From: Stephen Berman Date: Sat, 11 May 2013 20:50:28 +0000 (+0200) Subject: * todos.el (todos-item-undone): Remove item highlighting when user X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2059 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5bdcc430533161f63d03eff01cf8601cb2dbf730;p=emacs.git * todos.el (todos-item-undone): Remove item highlighting when user quits before deciding whether to omit comment. Fix misplaced closing paren. Change two uses of `if' to `when'. --- diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog index 10b2d750344..fcdcf20151d 100644 --- a/lisp/calendar/ChangeLog +++ b/lisp/calendar/ChangeLog @@ -1,3 +1,9 @@ +2013-05-11 Stephen Berman + + * todos.el (todos-item-undone): Remove item highlighting when user + quits before deciding whether to omit comment. Fix misplaced + closing paren. Change two uses of `if' to `when'. + 2013-05-10 Stephen Berman * todos.el: Rename numerous commands and defcustoms and adjust all diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index e203949c10a..aff12e62158 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el @@ -5770,41 +5770,43 @@ comments without asking." (and marked (goto-char (point-min))) (catch 'done (while (not (eobp)) - (if (or (not marked) (and marked (todos-marked-item-p))) - (if (not (todos-done-item-p)) - (error "Only done items can be undone") - (todos-item-start) - (unless marked - (setq ov (make-overlay (save-excursion (todos-item-start)) - (save-excursion (todos-item-end)))) - (overlay-put ov 'face 'todos-search)) - ;; Find the end of the date string added upon tagging item as - ;; done. - (setq start (search-forward "] ")) - (setq item-count (1+ item-count)) - (unless (looking-at (regexp-quote todos-nondiary-start)) - (setq diary-count (1+ diary-count))) - (setq end (save-excursion (todos-item-end))) - ;; Ask (once) whether to omit done item's comment. If - ;; affirmed, omit subsequent comments without asking. - (when (re-search-forward - (concat " \\[" (regexp-quote todos-comment-string) - ": [^]]+\\]") end t) - (if (eq first 'first) - (setq first - (if (eq todos-undo-item-omit-comment 'ask) - (when (y-or-n-p (concat "Omit comment" pl - " from restored item" - pl "? ")) - 'omit) - (when todos-undo-item-omit-comment 'omit))) - t) - (when (eq first 'omit) - (setq end (match-beginning 0))) - (setq item (concat item - (buffer-substring-no-properties start end) - (when marked "\n"))) - (unless marked (throw 'done nil))))) + (when (or (not marked) (and marked (todos-marked-item-p))) + (if (not (todos-done-item-p)) + (error "Only done items can be undone") + (todos-item-start) + (unless marked + (setq ov (make-overlay (save-excursion (todos-item-start)) + (save-excursion (todos-item-end)))) + (overlay-put ov 'face 'todos-search)) + ;; Find the end of the date string added upon tagging item as + ;; done. + (setq start (search-forward "] ")) + (setq item-count (1+ item-count)) + (unless (looking-at (regexp-quote todos-nondiary-start)) + (setq diary-count (1+ diary-count))) + (setq end (save-excursion (todos-item-end))) + ;; Ask (once) whether to omit done item's comment. If + ;; affirmed, omit subsequent comments without asking. + (when (re-search-forward + (concat " \\[" (regexp-quote todos-comment-string) + ": [^]]+\\]") end t) + (unwind-protect + (if (eq first 'first) + (setq first + (if (eq todos-undo-item-omit-comment 'ask) + (when (y-or-n-p (concat "Omit comment" pl + " from restored item" + pl "? ")) + 'omit) + (when todos-undo-item-omit-comment 'omit))) + t) + (when (and (eq first 'first) ov) (delete-overlay ov))) + (when (eq first 'omit) + (setq end (match-beginning 0)))) + (setq item (concat item + (buffer-substring-no-properties start end) + (when marked "\n"))) + (unless marked (throw 'done nil)))) (todos-forward-item))) (unwind-protect (progn @@ -5814,7 +5816,7 @@ comments without asking." (todos-set-item-priority item cat t) (setq npoint (point)) (setq undone t)) - (if ov (delete-overlay ov)) + (when ov (delete-overlay ov)) (if (not undone) (goto-char opoint) (if marked