diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index eaa250584ef..e538756cc10 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -6,7 +6,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -389,7 +389,7 @@ or `C-c a #' to produce the list." (defcustom org-agenda-filter-effort-default-operator "<" "The default operator for effort estimate filtering. -If you select an effort estimate limit with first pressing an operator, +If you select an effort estimate limit without first pressing an operator, this one will be used." :group 'org-agenda-custom-commands :type '(choice (const :tag "less or equal" "<") @@ -409,7 +409,7 @@ t, also all archive files associated with the current selection of agenda files will be included.") (defcustom org-agenda-skip-comment-trees t - "Non-nil means, skip trees that start with teh COMMENT keyword. + "Non-nil means, skip trees that start with the COMMENT keyword. When nil, these trees are also scand by agenda commands." :group 'org-agenda-skip :type 'boolean) @@ -650,6 +650,16 @@ given here." :group 'org-agenda-daily/weekly :type 'number) +(defcustom org-agenda-log-mode-items '(closed clock) + "List of items that should be shown in agenda log mode. +This list may contain the following symbols: + + closed Show entries that have been closed on that day. + clock Show entries that have received clocked time on that day. + state Show all logged state changes." + :group 'org-agenda-daily/weekly + :type '(set :greedy t (const closed) (const clock) (const state))) + (defcustom org-agenda-start-with-clockreport-mode nil "The initial value of clockreport-mode in a newly created agenda window." :group 'org-agenda-startup @@ -1585,12 +1595,11 @@ s Search for keywords C Configure custom agenda commands "Prefix key")))) prefixes)) (goto-char (point-min)) - (when (fboundp 'fit-window-to-buffer) - (if second-time - (if (not (pos-visible-in-window-p (point-max))) - (fit-window-to-buffer)) - (setq second-time t) - (fit-window-to-buffer))) + (if second-time + (if (not (pos-visible-in-window-p (point-max))) + (org-fit-window-to-buffer)) + (setq second-time t) + (org-fit-window-to-buffer)) (message "Press key for agenda command%s:" (if (or restrict-ok org-agenda-overriding-restriction) (if org-agenda-overriding-restriction @@ -1870,40 +1879,79 @@ higher priority settings." (org-let (if nosettings nil org-agenda-exporter-settings) '(save-excursion (save-window-excursion - (cond - ((string-match "\\.html?\\'" file) - (set-buffer (htmlize-buffer (current-buffer))) - - (when (and org-agenda-export-html-style - (string-match "")) - (insert org-agenda-export-html-style)) - (write-file file) - (kill-buffer (current-buffer)) - (message "HTML written to %s" file)) - ((string-match "\\.ps\\'" file) - (ps-print-buffer-with-faces file) - (message "Postscript written to %s" file)) - ((string-match "\\.ics\\'" file) - (let ((org-agenda-marker-table - (org-create-marker-find-array - (org-agenda-collect-markers))) - (org-icalendar-verify-function 'org-check-agenda-marker-table) - (org-combined-agenda-icalendar-file file)) - (apply 'org-export-icalendar 'combine - (org-agenda-files nil 'ifmode)))) - (t - (let ((bs (buffer-string))) - (find-file file) - (erase-buffer) + (org-agenda-mark-filtered-text) + (let ((bs (copy-sequence (buffer-string))) beg) + (org-agenda-unmark-filtered-text) + (with-temp-buffer (insert bs) - (save-buffer 0) - (kill-buffer (current-buffer)) - (message "Plain text written to %s" file)))))) + (org-agenda-remove-marked-text 'org-filtered) + (while (setq beg (text-property-any (point-min) (point-max) + 'org-filtered t)) + (delete-region + beg (or (next-single-property-change beg 'org-filtered) + (point-max)))) + (cond + ((string-match "\\.html?\\'" file) + (set-buffer (htmlize-buffer (current-buffer))) + + (when (and org-agenda-export-html-style + (string-match "")) + (insert org-agenda-export-html-style)) + (write-file file) + (kill-buffer (current-buffer)) + (message "HTML written to %s" file)) + ((string-match "\\.ps\\'" file) + (ps-print-buffer-with-faces file) + (message "Postscript written to %s" file)) + ((string-match "\\.ics\\'" file) + (let ((org-agenda-marker-table + (org-create-marker-find-array + (org-agenda-collect-markers))) + (org-icalendar-verify-function 'org-check-agenda-marker-table) + (org-combined-agenda-icalendar-file file)) + (apply 'org-export-icalendar 'combine + (org-agenda-files nil 'ifmode)))) + (t + (let ((bs (buffer-string))) + (find-file file) + (erase-buffer) + (insert bs) + (save-buffer 0) + (kill-buffer (current-buffer)) + (message "Plain text written to %s" file)))))))) (set-buffer org-agenda-buffer-name))) +(defvar org-agenda-filter-overlays nil) + +(defun org-agenda-mark-filtered-text () + "Mark all text hidden by filtering with a text property." + (let ((inhibit-read-only t)) + (mapc + (lambda (o) + (when (equal (org-overlay-buffer o) (current-buffer)) + (put-text-property + (org-overlay-start o) (org-overlay-end o) + 'org-filtered t))) + org-agenda-filter-overlays))) + +(defun org-agenda-unmark-filtered-text () + "Remove the filtering text property." + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(org-filtered t)))) + +(defun org-agenda-remove-marked-text (property &optional value) + "Delete all text marked with VALUE of PROPERTY. +VALUE defaults to t." + (let (beg) + (setq value (or value t)) + (while (setq beg (text-property-any (point-min) (point-max) + property value)) + (delete-region + beg (or (next-single-property-change beg 'org-filtered) + (point-max)))))) (defun org-agenda-collect-markers () "Collect the markers pointing to entries in the agenda buffer." @@ -1952,7 +2000,7 @@ higher priority settings." "Fit the window to the buffer size." (and (memq org-agenda-window-setup '(reorganize-frame)) (fboundp 'fit-window-to-buffer) - (fit-window-to-buffer + (org-fit-window-to-buffer nil (floor (* (frame-height) (cdr org-agenda-window-frame-fractions))) (floor (* (frame-height) (car org-agenda-window-frame-fractions)))))) @@ -2378,13 +2426,18 @@ given in `org-agenda-start-on-weekday'." (while (setq file (pop files)) (catch 'nextfile (org-check-agenda-file file) - (if org-agenda-show-log - (setq rtn (org-agenda-get-day-entries - file date - :deadline :scheduled :timestamp :sexp :closed)) + (cond + ((eq org-agenda-show-log 'only) + (setq rtn (org-agenda-get-day-entries + file date :closed))) + (org-agenda-show-log (setq rtn (org-agenda-get-day-entries file date - :deadline :scheduled :sexp :timestamp))) + :deadline :scheduled :timestamp :sexp :closed))) + (t + (setq rtn (org-agenda-get-day-entries + file date + :deadline :scheduled :sexp :timestamp)))) (setq rtnall (append rtnall rtn)))) (if org-agenda-include-diary (progn @@ -3127,7 +3180,7 @@ the documentation of `org-diary'." (setq rtn (org-agenda-get-scheduled)) (setq results (append results rtn))) ((eq arg :closed) - (setq rtn (org-agenda-get-closed)) + (setq rtn (org-agenda-get-progress)) (setq results (append results rtn))) ((eq arg :deadline) (setq rtn (org-agenda-get-deadlines)) @@ -3331,7 +3384,8 @@ the documentation of `org-diary'." (push txt ee)))) (nreverse ee))) -(defun org-agenda-get-closed () +(defalias 'org-get-closed 'org-get-progress) +(defun org-agenda-get-progress () "Return the logged TODO entries for agenda display." (let* ((props (list 'mouse-face 'highlight 'org-not-done-regexp org-not-done-regexp @@ -3341,8 +3395,20 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) + (items (if (consp org-agenda-show-log) + org-agenda-show-log + org-agenda-log-mode-items)) + (parts + (delq nil + (list + (if (memq 'closed items) (concat "\\<" org-closed-string)) + (if (memq 'clock items) (concat "\\<" org-clock-string)) + (if (memq 'state items) "- State \"\\([a-zA-Z0-9]+\\)\"")))) + (parts-re (if parts (mapconcat 'identity parts "\\|") + (error "`org-agenda-log-mode-items' is empty"))) (regexp (concat - "\\<\\(" org-closed-string "\\|" org-clock-string "\\) *\\[" + "\\(" parts-re "\\)" + " *\\[" (regexp-quote (substring (format-time-string @@ -3350,7 +3416,7 @@ the documentation of `org-diary'." (apply 'encode-time ; DATE bound by calendar (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 1 11)))) - marker hdmarker priority category tags closedp + marker hdmarker priority category tags closedp statep state ee txt timestr rest clocked) (goto-char (point-min)) (while (re-search-forward regexp nil t) @@ -3358,6 +3424,8 @@ the documentation of `org-diary'." (org-agenda-skip) (setq marker (org-agenda-new-marker (match-beginning 0)) closedp (equal (match-string 1) org-closed-string) + statep (equal (string-to-char (match-string 1)) ?-) + state (and statep (match-string 2)) category (org-get-category (match-beginning 0)) timestr (buffer-substring (match-beginning 0) (point-at-eol)) ;; donep (org-entry-is-done-p) @@ -3366,7 +3434,7 @@ the documentation of `org-diary'." ;; substring should only run to end of time stamp (setq rest (substring timestr (match-end 0)) timestr (substring timestr 0 (match-end 0))) - (if (and (not closedp) + (if (and (not closedp) (not statep) (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)" rest)) (progn (setq timestr (concat (substring timestr 0 -1) "-" (match-string 1 rest) "]")) @@ -3380,8 +3448,10 @@ the documentation of `org-diary'." tags (org-get-tags-at)) (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") (setq txt (org-format-agenda-item - (if closedp "Closed: " - (concat "Clocked: (" clocked ")")) + (cond + (closedp "Closed: ") + (statep (concat "State: (" state ")")) + (t (concat "Clocked: (" clocked ")"))) (match-string 1) category tags timestr))) (setq txt org-agenda-no-heading-message)) (setq priority 100000) @@ -4238,7 +4308,7 @@ E looks line \"+<2:25\"." If the line does not have an effort defined, return nil." (let ((eff (get-text-property (point) 'effort-minutes))) (if (not eff) - nil ; we don't have an effort defined + 0 ; we don't have an effort defined, treat as 0 (funcall op eff value)))) (defun org-agenda-filter-apply (filter) @@ -4258,8 +4328,6 @@ If the line does not have an effort defined, return nil." (beginning-of-line 2)) (beginning-of-line 2)))))) -(defvar org-agenda-filter-overlays nil) - (defun org-agenda-filter-by-tag-hide-line () (let (ov) (setq ov (org-make-overlay (max (point-min) (1- (point-at-bol))) @@ -4565,11 +4633,18 @@ so that the date SD will be in that range." (message "Clocktable mode is %s" (if org-agenda-clockreport-mode "on" "off"))) -(defun org-agenda-log-mode () - "Toggle log mode in an agenda buffer." - (interactive) +(defun org-agenda-log-mode (&optional special) + "Toggle log mode in an agenda buffer. +With argument SPECIAL, show all possible log items, not only the ones +configured in `org-agenda-log-mode-items'. +With a double `C-u' prefix arg, show *only* log items, nothing else." + (interactive "P") (org-agenda-check-type t 'agenda 'timeline) - (setq org-agenda-show-log (not org-agenda-show-log)) + (setq org-agenda-show-log + (if (equal special '(16)) + 'only + (if special '(closed clock state) + (not org-agenda-show-log)))) (org-agenda-set-mode-name) (org-agenda-redo) (message "Log mode is %s" @@ -4622,7 +4697,8 @@ so that the date SD will be in that range." (if org-agenda-follow-mode " Follow" "") (if org-agenda-include-diary " Diary" "") (if org-agenda-use-time-grid " Grid" "") - (if org-agenda-show-log " Log" "") + (if (consp org-agenda-show-log) " LogAll" + (if org-agenda-show-log " Log" "")) (if org-agenda-filter (concat " {" (mapconcat 'identity org-agenda-filter "") "}") "") @@ -4890,8 +4966,10 @@ the same tree node, and the headline of the tree node in the Org-mode file." (buffer (marker-buffer marker)) (pos (marker-position marker)) (hdmarker (get-text-property (point) 'org-hd-marker)) + (todayp (equal (get-text-property (point) 'day) + (time-to-days (current-time)))) (inhibit-read-only t) - newhead) + org-agenda-headline-snapshot-before-repeat newhead just-one) (org-with-remote-undo buffer (with-current-buffer buffer (widen) @@ -4903,12 +4981,19 @@ the same tree node, and the headline of the tree node in the Org-mode file." (org-todo arg) (and (bolp) (forward-char 1)) (setq newhead (org-get-heading)) + (when (and (org-bound-and-true-p + org-agenda-headline-snapshot-before-repeat) + (not (equal org-agenda-headline-snapshot-before-repeat + newhead)) + todayp) + (setq newhead org-agenda-headline-snapshot-before-repeat + just-one t)) (save-excursion (org-back-to-heading) (move-marker org-last-heading-marker (point)))) (beginning-of-line 1) (save-excursion - (org-agenda-change-all-lines newhead hdmarker 'fixface)) + (org-agenda-change-all-lines newhead hdmarker 'fixface just-one)) (org-move-to-column col)))) (defun org-agenda-add-note (&optional arg) @@ -4930,7 +5015,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." (org-flag-heading nil))) ; show the next heading (org-add-note)))) -(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface) +(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface just-this) "Change all lines in the agenda buffer which match HDMARKER. The new content of the line will be NEWHEAD (as modified by `org-format-agenda-item'). HDMARKER is checked with @@ -4938,6 +5023,7 @@ The new content of the line will be NEWHEAD (as modified by If FIXFACE is non-nil, the face of each item is modified acording to the new TODO state." (let* ((inhibit-read-only t) + (line (org-current-line)) props m pl undone-face done-face finish new dotime cat tags) (save-excursion (goto-char (point-max)) @@ -4945,6 +5031,7 @@ the new TODO state." (while (not finish) (setq finish (bobp)) (when (and (setq m (get-text-property (point) 'org-hd-marker)) + (or (not just-this) (= (org-current-line) line)) (equal m hdmarker)) (setq props (text-properties-at (point)) dotime (get-text-property (point) 'dotime) @@ -5450,8 +5537,7 @@ This is a command that has to be installed in `calendar-mode-map'." "Chinese: " (calendar-chinese-date-string date) "\n")) (with-output-to-temp-buffer "*Dates*" (princ s)) - (if (fboundp 'fit-window-to-buffer) - (fit-window-to-buffer (get-buffer-window "*Dates*"))))) + (org-fit-window-to-buffer (get-buffer-window "*Dates*")))) ;;; Appointment reminders diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el index 75acc8e89ec..d580db989fe 100644 --- a/lisp/org/org-archive.el +++ b/lisp/org/org-archive.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el index 08b4a5997e6..feeb5f66a4d 100644 --- a/lisp/org/org-attach.el +++ b/lisp/org/org-attach.el @@ -4,7 +4,7 @@ ;; Author: John Wiegley ;; Keywords: org data task -;; Version: 6.10c +;; Version: 6.12a ;; This file is part of GNU Emacs. ;; @@ -125,7 +125,7 @@ F Like \"f\", but force using dired in Emacs. d Delete one attachment, you will be prompted for a file name. D Delete all of a task's attachments. A safer way is to open the directory in dired and delete from there."))) - (shrink-window-if-larger-than-buffer (get-buffer-window "*Org Attach*")) + (org-fit-window-to-buffer (get-buffer-window "*Org Attach*")) (message "Select command: [acmlzoOfFdD]") (setq c (read-char-exclusive)) (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*")))) @@ -156,11 +156,7 @@ the directory and the corresponding ID will be created." (let ((uuid (org-id-get (point) create-if-not-exists-p))) (when (or uuid create-if-not-exists-p) (unless uuid - (let ((uuid-string (shell-command-to-string "uuidgen"))) - (setf uuid-string - (substring uuid-string 0 (1- (length uuid-string)))) - (org-entry-put (point) "ID" uuid-string) - (setf uuid uuid-string))) + (error "ID retrieval/creation failed")) (let ((attach-dir (expand-file-name (format "%s/%s" (substring uuid 0 2) @@ -334,6 +330,17 @@ See `org-attach-open'." (interactive) (org-attach-open 'in-emacs)) +(defun org-attach-expand (file) + "Return the full path to the current entry's attachment file FILE. +Basically, this adds the path to the attachment directory." + (expand-file-name file (org-attach-dir))) + +(defun org-attach-expand-link (file) + "Return a file link pointing to the current entry's attachment file FILE. +Basically, this adds the path to the attachment directory, and a \"file:\" +prefix." + (concat "file:" (org-attach-expand file))) + (provide 'org-attach) ;; arch-tag: fce93c2e-fe07-4fa3-a905-e10dcc7a6248 diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el index ca68a20f684..13b3ff047df 100644 --- a/lisp/org/org-bbdb.el +++ b/lisp/org/org-bbdb.el @@ -6,7 +6,7 @@ ;; Thomas Baumann ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el index 94224afb100..b457121e446 100644 --- a/lisp/org/org-bibtex.el +++ b/lisp/org/org-bibtex.el @@ -5,7 +5,7 @@ ;; Author: Bastien Guerry ;; Carsten Dominik ;; Keywords: org, wp, remember -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index d5bfbf46906..d54a4900476 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -33,6 +33,7 @@ (require 'calendar)) (declare-function calendar-absolute-from-iso "cal-iso" (&optional date)) +(defvar org-time-stamp-formats) (defgroup org-clock nil "Options concerning clocking working time in Org-mode." @@ -95,6 +96,34 @@ The function is called with point at the beginning of the headline." :group 'org-clock :type 'integer) +(defcustom org-clock-in-resume nil + "If non-nil, when clocking into a task with a clock entry which +has not been closed, resume the clock from that point" + :group 'org-clock + :type 'boolean) + +(defcustom org-clock-persist nil + "When non-nil, save the running clock when emacs is closed, and + resume it next time emacs is started." + :group 'org-clock + :type 'boolean) + +(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el" + "File to save clock data to" + :group 'org-clock + :type 'string) + +(defcustom org-clock-persist-query-save nil + "When non-nil, ask before saving the current clock on exit" + :group 'org-clock + :type 'boolean) + +(defcustom org-clock-persist-query-resume t + "When non-nil, ask before resuming any stored clock during +load." + :group 'org-clock + :type 'boolean) + ;;; The clock for measuring work time. (defvar org-mode-line-string "") @@ -175,9 +204,7 @@ of a different task.") (+ i (- ?A 10))) m)) (push s sel-list))) org-clock-history) - (if (fboundp 'fit-window-to-buffer) - (fit-window-to-buffer) - (shrink-window-if-larger-than-buffer)) + (org-fit-window-to-buffer) (message (or prompt "Select task for clocking:")) (setq rpl (read-char-exclusive)) (cond @@ -291,12 +318,21 @@ the clocking selection, associated with the letter `d'." (t "???"))) (setq org-clock-heading (org-propertize org-clock-heading 'face nil)) (org-clock-find-position) - - (insert "\n") (backward-char 1) - (org-indent-line-function) - (insert org-clock-string " ") - (setq org-clock-start-time (current-time)) - (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive)) + (if (and org-clock-in-resume + (looking-at (concat "^[ \\t]* " org-clock-string + " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" + " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$"))) + (progn (message "Matched %s" (match-string 1)) + (setq ts (concat "[" (match-string 1) "]")) + (goto-char (match-end 1)) + (setq org-clock-start-time + (apply 'encode-time (org-parse-time-string (match-string 1))))) + (progn + (insert "\n") (backward-char 1) + (org-indent-line-function) + (insert org-clock-string " ") + (setq org-clock-start-time (current-time)) + (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive)))) (move-marker org-clock-marker (point) (buffer-base-buffer)) (or global-mode-string (setq global-mode-string '(""))) (or (memq 'org-mode-line-string global-mode-string) @@ -783,7 +819,7 @@ the currently selected interval size." (te (plist-get params :tend)) (block (plist-get params :block)) (link (plist-get params :link)) - ipos time p level hlc hdl + ipos time p level hlc hdl content recalc formula pcol cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list) (setq org-clock-file-total-minutes nil) (when step @@ -923,9 +959,37 @@ the currently selected interval size." 'identity (delq nil tbl) (if scope-is-list "\n|-\n" "\n"))) (backward-delete-char 1) + (if (setq formula (plist-get params :formula)) + (cond + ((eq formula '%) + (setq pcol (+ (if scope-is-list 1 0) maxlevel 3)) + (insert + (format + "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f" + pcol + 2 + (+ 3 (if scope-is-list 1 0)) + (+ (if scope-is-list 1 0) 3) + (1- pcol))) + (setq recalc t)) + ((stringp formula) + (insert "\n#+TBLFM: " formula) + (setq recalc t)) + (t (error "invalid formula in clocktable"))) + ;; Should we rescue an old formula? + (when (stringp (setq content (plist-get params :content))) + (when (string-match "^\\(#\\+TBLFM:.*\\)" content) + (setq recalc t) + (insert "\n" (match-string 1 (plist-get params :content))) + (beginning-of-line 0)))) (goto-char ipos) (skip-chars-forward "^|") (org-table-align) + (when recalc + (if (eq formula '%) + (save-excursion (org-table-goto-column pcol nil 'force) + (insert "%"))) + (org-table-recalculate 'all)) (when rm-file-column (forward-char 1) (org-table-delete-column))))))) @@ -962,7 +1026,6 @@ the currently selected interval size." (re-search-forward "#\\+END:") (end-of-line 0)))) - (defun org-clocktable-add-file (file table) (if table (let ((lines (org-split-string table "\n")) @@ -975,6 +1038,102 @@ the currently selected interval size." lines) "\n")))) +(defun org-clock-time% (total &rest strings) + "Compute a time fraction in percent. +TOTAL s a time string like 10:21 specifying the total times. +STRINGS is a list of strings that should be checked for a time. +The first string that does have a time will be used. +This function is made for clock tables." + (let ((re "\\([0-9]+\\):\\([0-9]+\\)") + tot s) + (save-match-data + (catch 'exit + (if (not (string-match re total)) + (throw 'exit 0.) + (setq tot (+ (string-to-number (match-string 2 total)) + (* 60 (string-to-number (match-string 1 total))))) + (if (= tot 0.) (throw 'exit 0.))) + (while (setq s (pop strings)) + (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) + (throw 'exit + (/ (* 100.0 (+ (string-to-number (match-string 2 s)) + (* 60 (string-to-number (match-string 1 s))))) + tot)))) + 0)))) + +(defun org-clock-save () + "Persist various clock-related data to disk" + (with-current-buffer (find-file (expand-file-name org-clock-persist-file)) + (progn (delete-region (point-min) (point-max)) + ;;Store clock + (insert (format ";; org-persist.el - %s at %s\n" + system-name (format-time-string + (cdr org-time-stamp-formats)))) + (if (and org-clock-persist (marker-buffer org-clock-marker) + (or (not org-clock-persist-query-save) + (y-or-n-p (concat "Save current clock (" + (substring-no-properties org-clock-heading) + ")")))) + (insert "(setq resume-clock '(\"" + (buffer-file-name (marker-buffer org-clock-marker)) + "\" . " (int-to-string (marker-position org-clock-marker)) + "))\n")) + ;;Store clocked task history. Tasks are stored reversed to make + ;;reading simpler + (if org-clock-history + (insert "(setq stored-clock-history '(" + (mapconcat + (lambda (m) + (when (marker-buffer m) + (concat "(\"" (buffer-file-name (marker-buffer m)) + "\" . " (int-to-string (marker-position m)) + ")"))) + (reverse org-clock-history) " ") "))\n")) + (save-buffer) + (kill-buffer (current-buffer))))) + +(defvar org-clock-loaded nil) + +(defun org-clock-load () + "Load various clock-related data from disk, optionally resuming +a stored clock" + (if (not org-clock-loaded) + (let ((filename (expand-file-name org-clock-persist-file)) + (org-clock-in-resume t)) + (if (file-readable-p filename) + (progn + (message "%s" "Restoring clock data") + (setq org-clock-loaded t) + (load-file filename) + ;; load history + (if (boundp 'stored-clock-history) + (save-window-excursion + (mapc (lambda (task) + (org-clock-history-push (cdr task) + (find-file (car task)))) + stored-clock-history))) + ;; resume clock + (if (and (boundp 'resume-clock) org-clock-persist + (or (not org-clock-persist-query-resume) + (y-or-n-p + (concat + "Resume clock (" + (with-current-buffer (find-file (car resume-clock)) + (progn (goto-char (cdr resume-clock)) + (looking-at org-complex-heading-regexp) + (match-string 4))) ")")))) + (with-current-buffer (find-file (car resume-clock)) + (progn (goto-char (cdr resume-clock)) + (org-clock-in))))) + (message "Not restoring clock data; %s not found" + org-clock-persist-file))))) + +;;;###autoload +(defun org-clock-persistence-insinuate () + "Set up hooks for clock persistence" + (add-hook 'org-mode-hook 'org-clock-load) + (add-hook 'kill-emacs-hook 'org-clock-save)) + (provide 'org-clock) ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el index 6580def46e2..b3be9f28161 100644 --- a/lisp/org/org-colview.el +++ b/lisp/org/org-colview.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 075fbac46e9..df0b187f472 100644 --- a/lisp/org/org-compat.el +++ b/lisp/org/org-compat.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -150,6 +150,22 @@ that will be added to PLIST. Returns the string that was modified." string) (put 'org-add-props 'lisp-indent-function 2) +(defun org-fit-window-to-buffer (&optional window max-height min-height + shrink-only) + "Fit WINDOW to the buffer, but only if it is not a side-by-side window. +WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are +passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call +`shrink-window-if-larger-than-buffer' instead, the hight limit are +ignored in this case." + (cond ((> (frame-width) (window-width window)) + ;; do nothing if another window would suffer + ) + ((and (fboundp 'fit-window-to-buffer) (not shrink-only)) + (fit-window-to-buffer window max-height min-height)) + ((fboundp 'shrink-window-if-larger-than-buffer) + (shrink-window-if-larger-than-buffer window))) + (or window (selected-window))) + ;; Region compatibility (defvar org-ignore-region nil diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el index c5c0bb30d47..87023e74c07 100644 --- a/lisp/org/org-exp.el +++ b/lisp/org/org-exp.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -70,7 +70,7 @@ force an export command into the current process." If any such tag is found in a buffer, all trees that do not carry one of these tags will be deleted before export. Inside trees that are selected like this, you can still deselect a -subtree by tagging it with one of the `org-export-excude-tags'." +subtree by tagging it with one of the `org-export-exclude-tags'." :group 'org-export-general :type '(repeat (string :tag "Tag"))) @@ -98,18 +98,24 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"." :type 'boolean) (defcustom org-export-language-setup - '(("en" "Author" "Date" "Table of Contents") - ("cs" "Autor" "Datum" "Obsah") - ("da" "Ophavsmand" "Dato" "Indhold") - ("de" "Autor" "Datum" "Inhaltsverzeichnis") - ("es" "Autor" "Fecha" "\xcdndice") - ("fr" "Auteur" "Date" "Table des mati\xe8res") - ("it" "Autore" "Data" "Indice") - ("nl" "Auteur" "Datum" "Inhoudsopgave") - ("no" "Forfatter" "Dato" "Innhold") - ("nb" "Forfatter" "Dato" "Innhold") ;; nb = Norsk (bokm.l) - ("nn" "Forfattar" "Dato" "Innhald") ;; nn = Norsk (nynorsk) - ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll")) + '(("en" "Author" "Date" "Table of Contents" "Footnotes") + ("ca" "Autor" "Data" "Índex" "Peus de pàgina") + ("cs" "Autor" "Datum" "Obsah" "Pozn\xe1mky pod carou") + ("da" "Ophavsmand" "Dato" "Indhold" "Fodnoter") + ("de" "Autor" "Datum" "Inhaltsverzeichnis" "Fußnoten") + ("eo" "Aŭtoro" "Dato" "Enhavo" "Piednotoj") + ("es" "Autor" "Fecha" "Índice" "Pies de página") + ("fi" "Tekijä" "Päivämäärä" "Sisällysluettelo" "Alaviitteet") + ("fr" "Auteur" "Date" "Table des matières" "Notes de bas de page") + ("hu" "Szerzõ" "Dátum" "Tartalomjegyzék" "Lábjegyzet") + ("is" "Höfundur" "Dagsetning" "Efnisyfirlit" "Aftanmálsgreinar") + ("it" "Autore" "Data" "Indice" "Note a piè di pagina") + ("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten") + ("no" "Forfatter" "Dato" "Innhold" "Fotnoter") + ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l) + ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk) + ("pl" "Autor" "Data" "Spis treści" "Przypis") + ("sv" "Författare" "Datum" "Innehåll" "Fotnoter")) "Terms used in export text, translated to different languages. Use the variable `org-export-default-language' to set the language, or use the +OPTION lines for a per-file setting." @@ -119,7 +125,8 @@ or use the +OPTION lines for a per-file setting." (string :tag "HTML language tag") (string :tag "Author") (string :tag "Date") - (string :tag "Table of Contents")))) + (string :tag "Table of Contents") + (string :tag "Footnotes")))) (defcustom org-export-default-language "en" "The default language of HTML export, as a string. @@ -303,6 +310,19 @@ This option can also be set with the +OPTIONS line, e.g. \"f:nil\"." :group 'org-export-translation :type 'boolean) +(defcustom org-export-html-footnotes-section "
+

%s:

+
+%s +
+
" + "Format for the footnotes section. +Should contain a two instances of %s. The first will be replaced with the +language-specific word for \"Footnotes\", the second one will be replaced +by the footnotes themselves." + :group 'org-export-html + :type 'string) + (defcustom org-export-with-sub-superscripts t "Non-nil means, interpret \"_\" and \"^\" for export. When this option is turned on, you can use TeX-like syntax for sub- and @@ -492,6 +512,7 @@ Org-mode file." (defconst org-export-html-style-default "" "The default style specification for exported HTML files. Please use the variables `org-export-html-style' and -`org-export-html-style-extra' to add to this style.") +`org-export-html-style-extra' to add to this style. If you wish to not +have the default style included, customize the variable +`org-export-html-style-include-default'.") + +(defcustom org-export-html-style-include-default t + "Non-nil means, include the default style in exported HTML files. +The actualy style is defined in `org-export-html-style-default' and should +not be modified. Use the variables `org-export-html-style' to add +your own style information." + :group 'org-export-html + :type 'boolean) +;;;###autoload +(put 'org-export-html-style 'safe-local-variable 'booleanp) (defcustom org-export-html-style "" "Org-wide style definitions for exported HTML files. @@ -535,11 +568,13 @@ you should consider to include definitions for the following classes: For example, a valid value would be: If you'd like to refer to en external style file, use something like @@ -812,6 +847,7 @@ or if they are only using it locally." (:time-stamp-file . org-export-time-stamp-file) (:tables . org-export-with-tables) (:table-auto-headline . org-export-highlight-first-table-line) + (:style-include-default . org-export-html-style-include-default) (:style . org-export-html-style) (:style-extra . org-export-html-style-extra) (:agenda-style . org-agenda-export-html-style) @@ -1046,9 +1082,8 @@ value of `org-export-run-in-background'." (delete-other-windows) (with-output-to-temp-buffer "*Org Export/Publishing Help*" (princ help)) - (if (fboundp 'fit-window-to-buffer) - (fit-window-to-buffer (get-buffer-window - "*Org Export/Publishing Help*"))) + (org-fit-window-to-buffer (get-buffer-window + "*Org Export/Publishing Help*")) (message "Select command: ") (setq r1 (read-char-exclusive))) (setq r2 (if (< r1 27) (+ r1 96) r1)) @@ -2597,7 +2632,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff." #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s %s #+EXPORT_SELECT_TAGS: %s -#+EXPORT_EXCUDE_TAGS: %s +#+EXPORT_EXCLUDE_TAGS: %s #+LINK_UP: %s #+LINK_HOME: %s #+CATEGORY: %s @@ -2764,6 +2799,7 @@ in a window. A non-interactive call will only return the buffer." rtn))) (defvar html-table-tag nil) ; dynamically scoped into this. +(defvar org-par-open nil) ;;;###autoload (defun org-export-as-html (arg &optional hidden ext-plist to-buffer body-only pub-dir) @@ -2802,8 +2838,8 @@ PUB-DIR is set, use this as the publishing directory." (org-combine-plists (org-default-export-plist) ext-plist (org-infile-export-plist)))) - - (style (concat org-export-html-style-default + (style (concat (if (plist-get opt-plist :style-include-default) + org-export-html-style-default) (plist-get opt-plist :style) (plist-get opt-plist :style-extra))) (html-extension (plist-get opt-plist :html-extension)) @@ -2915,6 +2951,7 @@ PUB-DIR is set, use this as the publishing directory." ind item-type starter didclose rpl path attr desc descp desc1 desc2 link snumber fnc item-tag + footnotes ) (let ((inhibit-read-only t)) @@ -3085,6 +3122,7 @@ lang=\"%s\" xml:lang=\"%s\"> (string-match "^[ \t]*:\\(.*\\)" line)) (when (not infixed) (setq infixed t) + (org-close-par-maybe) (insert "
\n"))
 	    (insert (org-html-protect (match-string 1 line)) "\n")
 	    (when (or (not lines)
@@ -3112,7 +3150,9 @@ lang=\"%s\" xml:lang=\"%s\">
 
 	  ;; Horizontal line
 	  (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
-	    (insert "\n
\n") + (if org-par-open + (insert "\n

\n
\n

\n") + (insert "\n


\n")) (throw 'nextline nil)) ;; Blockquotes and verse @@ -3202,7 +3242,9 @@ lang=\"%s\" xml:lang=\"%s\"> "" desc ""))) + "\"" attr ">" + (org-export-html-format-desc desc) + ""))) ((member type '("http" "https")) ;; standard URL, just check if we need to inline an image (if (and (or (eq t org-export-html-inline-images) @@ -3210,12 +3252,19 @@ lang=\"%s\" xml:lang=\"%s\"> (org-file-image-p path)) (setq rpl (concat "")) (setq link (concat type ":" path)) - (setq rpl (concat "" - desc "")))) + (setq rpl (concat "" + (org-export-html-format-desc desc) + "")))) ((member type '("ftp" "mailto" "news")) ;; standard URL (setq link (concat type ":" path)) - (setq rpl (concat "" desc ""))) + (setq rpl (concat "" + (org-export-html-format-desc desc) + ""))) ((functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) ;; The link protocol has a function for format the link @@ -3261,7 +3310,8 @@ lang=\"%s\" xml:lang=\"%s\"> (not descp)))) (concat "") (concat "" - desc ""))) + (org-export-html-format-desc desc) + ""))) (if (not valid) (setq rpl desc)))) (t @@ -3322,6 +3372,7 @@ lang=\"%s\" xml:lang=\"%s\"> head-count) ;; QUOTES (when (string-match quote-re line) + (org-close-par-maybe) (insert "
")
 	      (setq inquote t)))
 
