diff options
| author | Stephen Berman | 2012-06-14 17:45:35 +0100 |
|---|---|---|
| committer | Stephen Berman | 2012-06-14 17:45:35 +0100 |
| commit | 144faf476ddad97b7e8b61252e215f47c9c2885d (patch) | |
| tree | b8b2e3d5e9035a6ac07f194e0796197d73b8fe65 | |
| parent | a820dfe8e0d63e9fda849a4250204f525a3f022b (diff) | |
| download | emacs-144faf476ddad97b7e8b61252e215f47c9c2885d.tar.gz emacs-144faf476ddad97b7e8b61252e215f47c9c2885d.zip | |
* calendar/todos.el (todos-done-separator-string): New defcustom.
(todos-done-separator): New variable replacing defcustom of the
same name.
(todos-reset-done-separator-string, todos-done-separator):
New functions.
(todos-mode): Make function added to
window-configuration-change-hook do a better job of updating the
done items separator string overlay.
(todos-unload-hook): Remove it here.
(todos-item-undo): Fix search for item's end.
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 103 |
2 files changed, 92 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bc6cdafee82..e7c9d8cb6ff 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2012-09-23 Stephen Berman <stephen.berman@gmx.net> | 1 | 2012-09-23 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 2 | ||
| 3 | * calendar/todos.el (todos-done-separator-string): New defcustom. | ||
| 4 | (todos-done-separator): New variable replacing defcustom of the | ||
| 5 | same name. | ||
| 6 | (todos-reset-done-separator-string, todos-done-separator): | ||
| 7 | New functions. | ||
| 8 | (todos-mode): Make function added to | ||
| 9 | window-configuration-change-hook do a better job of updating the | ||
| 10 | done items separator string overlay. | ||
| 11 | (todos-unload-hook): Remove it here. | ||
| 12 | (todos-item-undo): Fix search for item's end. | ||
| 13 | |||
| 14 | 2012-09-23 Stephen Berman <stephen.berman@gmx.net> | ||
| 15 | |||
| 3 | * calendar/todos.el: Further comment revision. | 16 | * calendar/todos.el: Further comment revision. |
| 4 | (todos-sorted-column): Change default value. | 17 | (todos-sorted-column): Change default value. |
| 5 | (todos-item-start): Handle empty category (needed in | 18 | (todos-item-start): Handle empty category (needed in |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 19ab6deca74..b1bf68fe4e1 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -161,27 +161,49 @@ These reflect the priorities of the items in each category." | |||
| 161 | ;; Activate the new setting (save-restriction does not help). | 161 | ;; Activate the new setting (save-restriction does not help). |
| 162 | (save-excursion (todos-category-select)))))))) | 162 | (save-excursion (todos-category-select)))))))) |
| 163 | 163 | ||
| 164 | ;; FIXME: Update when window-width changes. Add todos-reset-separator to | 164 | (defcustom todos-done-separator-string "_" |
| 165 | ;; window-configuration-change-hook in todos-mode? But this depends on the | 165 | "String for generating `todos-done-separator'. |
| 166 | ;; value being window-width instead of a constant length. | 166 | |
| 167 | (defcustom todos-done-separator (make-string (window-width) ?_) | 167 | If the string consists of a single character, |
| 168 | "String used to visually separate done from not done items. | 168 | `todos-done-separator' will be the string made by repeating this |
| 169 | Displayed as an overlay instead of `todos-category-done' when | 169 | character for the width of the window, and the length is |
| 170 | done items are shown." | 170 | automatically recalculated when the window width changes. If the |
| 171 | string consists of more (or less) than one character, it will be | ||
| 172 | the value of `todos-done-separator'." | ||
| 171 | :type 'string | 173 | :type 'string |
| 172 | :initialize 'custom-initialize-default | 174 | :initialize 'custom-initialize-default |
| 173 | :set 'todos-reset-separator | 175 | :set 'todos-reset-done-separator-string |
| 174 | :group 'todos) | 176 | :group 'todos) |
| 175 | 177 | ||
| 176 | ;; (defun todos-reset-done-separator (symbol value) | 178 | (defun todos-reset-done-separator-string (symbol value) |
| 177 | ;; "The :set function for `todos-done-separator' | 179 | "The :set function for `todos-done-separator-string'." |
| 178 | ;; Also added to `window-configuration-change-hook' in Todos mode." | 180 | (let ((oldvalue (symbol-value symbol)) |
| 179 | ;; (let ((oldvalue (symbol-value symbol))) | 181 | (files todos-file-buffers) |
| 180 | ;; (custom-set-default symbol value) | 182 | (sep todos-done-separator)) |
| 181 | ;; (when (not (equal value oldvalue)) | 183 | (custom-set-default symbol value) |
| 182 | ;; (make-string (window-width) ?_) | 184 | (setq todos-done-separator (todos-done-separator)) |
| 183 | ;; ;; (save-excursion (todos-category-select)) | 185 | ;; Replace any existing separator string overlays. |
| 184 | ;; ))) | 186 | (when (not (equal value oldvalue)) |
| 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))))))))))) | ||
| 185 | 207 | ||
| 186 | (defcustom todos-done-string "DONE " | 208 | (defcustom todos-done-string "DONE " |
| 187 | "Identifying string appended to the front of done todos items." | 209 | "Identifying string appended to the front of done todos items." |
| @@ -612,6 +634,7 @@ categories display according to priority." | |||
| 612 | (:background "grey85")) | 634 | (:background "grey85")) |
| 613 | (((class color) | 635 | (((class color) |
| 614 | (background dark)) | 636 | (background dark)) |
| 637 | ;; FIXME: make foreground dark, else illegible | ||
| 615 | (:background "grey10")) | 638 | (:background "grey10")) |
| 616 | (t | 639 | (t |
| 617 | (:background "gray"))) | 640 | (:background "gray"))) |
| @@ -1017,6 +1040,19 @@ number as its value." | |||
| 1017 | (defconst todos-category-done "==--== DONE " | 1040 | (defconst todos-category-done "==--== DONE " |
| 1018 | "String marking beginning of category's done items.") | 1041 | "String marking beginning of category's done items.") |
| 1019 | 1042 | ||
| 1043 | (defun todos-done-separator () | ||
| 1044 | "Return string used as value of variable `todos-done-separator'." | ||
| 1045 | (let ((sep todos-done-separator-string)) | ||
| 1046 | (if (= 1 (length sep)) | ||
| 1047 | (make-string (window-width) (string-to-char sep)) | ||
| 1048 | todos-done-separator-string))) | ||
| 1049 | |||
| 1050 | (defvar todos-done-separator (todos-done-separator) | ||
| 1051 | "String used to visually separate done from not done items. | ||
| 1052 | Displayed as an overlay instead of `todos-category-done' when | ||
| 1053 | done items are shown. Its value is determined by user option | ||
| 1054 | `todos-done-separator-string'.") | ||
| 1055 | |||
| 1020 | (defun todos-category-select () | 1056 | (defun todos-category-select () |
| 1021 | "Display the current category correctly." | 1057 | "Display the current category correctly." |
| 1022 | (let ((name (todos-current-category)) | 1058 | (let ((name (todos-current-category)) |
| @@ -1054,6 +1090,7 @@ number as its value." | |||
| 1054 | (let* ((done-sep todos-done-separator) | 1090 | (let* ((done-sep todos-done-separator) |
| 1055 | (ovs (overlays-at done-sep-start)) | 1091 | (ovs (overlays-at done-sep-start)) |
| 1056 | ov-sep) | 1092 | ov-sep) |
| 1093 | ;; There should never be more than one overlay here, so car suffices. | ||
| 1057 | (unless (and ovs (string= (overlay-get (car ovs) 'display) done-sep)) | 1094 | (unless (and ovs (string= (overlay-get (car ovs) 'display) done-sep)) |
| 1058 | (setq ov-sep (make-overlay done-sep-start done-end)) | 1095 | (setq ov-sep (make-overlay done-sep-start done-end)) |
| 1059 | (overlay-put ov-sep 'display done-sep)))) | 1096 | (overlay-put ov-sep 'display done-sep)))) |
| @@ -2522,11 +2559,29 @@ which is the value of the user option | |||
| 2522 | (add-hook 'post-command-hook 'todos-update-buffer-list nil t) | 2559 | (add-hook 'post-command-hook 'todos-update-buffer-list nil t) |
| 2523 | (when todos-show-current-file | 2560 | (when todos-show-current-file |
| 2524 | (add-hook 'pre-command-hook 'todos-show-current-file nil t)) | 2561 | (add-hook 'pre-command-hook 'todos-show-current-file nil t)) |
| 2525 | ;; FIXME: works more or less, but should be tied to the defcustom | ||
| 2526 | (add-hook 'window-configuration-change-hook | 2562 | (add-hook 'window-configuration-change-hook |
| 2563 | ;; FIXME | ||
| 2527 | (lambda () | 2564 | (lambda () |
| 2528 | (setq todos-done-separator (make-string (window-width) ?_))) | 2565 | (let ((sep todos-done-separator)) |
| 2529 | nil t) | 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) | ||
| 2530 | (add-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file nil t)) | 2585 | (add-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file nil t)) |
| 2531 | 2586 | ||
| 2532 | ;; FIXME: need this? | 2587 | ;; FIXME: need this? |
| @@ -2537,9 +2592,8 @@ which is the value of the user option | |||
| 2537 | (remove-hook 'find-file-hook 'todos-display-as-todos-file t) | 2592 | (remove-hook 'find-file-hook 'todos-display-as-todos-file t) |
| 2538 | (remove-hook 'find-file-hook 'todos-add-to-buffer-list t) | 2593 | (remove-hook 'find-file-hook 'todos-add-to-buffer-list t) |
| 2539 | (remove-hook 'window-configuration-change-hook | 2594 | (remove-hook 'window-configuration-change-hook |
| 2540 | (lambda () | 2595 | ;; FIXME |
| 2541 | (setq todos-done-separator | 2596 | (lambda () (setq todos-done-separator (todos-done-separator))) t) |
| 2542 | (make-string (window-width) ?_))) t) | ||
| 2543 | (remove-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file t)) | 2597 | (remove-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file t)) |
| 2544 | 2598 | ||
| 2545 | (put 'todos-archive-mode 'mode-class 'special) | 2599 | (put 'todos-archive-mode 'mode-class 'special) |
| @@ -4695,6 +4749,7 @@ the restored item." | |||
| 4695 | (orig-mrk (progn (todos-item-start) (point-marker))) | 4749 | (orig-mrk (progn (todos-item-start) (point-marker))) |
| 4696 | ;; Find the end of the date string added upon tagging item as done. | 4750 | ;; Find the end of the date string added upon tagging item as done. |
| 4697 | (start (search-forward "] ")) | 4751 | (start (search-forward "] ")) |
| 4752 | (end (save-excursion (todos-item-end))) | ||
| 4698 | item undone) | 4753 | item undone) |
| 4699 | (todos-item-start) | 4754 | (todos-item-start) |
| 4700 | (when (and (re-search-forward (concat " \\[" | 4755 | (when (and (re-search-forward (concat " \\[" |
| @@ -4702,7 +4757,7 @@ the restored item." | |||
| 4702 | ": \\([^]]+\\)\\]") end t) | 4757 | ": \\([^]]+\\)\\]") end t) |
| 4703 | (y-or-n-p "Omit comment from restored item? ")) | 4758 | (y-or-n-p "Omit comment from restored item? ")) |
| 4704 | (delete-region (match-beginning 0) (match-end 0))) | 4759 | (delete-region (match-beginning 0) (match-end 0))) |
| 4705 | (setq item (buffer-substring start (todos-item-end))) | 4760 | (setq item (buffer-substring start end)) |
| 4706 | (todos-remove-item) | 4761 | (todos-remove-item) |
| 4707 | ;; If user cancels before setting new priority, then leave the done item | 4762 | ;; If user cancels before setting new priority, then leave the done item |
| 4708 | ;; unchanged. | 4763 | ;; unchanged. |