Merge branch 'master' of orgmode.org:org-mode

This commit is contained in:
David Arroyo Menendez 2013-11-19 08:13:57 +01:00
commit dcddfae281
3 changed files with 511 additions and 276 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10520,11 +10520,29 @@ application the system uses for this file type."
(apply cmd (nreverse args1)))) (apply cmd (nreverse args1))))
((member type '("http" "https" "ftp" "news")) ((member type '("http" "https" "ftp" "news"))
(browse-url (concat type ":" (org-link-escape-browser path)))) ;; In the example of the http Org link
;; [[http://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emacs-orgmode&query=%252Bsubject:"Release+8.2"]]
;; to open a browser with +subject:"Release 8.2" in the
;; query field the variable `path' contains
;; [...]=%2Bsubject:"Release+8.2", `url-encode-url'
;; converts correct to [...]=%2Bsubject:%22Release+8.2%22
;; and `org-link-escape-browser' converts wrong to
;; [...]=%252Bsubject:%22Release+8.2%22.
;;
;; `url-encode-url' is available since Emacs 24.3.1 and
;; `org-link-escape-browser' can be removed altogether
;; once Org drops support for Emacs 24.1 and 24.2.
(browse-url (funcall (if (fboundp 'url-encode-url)
#'url-encode-url
#'org-link-escape-browser)
(concat type ":" path))))
((string= type "doi") ((string= type "doi")
(browse-url (concat org-doi-server-url ;; See comments for type http above
(org-link-escape-browser path)))) (browse-url (funcall (if (fboundp 'url-encode-url)
#'url-encode-url
#'org-link-escape-browser)
(concat org-doi-server-url path))))
((member type '("message")) ((member type '("message"))
(browse-url (concat type ":" path))) (browse-url (concat type ":" path)))
@ -15226,103 +15244,102 @@ is a string only get exactly this property. SPECIFIC can be a string, the
specific property we are interested in. Specifying it can speed specific property we are interested in. Specifying it can speed
things up because then unnecessary parsing is avoided." things up because then unnecessary parsing is avoided."
(setq which (or which 'all)) (setq which (or which 'all))
(org-with-point-at pom (org-with-wide-buffer
(let ((clockstr (substring org-clock-string 0 -1)) (org-with-point-at pom
(excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED")) (let ((clockstr (substring org-clock-string 0 -1))
(case-fold-search nil) (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED"))
beg end range props sum-props key key1 value string clocksum clocksumt) (case-fold-search nil)
(save-excursion beg end range props sum-props key key1 value string clocksum clocksumt)
(when (condition-case nil (when (and (derived-mode-p 'org-mode)
(and (derived-mode-p 'org-mode) (org-back-to-heading t)) (ignore-errors (org-back-to-heading t)))
(error nil)) (setq beg (point))
(setq beg (point)) (setq sum-props (get-text-property (point) 'org-summaries))
(setq sum-props (get-text-property (point) 'org-summaries)) (setq clocksum (get-text-property (point) :org-clock-minutes)
(setq clocksum (get-text-property (point) :org-clock-minutes) clocksumt (get-text-property (point) :org-clock-minutes-today))
clocksumt (get-text-property (point) :org-clock-minutes-today)) (outline-next-heading)
(outline-next-heading) (setq end (point))
(setq end (point)) (when (memq which '(all special))
(when (memq which '(all special)) ;; Get the special properties, like TODO and tags
;; Get the special properties, like TODO and tags (goto-char beg)
(goto-char beg) (when (and (or (not specific) (string= specific "TODO"))
(when (and (or (not specific) (string= specific "TODO")) (looking-at org-todo-line-regexp) (match-end 2))
(looking-at org-todo-line-regexp) (match-end 2)) (push (cons "TODO" (org-match-string-no-properties 2)) props))
(push (cons "TODO" (org-match-string-no-properties 2)) props)) (when (and (or (not specific) (string= specific "PRIORITY"))
(when (and (or (not specific) (string= specific "PRIORITY")) (looking-at org-priority-regexp))
(looking-at org-priority-regexp)) (push (cons "PRIORITY" (org-match-string-no-properties 2)) props))
(push (cons "PRIORITY" (org-match-string-no-properties 2)) props)) (when (or (not specific) (string= specific "FILE"))
(when (or (not specific) (string= specific "FILE")) (push (cons "FILE" buffer-file-name) props))
(push (cons "FILE" buffer-file-name) props)) (when (and (or (not specific) (string= specific "TAGS"))
(when (and (or (not specific) (string= specific "TAGS")) (setq value (org-get-tags-string))
(setq value (org-get-tags-string)) (string-match "\\S-" value))
(string-match "\\S-" value)) (push (cons "TAGS" value) props))
(push (cons "TAGS" value) props)) (when (and (or (not specific) (string= specific "ALLTAGS"))
(when (and (or (not specific) (string= specific "ALLTAGS")) (setq value (org-get-tags-at)))
(setq value (org-get-tags-at))) (push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":")
(push (cons "ALLTAGS" (concat ":" (mapconcat 'identity value ":") ":"))
":")) props))
props)) (when (or (not specific) (string= specific "BLOCKED"))
(when (or (not specific) (string= specific "BLOCKED")) (push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props))
(push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props)) (when (or (not specific)
(when (or (not specific) (member specific
(member specific '("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED"
'("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED" "TIMESTAMP" "TIMESTAMP_IA")))
"TIMESTAMP" "TIMESTAMP_IA"))) (catch 'match
(catch 'match (while (re-search-forward org-maybe-keyword-time-regexp end t)
(while (re-search-forward org-maybe-keyword-time-regexp end t) (setq key (if (match-end 1)
(setq key (if (match-end 1) (substring (org-match-string-no-properties 1)
(substring (org-match-string-no-properties 1) 0 -1))
0 -1)) string (if (equal key clockstr)
string (if (equal key clockstr) (org-trim
(org-trim (buffer-substring-no-properties
(buffer-substring-no-properties (match-beginning 3) (goto-char
(match-beginning 3) (goto-char (point-at-eol))))
(point-at-eol)))) (substring (org-match-string-no-properties 3)
(substring (org-match-string-no-properties 3) 1 -1)))
1 -1))) ;; Get the correct property name from the key. This is
;; Get the correct property name from the key. This is ;; necessary if the user has configured time keywords.
;; necessary if the user has configured time keywords. (setq key1 (concat key ":"))
(setq key1 (concat key ":")) (cond
(cond ((not key)
((not key) (setq key
(setq key (if (= (char-after (match-beginning 3)) ?\[)
(if (= (char-after (match-beginning 3)) ?\[) "TIMESTAMP_IA" "TIMESTAMP")))
"TIMESTAMP_IA" "TIMESTAMP"))) ((equal key1 org-scheduled-string) (setq key "SCHEDULED"))
((equal key1 org-scheduled-string) (setq key "SCHEDULED")) ((equal key1 org-deadline-string) (setq key "DEADLINE"))
((equal key1 org-deadline-string) (setq key "DEADLINE")) ((equal key1 org-closed-string) (setq key "CLOSED"))
((equal key1 org-closed-string) (setq key "CLOSED")) ((equal key1 org-clock-string) (setq key "CLOCK")))
((equal key1 org-clock-string) (setq key "CLOCK"))) (if (and specific (equal key specific) (not (equal key "CLOCK")))
(if (and specific (equal key specific) (not (equal key "CLOCK"))) (progn
(progn (push (cons key string) props)
(push (cons key string) props) ;; no need to search further if match is found
;; no need to search further if match is found (throw 'match t))
(throw 'match t)) (when (or (equal key "CLOCK") (not (assoc key props)))
(when (or (equal key "CLOCK") (not (assoc key props))) (push (cons key string) props)))))))
(push (cons key string) props)))))))
(when (memq which '(all standard)) (when (memq which '(all standard))
;; Get the standard properties, like :PROP: ... ;; Get the standard properties, like :PROP: ...
(setq range (org-get-property-block beg end)) (setq range (org-get-property-block beg end))
(when range (when range
(goto-char (car range)) (goto-char (car range))
(while (re-search-forward org-property-re (while (re-search-forward org-property-re
(cdr range) t) (cdr range) t)
(setq key (org-match-string-no-properties 2) (setq key (org-match-string-no-properties 2)
value (org-trim (or (org-match-string-no-properties 3) ""))) value (org-trim (or (org-match-string-no-properties 3) "")))
(unless (member key excluded) (unless (member key excluded)
(push (cons key (or value "")) props))))) (push (cons key (or value "")) props)))))
(if clocksum (if clocksum
(push (cons "CLOCKSUM" (push (cons "CLOCKSUM"
(org-columns-number-to-string (/ (float clocksum) 60.) (org-columns-number-to-string (/ (float clocksum) 60.)
'add_times)) 'add_times))
props)) props))
(if clocksumt (if clocksumt
(push (cons "CLOCKSUM_T" (push (cons "CLOCKSUM_T"
(org-columns-number-to-string (/ (float clocksumt) 60.) (org-columns-number-to-string (/ (float clocksumt) 60.)
'add_times)) 'add_times))
props)) props))
(unless (assoc "CATEGORY" props) (unless (assoc "CATEGORY" props)
(push (cons "CATEGORY" (org-get-category)) props)) (push (cons "CATEGORY" (org-get-category)) props))
(append sum-props (nreverse props))))))) (append sum-props (nreverse props)))))))
(defun org-entry-get (pom property &optional inherit literal-nil) (defun org-entry-get (pom property &optional inherit literal-nil)
"Get value of PROPERTY for entry or content at point-or-marker POM. "Get value of PROPERTY for entry or content at point-or-marker POM.

View File

@ -205,31 +205,32 @@ mode holding TEXT. If the string \"<point>\" appears in TEXT
then remove it and place the point there before running BODY, then remove it and place the point there before running BODY,
otherwise place the point at the beginning of the inserted text." otherwise place the point at the beginning of the inserted text."
(declare (indent 1)) (declare (indent 1))
(let ((inside-text (if (stringp text) text (eval text)))) `(let ((inside-text (if (stringp ,text) ,text (eval ,text))))
`(with-temp-buffer (with-temp-buffer
(org-mode) (org-mode)
,(let ((point (string-match (regexp-quote "<point>") inside-text))) (let ((point (string-match (regexp-quote "<point>") inside-text)))
(if point (if point
`(progn (insert `(replace-match "" nil nil inside-text)) (progn (insert (replace-match "" nil nil inside-text))
(goto-char ,(match-beginning 0))) (goto-char (match-beginning 0)))
`(progn (insert ,inside-text) (progn (insert inside-text)
(goto-char (point-min))))) (goto-char (point-min)))))
,@body))) ,@body)))
(def-edebug-spec org-test-with-temp-text (form body)) (def-edebug-spec org-test-with-temp-text (form body))
(defmacro org-test-with-temp-text-in-file (text &rest body) (defmacro org-test-with-temp-text-in-file (text &rest body)
"Run body in a temporary file buffer with Org-mode as the active mode." "Run body in a temporary file buffer with Org-mode as the active mode."
(declare (indent 1)) (declare (indent 1))
(let ((file (make-temp-file "org-test")) (let ((results (gensym)))
(inside-text (if (stringp text) text (eval text))) `(let ((file (make-temp-file "org-test"))
(results (gensym))) (kill-buffer-query-functions nil)
`(let ((kill-buffer-query-functions nil) ,results) (inside-text (if (stringp ,text) ,text (eval ,text)))
(with-temp-file ,file (insert ,inside-text)) ,results)
(find-file ,file) (with-temp-file file (insert inside-text))
(find-file file)
(org-mode) (org-mode)
(setq ,results (progn ,@body)) (setq ,results (progn ,@body))
(save-buffer) (kill-buffer (current-buffer)) (save-buffer) (kill-buffer (current-buffer))
(delete-file ,file) (delete-file file)
,results))) ,results)))
(def-edebug-spec org-test-with-temp-text-in-file (form body)) (def-edebug-spec org-test-with-temp-text-in-file (form body))