aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2012-06-15 00:32:09 +0100
committerStephen Berman2012-06-15 00:32:09 +0100
commitd9be0d35088afba9e6000d8ca1ed861d12e2ecac (patch)
tree6adc272c6de3ffdf49bf8ac0a5877b7f1cd42957
parent144faf476ddad97b7e8b61252e215f47c9c2885d (diff)
downloademacs-d9be0d35088afba9e6000d8ca1ed861d12e2ecac.tar.gz
emacs-d9be0d35088afba9e6000d8ca1ed861d12e2ecac.zip
* calendar/todos.el (todos-reset-done-separator)
(todos-reset-and-enable-done-separator): New functions. (todos-reset-done-separator-string): Rewrite using todos-reset-done-separator for string longer than 1 character. (todos-mode): Add todos-reset-and-enable-done-separator to window-configuration-change-hook, replacing previous anonymous function. (todos-unload-hook): And remove it.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/calendar/todos.el87
2 files changed, 52 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e7c9d8cb6ff..893ad521175 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
12012-09-23 Stephen Berman <stephen.berman@gmx.net> 12012-09-23 Stephen Berman <stephen.berman@gmx.net>
2 2
3 * calendar/todos.el (todos-reset-done-separator)
4 (todos-reset-and-enable-done-separator): New functions.
5 (todos-reset-done-separator-string): Rewrite using
6 todos-reset-done-separator for string longer than 1 character.
7 (todos-mode): Add todos-reset-and-enable-done-separator to
8 window-configuration-change-hook, replacing previous anonymous
9 function.
10 (todos-unload-hook): And remove it.
11
122012-09-23 Stephen Berman <stephen.berman@gmx.net>
13
3 * calendar/todos.el (todos-done-separator-string): New defcustom. 14 * calendar/todos.el (todos-done-separator-string): New defcustom.
4 (todos-done-separator): New variable replacing defcustom of the 15 (todos-done-separator): New variable replacing defcustom of the
5 same name. 16 same name.
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index b1bf68fe4e1..97a433c6ead 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -182,28 +182,8 @@ the value of `todos-done-separator'."
182 (sep todos-done-separator)) 182 (sep todos-done-separator))
183 (custom-set-default symbol value) 183 (custom-set-default symbol value)
184 (setq todos-done-separator (todos-done-separator)) 184 (setq todos-done-separator (todos-done-separator))
185 ;; Replace any existing separator string overlays. 185 (when (= 1 (length value))
186 (when (not (equal value oldvalue)) 186 (todos-reset-done-separator sep))))
187 (dolist (f files)
188 (with-current-buffer (find-buffer-visiting f)
189 (save-excursion
190 (save-restriction
191 (widen)
192 (goto-char (point-min))
193 (while (re-search-forward (concat "\n\\("
194 (regexp-quote todos-category-done)
195 "\\)") nil t)
196 (setq beg (match-beginning 1))
197 (setq end (match-end 0))
198 (let* ((ovs (overlays-at beg))
199 old-sep new-sep)
200 (and ovs
201 (setq old-sep (overlay-get (car ovs) 'display))
202 (string= old-sep sep)
203 (delete-overlay (car ovs))
204 (setq new-sep (make-overlay beg end))
205 (overlay-put new-sep 'display
206 todos-done-separator)))))))))))
207 187
208(defcustom todos-done-string "DONE " 188(defcustom todos-done-string "DONE "
209 "Identifying string appended to the front of done todos items." 189 "Identifying string appended to the front of done todos items."
@@ -1053,6 +1033,43 @@ Displayed as an overlay instead of `todos-category-done' when
1053done items are shown. Its value is determined by user option 1033done items are shown. Its value is determined by user option
1054`todos-done-separator-string'.") 1034`todos-done-separator-string'.")
1055 1035
1036(defun todos-reset-done-separator (sep)
1037 "Replace any existing overlays of separator string SEP."
1038 (save-excursion
1039 (save-restriction
1040 (widen)
1041 (goto-char (point-min))
1042 (while (re-search-forward
1043 (concat "\n\\(" (regexp-quote todos-category-done) "\\)") nil t)
1044 (setq beg (match-beginning 1))
1045 (setq end (match-end 0))
1046 (let* ((ovs (overlays-at beg))
1047 old-sep new-sep)
1048 (and ovs
1049 (setq old-sep (overlay-get (car ovs) 'display))
1050 (string= old-sep sep)
1051 (delete-overlay (car ovs))
1052 (setq new-sep (make-overlay beg end))
1053 (overlay-put new-sep 'display
1054 todos-done-separator)))))))
1055
1056(defun todos-reset-and-enable-done-separator ()
1057 "Hook function for activating new separator overlay.
1058Added to `window-configuration-change-hook' in `todos-mode'."
1059 (when (= 1 (length todos-done-separator-string))
1060 (let ((sep todos-done-separator))
1061 (setq todos-done-separator (todos-done-separator))
1062 (todos-reset-done-separator sep))
1063 ;; If the separator overlay is now shown, we have to hide and then show it
1064 ;; again in order to let the change in length take effect.
1065 (save-excursion
1066 (goto-char (point-min))
1067 (when (re-search-forward todos-done-string-start nil t)
1068 (let ((todos-show-with-done nil))
1069 (todos-category-select))
1070 (let ((todos-show-with-done t))
1071 (todos-category-select))))))
1072
1056(defun todos-category-select () 1073(defun todos-category-select ()
1057 "Display the current category correctly." 1074 "Display the current category correctly."
1058 (let ((name (todos-current-category)) 1075 (let ((name (todos-current-category))
@@ -2560,28 +2577,7 @@ which is the value of the user option
2560 (when todos-show-current-file 2577 (when todos-show-current-file
2561 (add-hook 'pre-command-hook 'todos-show-current-file nil t)) 2578 (add-hook 'pre-command-hook 'todos-show-current-file nil t))
2562 (add-hook 'window-configuration-change-hook 2579 (add-hook 'window-configuration-change-hook
2563 ;; FIXME 2580 'todos-reset-and-enable-done-separator nil t)
2564 (lambda ()
2565 (let ((sep todos-done-separator))
2566 (setq todos-done-separator (todos-done-separator))
2567 (save-excursion
2568 (save-restriction
2569 (widen)
2570 (goto-char (point-min))
2571 (while (re-search-forward
2572 (concat "\n\\(" (regexp-quote todos-category-done)
2573 "\\)") nil t)
2574 (setq beg (match-beginning 1))
2575 (setq end (match-end 0))
2576 (let* ((ovs (overlays-at beg))
2577 old-sep new-sep)
2578 (and ovs
2579 (setq old-sep (overlay-get (car ovs) 'display))
2580 (string= old-sep sep)
2581 (delete-overlay (car ovs))
2582 (setq new-sep (make-overlay beg end))
2583 (overlay-put new-sep 'display
2584 todos-done-separator)))))))) nil t)
2585 (add-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file nil t)) 2581 (add-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file nil t))
2586 2582
2587;; FIXME: need this? 2583;; FIXME: need this?
@@ -2592,8 +2588,7 @@ which is the value of the user option
2592 (remove-hook 'find-file-hook 'todos-display-as-todos-file t) 2588 (remove-hook 'find-file-hook 'todos-display-as-todos-file t)
2593 (remove-hook 'find-file-hook 'todos-add-to-buffer-list t) 2589 (remove-hook 'find-file-hook 'todos-add-to-buffer-list t)
2594 (remove-hook 'window-configuration-change-hook 2590 (remove-hook 'window-configuration-change-hook
2595 ;; FIXME 2591 'todos-reset-and-enable-done-separator t)
2596 (lambda () (setq todos-done-separator (todos-done-separator))) t)
2597 (remove-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file t)) 2592 (remove-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file t))
2598 2593
2599(put 'todos-archive-mode 'mode-class 'special) 2594(put 'todos-archive-mode 'mode-class 'special)