[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] planner - cyclic tasks - diary and schedule
From: |
Sergey Vlasov |
Subject: |
Re: [emacs-wiki-discuss] planner - cyclic tasks - diary and schedule |
Date: |
Thu, 16 Mar 2006 18:46:08 +0300 |
On Mon, Mar 13, 2006 at 03:14:33PM -0000, Phillip Lord wrote:
> Firstly, my diary cylic file tells me about selective display,
> and suggests I remove it with "s" in Calendar. But this actually
> takes me to the diary file, rather than diary.cyclic-tasks.
You may try this piece of code to keep diary files editable:
;; Diary support code in Emacs is ancient and uses obscure features
;; like `selective-display'. Using `fancy-diary-display' in the
;; `diary-display-hook' helps to avoid `selective-display' for the
;; diary file buffer in the usual case of calling the `diary' command
;; interactively. However, some Lisp code calls `list-diary-entries'
;; or `diary' after binding `diary-display-hook' to some other thing,
;; and then forgets to return the buffer to a sane state. One example
;; of such behavior is `appt-check'.
;;
;; This function attempts to fix the damage done by `appt-check'; it
;; should be added to `diary-hook' (which `appt-check' does not
;; touch). It will not fix the problem in all cases (e.g., some code
;; calling `list-diary-entries' might rebind `diary-hook' around it -
;; but in this case it is likely that it does some cleanup itself).
;;
(defun vsu/unscrew-diary-buffer ()
"Undo `selective-display' hackery performed by `list-diary-entries'."
(save-excursion
(set-buffer (find-buffer-visiting (substitute-in-file-name diary-file)))
(when selective-display
(let ((diary-modified (buffer-modified-p)))
(subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
(setq selective-display nil)
(kill-local-variable 'mode-line-format)
(set-buffer-modified-p diary-modified))))
;; Clear the "Preparing diary..." message
(message nil))
(add-hook 'diary-hook 'vsu/unscrew-diary-buffer)
;; `fancy-diary-display' does not just look nicer - it also undoes the
;; modifications which `list-diary-entries' does to the diary file
;; buffer (like setting `selective-display' and changing some
;; end-of-line characters to ^M). It is also required for
;; `planner-diary'.
;;
(add-hook 'diary-display-hook 'fancy-diary-display)
pgpFg6o6jiAh_.pgp
Description: PGP signature