diff options
| author | Stephen Berman | 2013-05-16 12:02:26 +0200 |
|---|---|---|
| committer | Stephen Berman | 2013-05-16 12:02:26 +0200 |
| commit | 46fa56ece0f7082de6da8a0a289ad18ae8d1d10a (patch) | |
| tree | 02c734bed817cca5debd434161ef23a708501e5f | |
| parent | 860ae8b019cecd0e07f8d78bd89e428fee988e79 (diff) | |
| download | emacs-46fa56ece0f7082de6da8a0a289ad18ae8d1d10a.tar.gz emacs-46fa56ece0f7082de6da8a0a289ad18ae8d1d10a.zip | |
* todos.el: Improve toggling of item numbering and headers.
(todos-prefix-overlays): Don't reset item numbering for
done items unless in todos-mode.
(todos-archive-mode-map): Add bindings for todos-toggle-item-header.
(todos-toggle-prefix-numbers): Reimplement without using
todos-reset-prefix and make it work in Todos Archive mode and
Todos Filtered Items mode.
(todos-toggle-item-header): Make it work in Todos Archive mode and
Todos Filtered Items mode.
| -rw-r--r-- | lisp/calendar/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 38 |
2 files changed, 38 insertions, 12 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog index c6d8be377aa..83bbb421e0f 100644 --- a/lisp/calendar/ChangeLog +++ b/lisp/calendar/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2013-05-16 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * todos.el: Improve toggling of item numbering and headers. | ||
| 4 | (todos-prefix-overlays): Don't reset item numbering for | ||
| 5 | done items unless in todos-mode. | ||
| 6 | (todos-archive-mode-map): Add bindings for todos-toggle-item-header. | ||
| 7 | (todos-toggle-prefix-numbers): Reimplement without using | ||
| 8 | todos-reset-prefix and make it work in Todos Archive mode and | ||
| 9 | Todos Filtered Items mode. | ||
| 10 | (todos-toggle-item-header): Make it work in Todos Archive mode and | ||
| 11 | Todos Filtered Items mode. | ||
| 12 | |||
| 1 | 2013-05-15 Stephen Berman <stephen.berman@gmx.net> | 13 | 2013-05-15 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 14 | ||
| 3 | * todos.el: Use tab instead of spaces to indent. | 15 | * todos.el: Use tab instead of spaces to indent. |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index aa1e9db47a5..508ae61b111 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -1607,7 +1607,8 @@ of each other." | |||
| 1607 | (goto-char (match-beginning 0)) | 1607 | (goto-char (match-beginning 0)) |
| 1608 | (setq num (1+ num)) | 1608 | (setq num (1+ num)) |
| 1609 | ;; Reset number to 1 for first done item. | 1609 | ;; Reset number to 1 for first done item. |
| 1610 | (when (and (looking-at todos-done-string-start) | 1610 | (when (and (eq major-mode 'todos-mode) |
| 1611 | (looking-at todos-done-string-start) | ||
| 1611 | (looking-back (concat "^" | 1612 | (looking-back (concat "^" |
| 1612 | (regexp-quote todos-category-done) | 1613 | (regexp-quote todos-category-done) |
| 1613 | "\n"))) | 1614 | "\n"))) |
| @@ -1620,8 +1621,9 @@ of each other." | |||
| 1620 | 'face | 1621 | 'face |
| 1621 | ;; Prefix of top priority items has a | 1622 | ;; Prefix of top priority items has a |
| 1622 | ;; distinct face in Todos mode. | 1623 | ;; distinct face in Todos mode. |
| 1623 | (if (and (not done) (<= num cat-tp) | 1624 | (if (and (eq major-mode 'todos-mode) |
| 1624 | (eq major-mode 'todos-mode)) | 1625 | (not done) |
| 1626 | (<= num cat-tp)) | ||
| 1625 | 'todos-top-priority | 1627 | 'todos-top-priority |
| 1626 | 'todos-prefix-string)) | 1628 | 'todos-prefix-string)) |
| 1627 | " ")) | 1629 | " ")) |
| @@ -2919,7 +2921,8 @@ which is the value of the user option | |||
| 2919 | (define-key map "H" 'todos-toggle-item-highlighting) | 2921 | (define-key map "H" 'todos-toggle-item-highlighting) |
| 2920 | (define-key map "FN" 'todos-toggle-prefix-numbers) | 2922 | (define-key map "FN" 'todos-toggle-prefix-numbers) |
| 2921 | (define-key map "N" 'todos-toggle-prefix-numbers) | 2923 | (define-key map "N" 'todos-toggle-prefix-numbers) |
| 2922 | ;; (define-key map "" 'todos-toggle-item-header) | 2924 | (define-key map "Fh" 'todos-toggle-item-header) |
| 2925 | (define-key map "h" 'todos-toggle-item-header) | ||
| 2923 | (define-key map "PB" 'todos-print-buffer) | 2926 | (define-key map "PB" 'todos-print-buffer) |
| 2924 | (define-key map "PF" 'todos-print-buffer-to-file) | 2927 | (define-key map "PF" 'todos-print-buffer-to-file) |
| 2925 | (define-key map "S" 'todos-search) | 2928 | (define-key map "S" 'todos-search) |
| @@ -3868,9 +3871,19 @@ face." | |||
| 3868 | ;;; Display Commands | 3871 | ;;; Display Commands |
| 3869 | 3872 | ||
| 3870 | (defun todos-toggle-prefix-numbers () | 3873 | (defun todos-toggle-prefix-numbers () |
| 3871 | "" | 3874 | "Hide item numbering if shown, show if hidden." |
| 3872 | (interactive) | 3875 | (interactive) |
| 3873 | (todos-reset-prefix 'todos-number-prefix (not todos-number-prefix))) | 3876 | (save-excursion |
| 3877 | (save-restriction | ||
| 3878 | (goto-char (point-min)) | ||
| 3879 | (let* ((ov (todos-get-overlay 'prefix)) | ||
| 3880 | (show-done (re-search-forward todos-done-string-start nil t)) | ||
| 3881 | (todos-show-with-done show-done) | ||
| 3882 | (todos-number-prefix (not (equal (overlay-get ov 'before-string) | ||
| 3883 | "1 ")))) | ||
| 3884 | (if (eq major-mode 'todos-filtered-items-mode) | ||
| 3885 | (todos-prefix-overlays) | ||
| 3886 | (todos-category-select)))))) | ||
| 3874 | 3887 | ||
| 3875 | (defun todos-toggle-view-done-items () | 3888 | (defun todos-toggle-view-done-items () |
| 3876 | "Show hidden or hide visible done items in current category." | 3889 | "Show hidden or hide visible done items in current category." |
| @@ -3908,7 +3921,9 @@ face." | |||
| 3908 | (hl-line-mode 1))) | 3921 | (hl-line-mode 1))) |
| 3909 | 3922 | ||
| 3910 | (defun todos-toggle-item-header () | 3923 | (defun todos-toggle-item-header () |
| 3911 | "Hide or show date-time header of todo items in the current file." | 3924 | "Hide or show item date-time headers in the current file. |
| 3925 | With done items, this hides only the done date-time string, not | ||
| 3926 | the the original date-time string." | ||
| 3912 | (interactive) | 3927 | (interactive) |
| 3913 | (save-excursion | 3928 | (save-excursion |
| 3914 | (save-restriction | 3929 | (save-restriction |
| @@ -3919,14 +3934,13 @@ face." | |||
| 3919 | (goto-char (point-min)) | 3934 | (goto-char (point-min)) |
| 3920 | (while (not (eobp)) | 3935 | (while (not (eobp)) |
| 3921 | (when (re-search-forward | 3936 | (when (re-search-forward |
| 3922 | (concat todos-date-string-start todos-date-pattern | 3937 | (concat todos-item-start |
| 3923 | "\\( " diary-time-regexp "\\)?" | 3938 | "\\( " diary-time-regexp "\\)?" |
| 3924 | (regexp-quote todos-nondiary-end) "? ") | 3939 | (regexp-quote todos-nondiary-end) "? ") |
| 3925 | nil t) | 3940 | nil t) |
| 3926 | (unless (save-match-data (todos-done-item-p)) | 3941 | (setq ov (make-overlay (match-beginning 0) (match-end 0) nil t)) |
| 3927 | (setq ov (make-overlay (match-beginning 0) (match-end 0) nil t)) | 3942 | (overlay-put ov 'todos 'header) |
| 3928 | (overlay-put ov 'todos 'header) | 3943 | (overlay-put ov 'display "")) |
| 3929 | (overlay-put ov 'display ""))) | ||
| 3930 | (todos-forward-item)))))) | 3944 | (todos-forward-item)))))) |
| 3931 | 3945 | ||
| 3932 | (defun todos-toggle-mark-item (&optional n) | 3946 | (defun todos-toggle-mark-item (&optional n) |