help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reload ~/diary for Calendar


From: Stefan Monnier
Subject: Re: reload ~/diary for Calendar
Date: Mon, 10 Jan 2011 17:11:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> I open ~/diary, say with nano, enter an appointment.

There's your problem: why with nano rather than with the Emacs you have
running already?
This is not to say Calendar isn't doing it wrong, just that it's
currently not prepared to react to changes made from a separate process.

> Save and close. Then I do F5, and the calandar shows up.

[BTW: F5 is not bound to anything by default, it is probably a local
customization of yours]

> By default, appointments are not highlisted in red, so I do "m" to
> show them. The test date I just entered does not show up in red. To
> get that, I have to go to emacs buffers, kill the diary buffer, and
> then restart Calendar (F5). The test data how is highlighted in red.

Rather than kill the diary buffer, you can also revert it (i.e. M-x
revert-buffer).  And then you need to use `m' in *Calendar* to refresh
its display accordingly.

> Admittedly, if I insert an appointment the proper way (i d), there is no
> problem. Apparently the answer to my question is to do things the right
> way. I got into the habit of editing ~/diary because dates are in
> chronological order.

Editing ~/diary is fine, as long as you do it within Emacs (and with in
the same Emacs process as the one showing *Calendar*).  But Calendar
should be improved to react properly to external modifications (these
can also happen when you things like synchronize a diary file across
machines).

You can avoid having to do the `m' after the revert with the untested
patch below, which also causes the `m' to detect when the file has
changed and prompt if you want to revert it.

And you can avoid having to do an explicit M-x revert-buffer if you use
something like the following in your .emacs:

   (add-hook 'diary-mode-hook 'auto-revert-mode)


-- Stefan

=== modified file 'lisp/calendar/diary-lib.el'
--- lisp/calendar/diary-lib.el  2010-12-17 12:58:05 +0000
+++ lisp/calendar/diary-lib.el  2011-01-10 22:09:27 +0000
@@ -1335,7 +1335,7 @@
     (calendar-redraw))
   (let ((diary-marking-entries-flag t)
         file-glob-attrs)
-    (with-current-buffer (find-file-noselect (diary-check-diary-file) t)
+    (with-current-buffer (find-file-noselect (diary-check-diary-file))
       (save-excursion
         (when (eq major-mode (default-value 'major-mode)) (diary-mode))
         (setq calendar-mark-diary-entries-flag t)
@@ -2346,6 +2346,7 @@
        '(diary-font-lock-keywords t))
   (add-to-invisibility-spec '(diary . nil))
   (add-hook 'after-save-hook 'diary-redraw-calendar nil t)
+  (add-hook 'after-revert-hook 'diary-redraw-calendar nil t)
   (if diary-header-line-flag
       (setq header-line-format diary-header-line-format)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]