@@ -3415,12 +3466,17 @@ lang=\"%s\" xml:lang=\"%s\">
 
 	    ;; Is this the start of a footnote?
 	    (when org-export-with-footnotes
+	      (when (and (boundp 'footnote-section-tag-regexp)
+			 (string-match (concat "^" footnote-section-tag-regexp)
+				       line))
+		;; ignore this line
+		(throw 'nextline nil))
 	      (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
 		(org-close-par-maybe)
 		(let ((n (match-string 1 line)))
-		  (setq line (replace-match
-			      (format "

%s" n n n) t t line)) - (setq line (concat line "

"))))) + (setq org-par-open t + line (replace-match + (format "

%s" n n n) t t line))))) ;; Check if the line break needs to be conserved (cond @@ -3432,7 +3488,9 @@ lang=\"%s\" xml:lang=\"%s\"> (insert line "\n"))))) ;; Properly close all local lists and other lists - (when inquote (insert "

\n")) + (when inquote + (insert "
\n") + (org-open-par)) (when in-local-list ;; Close any local lists before inserting a new header line (while local-list-type @@ -3447,6 +3505,16 @@ lang=\"%s\" xml:lang=\"%s\"> ;; the to close the last text-... div. (insert "\n") + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "

[^\000]*?\\(

\\|\\'\\)" nil t) + (push (match-string 0) footnotes) + (replace-match "" t t))) + (when footnotes + (insert (format org-export-html-footnotes-section + (or (nth 4 lang-words) "Footnotes") + (mapconcat 'identity (nreverse footnotes) "\n")) + "\n")) (unless body-only (when (plist-get opt-plist :auto-postamble) (insert "
") @@ -3525,6 +3593,21 @@ lang=\"%s\" xml:lang=\"%s\"> (kill-buffer (current-buffer))) (current-buffer))))) +(defun org-export-html-format-href (s) + "Make sure the S is valid as a href reference in an XHTML document." + (save-match-data + (let ((start 0)) + (while (string-match "&" s start) + (setq start (+ (match-beginning 0) 3) + s (replace-match "&" t t s))))) + s) + +(defun org-export-html-format-desc (s) + "Make sure the S is valid as a description in a link." + (if s + (save-match-data + (org-html-do-expand s)) + s)) (defvar org-table-colgroup-info nil) (defun org-format-table-ascii (lines) @@ -3882,7 +3965,10 @@ that uses these same face definitions." (while (string-match "<" s) (setq s (replace-match "<" t t s))) (while (string-match ">" s) - (setq s (replace-match ">" t t s)))) + (setq s (replace-match ">" t t s))) +; (while (string-match "\"" s) +; (setq s (replace-match """ t t s))) + ) s) (defun org-export-cleanup-toc-line (s) @@ -4037,7 +4123,6 @@ stacked delimiters is N. Escaping delimiters is not possible." (setq s (1+ s)))) string)) -(defvar org-par-open nil) (defun org-open-par () "Insert

, but first close previous paragraph if any." (org-close-par-maybe) @@ -4384,9 +4469,9 @@ END:VEVENT\n" hd (concat (substring hd 0 (match-beginning 1)) (substring hd (match-end 1)))) (setq pri org-default-priority)) - (setq pri (floor (1+ (* 8. (/ (float (- org-lowest-priority pri)) - (- org-lowest-priority org-highest-priority)))))) - + (setq pri (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri)) + (- org-lowest-priority org-highest-priority)))))) + (princ (format "BEGIN:VTODO UID: %s %s diff --git a/lisp/org/org-export-latex.el b/lisp/org/org-export-latex.el index 7a6cc8e3c98..cf80dffa220 100644 --- a/lisp/org/org-export-latex.el +++ b/lisp/org/org-export-latex.el @@ -4,7 +4,7 @@ ;; ;; Emacs Lisp Archive Entry ;; Filename: org-export-latex.el -;; Version: 6.10c +;; Version: 6.12a ;; Author: Bastien Guerry ;; Maintainer: Bastien Guerry ;; Keywords: org, wp, tex diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el index 8244283be49..e24441135fa 100644 --- a/lisp/org/org-faces.el +++ b/lisp/org/org-faces.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el index d31f9a7826c..3f2781bbf36 100644 --- a/lisp/org/org-gnus.el +++ b/lisp/org/org-gnus.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -96,12 +96,11 @@ negates this setting for the duration of the command." (setq desc (org-email-link-description)) (if (org-xor current-prefix-arg org-usenet-links-prefer-google) (setq link - (concat - desc "\n " - (format "http://groups.google.com/groups?as_umsgid=%s" - (org-fixup-message-id-for-http message-id)))) - (setq link (org-make-link "gnus:" group - "#" (number-to-string article)))) + (format "http://groups.google.com/groups?as_umsgid=%s" + (org-fixup-message-id-for-http message-id))) + (setq link (org-make-link "gnus:" group "#" + (or message-id + (number-to-string article))))) (org-add-link-props :link link :description desc) link)))) @@ -121,9 +120,17 @@ negates this setting for the duration of the command." (if gnus-other-frame-object (select-frame gnus-other-frame-object)) (cond ((and group article) (gnus-group-read-group 1 nil group) - (gnus-summary-goto-article (string-to-number article) nil t)) + (gnus-summary-goto-article + (if (string-match "[^0-9]" article) + article + (string-to-number article)) + nil t)) (group (gnus-group-jump-to-group group)))) +(defun org-gnus-no-new-news () + "Like `M-x gnus' but doesn't check for new news." + (if (not (gnus-alive-p)) (gnus))) + (provide 'org-gnus) ;; arch-tag: 512e0840-58fa-45b3-b456-71e10fa2376d diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el index 5ba0c419a8a..764c0254e75 100644 --- a/lisp/org/org-id.el +++ b/lisp/org/org-id.el @@ -4,7 +4,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -251,7 +251,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"." (if (equal prefix ":") (setq prefix "")) (cond ((eq org-id-method 'uuidgen) - (setq unique (substring (shell-command-to-string "uuidgen") 1 -1))) + (setq unique (org-trim (shell-command-to-string "uuidgen")))) ((eq org-id-method 'org) (let* ((etime (org-id-reverse-string (org-id-time-to-b36))) (postfix (if org-id-include-domain diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el index b664d61f6e7..20127e4aca7 100644 --- a/lisp/org/org-info.el +++ b/lisp/org/org-info.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el index ed8e2fa68d2..acc99185822 100644 --- a/lisp/org/org-irc.el +++ b/lisp/org/org-irc.el @@ -4,7 +4,7 @@ ;; ;; Author: Philip Jackson ;; Keywords: erc, irc, link, org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el index 17a029dfc93..93a57de6185 100644 --- a/lisp/org/org-jsinfo.el +++ b/lisp/org/org-jsinfo.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 6.10c +;; Version: 6.12a ;; ;; This file is part of GNU Emacs. ;; @@ -104,8 +104,8 @@ means to use the maximum value consistent with other options." org-infojs-opts-table))) (defcustom org-infojs-template - " - +