mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-25 06:17:34 +00:00
* 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.
This commit is contained in:
parent
144faf476d
commit
d9be0d3508
2 changed files with 52 additions and 46 deletions
|
|
@ -1,3 +1,14 @@
|
|||
2012-09-23 Stephen Berman <stephen.berman@gmx.net>
|
||||
|
||||
* 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.
|
||||
|
||||
2012-09-23 Stephen Berman <stephen.berman@gmx.net>
|
||||
|
||||
* calendar/todos.el (todos-done-separator-string): New defcustom.
|
||||
|
|
|
|||
|
|
@ -182,28 +182,8 @@ the value of `todos-done-separator'."
|
|||
(sep todos-done-separator))
|
||||
(custom-set-default symbol value)
|
||||
(setq todos-done-separator (todos-done-separator))
|
||||
;; Replace any existing separator string overlays.
|
||||
(when (not (equal value oldvalue))
|
||||
(dolist (f files)
|
||||
(with-current-buffer (find-buffer-visiting f)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward (concat "\n\\("
|
||||
(regexp-quote todos-category-done)
|
||||
"\\)") nil t)
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 0))
|
||||
(let* ((ovs (overlays-at beg))
|
||||
old-sep new-sep)
|
||||
(and ovs
|
||||
(setq old-sep (overlay-get (car ovs) 'display))
|
||||
(string= old-sep sep)
|
||||
(delete-overlay (car ovs))
|
||||
(setq new-sep (make-overlay beg end))
|
||||
(overlay-put new-sep 'display
|
||||
todos-done-separator)))))))))))
|
||||
(when (= 1 (length value))
|
||||
(todos-reset-done-separator sep))))
|
||||
|
||||
(defcustom todos-done-string "DONE "
|
||||
"Identifying string appended to the front of done todos items."
|
||||
|
|
@ -1053,6 +1033,43 @@ Displayed as an overlay instead of `todos-category-done' when
|
|||
done items are shown. Its value is determined by user option
|
||||
`todos-done-separator-string'.")
|
||||
|
||||
(defun todos-reset-done-separator (sep)
|
||||
"Replace any existing overlays of separator string SEP."
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(concat "\n\\(" (regexp-quote todos-category-done) "\\)") nil t)
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 0))
|
||||
(let* ((ovs (overlays-at beg))
|
||||
old-sep new-sep)
|
||||
(and ovs
|
||||
(setq old-sep (overlay-get (car ovs) 'display))
|
||||
(string= old-sep sep)
|
||||
(delete-overlay (car ovs))
|
||||
(setq new-sep (make-overlay beg end))
|
||||
(overlay-put new-sep 'display
|
||||
todos-done-separator)))))))
|
||||
|
||||
(defun todos-reset-and-enable-done-separator ()
|
||||
"Hook function for activating new separator overlay.
|
||||
Added to `window-configuration-change-hook' in `todos-mode'."
|
||||
(when (= 1 (length todos-done-separator-string))
|
||||
(let ((sep todos-done-separator))
|
||||
(setq todos-done-separator (todos-done-separator))
|
||||
(todos-reset-done-separator sep))
|
||||
;; If the separator overlay is now shown, we have to hide and then show it
|
||||
;; again in order to let the change in length take effect.
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward todos-done-string-start nil t)
|
||||
(let ((todos-show-with-done nil))
|
||||
(todos-category-select))
|
||||
(let ((todos-show-with-done t))
|
||||
(todos-category-select))))))
|
||||
|
||||
(defun todos-category-select ()
|
||||
"Display the current category correctly."
|
||||
(let ((name (todos-current-category))
|
||||
|
|
@ -2560,28 +2577,7 @@ which is the value of the user option
|
|||
(when todos-show-current-file
|
||||
(add-hook 'pre-command-hook 'todos-show-current-file nil t))
|
||||
(add-hook 'window-configuration-change-hook
|
||||
;; FIXME
|
||||
(lambda ()
|
||||
(let ((sep todos-done-separator))
|
||||
(setq todos-done-separator (todos-done-separator))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward
|
||||
(concat "\n\\(" (regexp-quote todos-category-done)
|
||||
"\\)") nil t)
|
||||
(setq beg (match-beginning 1))
|
||||
(setq end (match-end 0))
|
||||
(let* ((ovs (overlays-at beg))
|
||||
old-sep new-sep)
|
||||
(and ovs
|
||||
(setq old-sep (overlay-get (car ovs) 'display))
|
||||
(string= old-sep sep)
|
||||
(delete-overlay (car ovs))
|
||||
(setq new-sep (make-overlay beg end))
|
||||
(overlay-put new-sep 'display
|
||||
todos-done-separator)))))))) nil t)
|
||||
'todos-reset-and-enable-done-separator nil t)
|
||||
(add-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file nil t))
|
||||
|
||||
;; FIXME: need this?
|
||||
|
|
@ -2592,8 +2588,7 @@ which is the value of the user option
|
|||
(remove-hook 'find-file-hook 'todos-display-as-todos-file t)
|
||||
(remove-hook 'find-file-hook 'todos-add-to-buffer-list t)
|
||||
(remove-hook 'window-configuration-change-hook
|
||||
;; FIXME
|
||||
(lambda () (setq todos-done-separator (todos-done-separator))) t)
|
||||
'todos-reset-and-enable-done-separator t)
|
||||
(remove-hook 'kill-buffer-hook 'todos-reset-global-current-todos-file t))
|
||||
|
||||
(put 'todos-archive-mode 'mode-class 'special)
|
||||
|
|
|
|||
Loading…
Reference in a new issue