all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* reload ~/diary for Calendar
@ 2011-01-10 18:21 Haines Brown
  2011-01-10 21:18 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Haines Brown @ 2011-01-10 18:21 UTC (permalink / raw)
  To: help-gnu-emacs

I frequently edit ~/diary to add new appointments, but the Calendar
mode does not show the revisions. Restarting Calendar with F5 does not
load the newest diary file. I have to delete the buffer "dairy" manually
and restart Calendar.

There must be a better way. How can I restart the Calendar and have it
show changes in ~/dairy? Perhaps the F5 command could be tied in with a
command to delete the diary buffer.

Haines Brown



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reload ~/diary for Calendar
  2011-01-10 18:21 reload ~/diary for Calendar Haines Brown
@ 2011-01-10 21:18 ` Stefan Monnier
  2011-01-10 21:35   ` Haines Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2011-01-10 21:18 UTC (permalink / raw)
  To: help-gnu-emacs

> I frequently edit ~/diary to add new appointments, but the Calendar
> mode does not show the revisions.

What do you mean by "doesn't show the revisions"?

> Restarting Calendar with F5 does not
> load the newest diary file. I have to delete the buffer "dairy" manually
> and restart Calendar.

Normally saving the diary file should be sufficient.


        Stefan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reload ~/diary for Calendar
  2011-01-10 21:18 ` Stefan Monnier
@ 2011-01-10 21:35   ` Haines Brown
  2011-01-10 22:11     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Haines Brown @ 2011-01-10 21:35 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan,

Thanks for responding. Sorry I wasn't clearer.

I open ~/diary, say with nano, enter an appointment. Save and
close. Then I do F5, and the calandar shows up. 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.

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.

Haines Brown   


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reload ~/diary for Calendar
  2011-01-10 21:35   ` Haines Brown
@ 2011-01-10 22:11     ` Stefan Monnier
  2011-01-25 13:45       ` Haines Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2011-01-10 22:11 UTC (permalink / raw)
  To: help-gnu-emacs

> 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)))
 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reload ~/diary for Calendar
  2011-01-10 22:11     ` Stefan Monnier
@ 2011-01-25 13:45       ` Haines Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Haines Brown @ 2011-01-25 13:45 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan, just wanted to thank you for the sage advice. By using emacs
instead of working outside it, things are going smoothly.

Haines


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-25 13:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 18:21 reload ~/diary for Calendar Haines Brown
2011-01-10 21:18 ` Stefan Monnier
2011-01-10 21:35   ` Haines Brown
2011-01-10 22:11     ` Stefan Monnier
2011-01-25 13:45       ` Haines Brown

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.