diff lisp/org/org-agenda.el @ 99501:e3acb52d33e1

2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-yank): Make any prefix force normal yanking. Suppress folding if text would be swallowed into a folded subtree. (org-yank-folded-subtrees, org-yank): Docstring updates. * org-agenda.el (org-agenda-compare-effort): Treat no effort defined as 0. * org-exp.el (org-export-language-setup): Add Catalan and Esperanto language entries. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-refile): Allow refiling of entire regions. * org-clock.el (org-clock-time%): New function. * org.el (org-entry-get, org-entry-delete): Use safer regexps to retrieve property values. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-list): Handle the value `only' of org-agenda-show-log'. (org-agenda-log-mode): Interpret a double prefix arg. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-footnotes-section): New variable. (org-export-as-html): Use `org-export-html-footnotes-section' to insert the footnotes. (org-export-language-setup): Add "Footnotes" to language words. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-yank): Fix bug when not inserting a subtree. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org-vm.el (org-vm-follow-link): Call `vm-preview-current-message' instead of `vm-beginning-of-message'. * org.el (org-make-link-regexps): Make sure that links to gnus can contain brackets. 2008-11-12 Carsten Dominik <carsten.dominik@gmail.com> * org-attach.el (org-attach-dir): Remove duplicate ID creation code. * org-id.el (org-id-new): Use `org-trim' to extract the uuid from shell output. * org.el (org-link-abbrev-alist): Improve customization type. * org-attach.el (org-attach-expand-link, org-attach-expand): New functions. * org-agenda.el (org-agenda-get-progress): Renamed from `org-get-closed'. Implement searching for state changes as well. (org-agenda-log-mode-items): New option. (org-agenda-log-mode): New option prefix argument, interpreted as request to show all possible progress info. (org-agenda-get-day-entries): Call `org-get-progress' instead of `org-get-closed'. (org-agenda-set-mode-name): Handle the more complex log mode settings. (org-get-closed): New alias, pointing to `org-get-progress'. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-file-apps-defaults-gnu) (org-file-apps-defaults-macosx) (org-file-apps-defaults-windowsnt): Add an entry defining the system command. (org-file-apps): Allow `system' as key and value. (org-open-at-point): Explain the effect of a double prefix arg. (org-open-file): If the argument `in-emacs' is (16), i.e. corresponding to a double prefix argument, try to open the file externally. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-insert-link): Abbreviate absolute files names in links. Also, fix a bug in which the double C-u prefix would not be honored. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-insert-heading): If buffer does not end with a newline, add one if necessary to insert headline correctly. * org-exp.el (org-export-as-html): Make sure that <hr/> is between paragraphs, not inside. * org.el (org-todo): Quote `org-agenda-headline-snapshot-before-repeat'. * org-exp.el (org-export-as-html): Fully process link descriptions. (org-export-html-format-desc): New function. (org-export-as-html): Collect footnotes into the correct basket. (org-html-protect): No longer protect quotations marks here, this goes wrong. * org-agenda.el (org-agenda-remove-marked-text): Bind variable BEG. * org-compat.el (org-fit-window-to-buffer): New function (not really, a preliminary and incomplete version was present earlier, but not used). * org.el (org-fast-todo-selection, org-fast-tag-selection): Use `org-fit-window-to-buffer'. * org-exp.el (org-export): Use `org-fit-window-to-buffer'. * org-agenda.el (org-agenda-get-restriction-and-command) (org-fit-agenda-window, org-agenda-convert-date): Use `org-fit-window-to-buffer'. * org-exp.el (org-export-as-html): Process href links through `org-export-html-format-href'. (org-export-html-format-href): New function. * org-agenda.el (org-agenda-todo): Update only the current headline if this is a repeated TODO, marked done for today. (org-agenda-change-all-lines): New argument JUST-THIS, to change only the current line. * org.el (org-todo): Take a snapshot of the headline if the repeater might change it. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org-publish.el (org-publish-find-title): Remove buffers visited only for extracting the title. * org-exp.el (org-export-html-style) (org-export-html-style-default): Mark style definitions as unparsed CDATA. * org-publish.el (org-publish-validate-link): Function re-introduced. 2008-11-12 Charles Sebold <csebold@gmail.com> * org-plot.el (org-plot/add-options-to-plist): Supports timefmt property. (org-plot-quote-timestamp-field): New function. (org-plot-quote-tsv-field): Call timestamp field function when necessary rather than just quoting as a string. (org-plot/gnuplot-to-data): Pass in timefmt property. (org-plot/gnuplot-script): Supports timefmt property. (org-plot/gnuplot): Checks for timestamp column before checking for text index column. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-insert-heading): Improve behavior with hidden subtrees. * org-publish.el (org-publish-org-index): Create a section in the index file. (org-publish-org-index): Stop linking to directories. * org.el (org-emphasis-alist): Use span instead of <u> to underline text. * org-exp.el (org-export-as-html): Make sure <p> is closed before <pre> sections. 2008-11-12 Sebastian Rose <sebastian_rose@gmx.de> * org-jsinfo.el (org-infojs-template): Remove language attribute from script tag. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-remove-marked-text): New function. (org-agenda-mark-filtered-text) (org-agenda-unmark-filtered-text): New functions. (org-write-agenda): Remove fltered text. * org.el (org-make-tags-matcher): Give access to TODO "property" without speed penalty. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-link-frame-setup): Add `org-gnus-no-new-news' as an option. (org-store-link-props): Make sure adding to the plist works correctly. * org-gnus.el (org-gnus-no-new-news): New function. (org-gnus-follow-link): Allow the article ID to be a message-id, in addition to allowing article numbers. Message IDs make much more roubust links. (org-gnus-store-link): Use message-id to create link. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-emphasize): Reverse the selection array. (org-emphasis-alist): Set <code> tags for the verbatim environment. * org-remember.el (org-remember-handler): Fix bug with prefix-related changing of the note storage target. * org-exp.el (org-print-icalendar-entries): Make the exported priorities compatible with RFC 2445. * org-clock.el (org-clock-save): Insert time stamp without dependence on time-stamp.el. 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org.el ("saveplace"): If saveplace puts point into an invisible location, make it visible. (org-make-tags-matcher): Allow inactive time stamps in time comparisons. (org-yank-adjusted-subtrees): New option. (org-yank): Incorporate adjusting trees. (org-paste-subtree): New argument FOR-YANK which will cause insertion at point without backing up over white lines, and leave point at the end of the inserted text. Also if the cursor is at the beginning of a headline, use the same level or the inserted tree. * org-publish.el (org-publish-get-base-files-1): Deal correctly with broken symlinks 2008-11-12 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-select-tags, org-get-current-options): Fix typo.
author Carsten Dominik <dominik@science.uva.nl>
date Wed, 12 Nov 2008 08:01:06 +0000
parents ff3f463a949c
children 4f4cd5ec5030
line wrap: on
line diff
--- a/lisp/org/org-agenda.el	Wed Nov 12 07:58:27 2008 +0000
+++ b/lisp/org/org-agenda.el	Wed Nov 12 08:01:06 2008 +0000
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; 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 @@
 
 (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 @@
 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 @@
   :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 @@
 				 "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 @@
   (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 "<style>" org-agenda-export-html-style))
-	     ;; replace <style> section with org-agenda-export-html-style
-	     (goto-char (point-min))
-	     (kill-region (- (search-forward "<style") 6)
-			  (search-forward "</style>"))
-	     (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 "<style>" org-agenda-export-html-style))
+		 ;; replace <style> section with org-agenda-export-html-style
+		 (goto-char (point-min))
+		 (kill-region (- (search-forward "<style") 6)
+			      (search-forward "</style>"))
+		 (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 @@
   "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 @@
       (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 @@
 		  (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 @@
 	  (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 @@
 		      '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 @@
 		     (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 @@
 	(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 @@
 	  ;; 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 @@
 		      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 @@
 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 @@
 	      (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 @@
   (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 @@
 		(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 @@
 	 (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 @@
 	(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 @@
 	     (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 @@
 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 @@
       (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 @@
 	     "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