all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6999: 23.2; [PATCH] appt ignores included diary files
@ 2010-09-08 12:31 Leo
  2010-09-08 12:45 ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-08 12:31 UTC (permalink / raw)
  To: 6999

When the main diary file includes other diary files. File saving in the
included does no appt-check, which means if one adds appointments
directly into the included file, they will not be added by
appt-update-list.

One simple solution is to make appt-update-list do appt-check if major
mode is diary-mode. Then users can open included files in diary mode and
add appointments.

diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 3573c95..818fee4 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -660,7 +660,8 @@ hour and minute parts."
 (defun appt-update-list ()
   "If the current buffer is visiting the diary, update appointments.
 This function is intended for use with `write-file-functions'."
-  (and (string-equal buffer-file-name (expand-file-name diary-file))
+  (and (or (string-equal buffer-file-name (expand-file-name diary-file))
+           (eq major-mode 'diary-mode))
        appt-timer
        (let ((appt-display-diary nil))
          (appt-check t)))





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-08 12:31 bug#6999: 23.2; [PATCH] appt ignores included diary files Leo
@ 2010-09-08 12:45 ` Leo
  2010-09-08 14:38   ` Stefan Monnier
  2010-09-14  0:24   ` Glenn Morris
  0 siblings, 2 replies; 10+ messages in thread
From: Leo @ 2010-09-08 12:45 UTC (permalink / raw)
  To: 6999

On 2010-09-08 13:31 +0100, Leo wrote:
> When the main diary file includes other diary files. File saving in the
> included does no appt-check, which means if one adds appointments
> directly into the included file, they will not be added by
> appt-update-list.
>
> One simple solution is to make appt-update-list do appt-check if major
> mode is diary-mode. Then users can open included files in diary mode and
> add appointments.
[...]

Annoyingly appt-check pops up the main diary buffer. So maybe do this
instead:

diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 3573c95..32563ab 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -660,10 +660,11 @@ hour and minute parts."
 (defun appt-update-list ()
   "If the current buffer is visiting the diary, update appointments.
 This function is intended for use with `write-file-functions'."
-  (and (string-equal buffer-file-name (expand-file-name diary-file))
+  (and (or (string-equal buffer-file-name (expand-file-name diary-file))
+           (eq major-mode 'diary-mode))
        appt-timer
        (let ((appt-display-diary nil))
-         (appt-check t)))
+         (save-window-excursion (appt-check t))))
   nil)
 
 ;; In Emacs-21.3, the manual documented the following procedure to






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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-08 12:45 ` Leo
@ 2010-09-08 14:38   ` Stefan Monnier
  2010-09-08 15:07     ` Leo
  2010-09-14  0:24   ` Glenn Morris
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2010-09-08 14:38 UTC (permalink / raw)
  To: Leo; +Cc: 6999

> Annoyingly appt-check pops up the main diary buffer. So maybe do this
> instead:
[...]
> -         (appt-check t)))
> +         (save-window-excursion (appt-check t))))

Not good enough: the buffer might have popped up in a new frame, in
which case save-window-excursion won't be of any help.

Basically, you can't undo a "pop up a buffer", so the code should be
written in such a way that it's only done when it's *really* necessary.


        Stefan





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-08 14:38   ` Stefan Monnier
@ 2010-09-08 15:07     ` Leo
  0 siblings, 0 replies; 10+ messages in thread
From: Leo @ 2010-09-08 15:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6999

On 2010-09-08 15:38 +0100, Stefan Monnier wrote:
> Not good enough: the buffer might have popped up in a new frame, in
> which case save-window-excursion won't be of any help.
>
> Basically, you can't undo a "pop up a buffer", so the code should be
> written in such a way that it's only done when it's *really* necessary.

This form (or selective (diary-show-all-entries)) in `appt-check'
displays diary buffer. I don't know how best to fix it.

Leo





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-08 12:45 ` Leo
  2010-09-08 14:38   ` Stefan Monnier
@ 2010-09-14  0:24   ` Glenn Morris
  2010-09-14  6:19     ` Leo
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-09-14  0:24 UTC (permalink / raw)
  To: Leo; +Cc: 6999

Leo wrote:

> -  (and (string-equal buffer-file-name (expand-file-name diary-file))
> +  (and (or (string-equal buffer-file-name (expand-file-name diary-file))
> +           (eq major-mode 'diary-mode))

There's no particular reason that the included diary files should be
being visited in diary-mode. I'll try to find a different fix (I'm
thinking maybe running diary-list-entries should store a list of any
include files that were found).





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-14  0:24   ` Glenn Morris
@ 2010-09-14  6:19     ` Leo
  2010-09-14  7:20       ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-14  6:19 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 6999

On 2010-09-14 01:24 +0100, Glenn Morris wrote:
> Leo wrote:
>
>> -  (and (string-equal buffer-file-name (expand-file-name diary-file))
>> +  (and (or (string-equal buffer-file-name (expand-file-name diary-file))
>> +           (eq major-mode 'diary-mode))
>
> There's no particular reason that the included diary files should be
> being visited in diary-mode. I'll try to find a different fix (I'm
> thinking maybe running diary-list-entries should store a list of any
> include files that were found).

But the point of that is to decide whether to call appt-check (hence
diary-list-entries, which is expensive). Looks like somehow diary-lib
needs a function to return all included files without doing list
entries. Thanks for looking into this.

Leo





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-14  6:19     ` Leo
@ 2010-09-14  7:20       ` Glenn Morris
  2010-09-14  7:38         ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-09-14  7:20 UTC (permalink / raw)
  To: Leo; +Cc: 6999


emacs-23 branch:

2010-09-14  Glenn Morris  <rgm at gnu.org>

    * calendar/diary-lib.el (diary-included-files): New variable.
    (diary-list-entries): Maybe initialize diary-included-files.
    (diary-include-other-diary-files): Append to diary-included-files.
    * calendar/appt.el (appt-update-list): Also check the
    members of diary-included-files.






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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-14  7:20       ` Glenn Morris
@ 2010-09-14  7:38         ` Leo
  2010-09-14  8:06           ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2010-09-14  7:38 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 6999

On 2010-09-14 08:20 +0100, Glenn Morris wrote:
> emacs-23 branch:
>
> 2010-09-14  Glenn Morris  <rgm at gnu.org>
>
>     * calendar/diary-lib.el (diary-included-files): New variable.
>     (diary-list-entries): Maybe initialize diary-included-files.
>     (diary-include-other-diary-files): Append to diary-included-files.
>     * calendar/appt.el (appt-update-list): Also check the
>     members of diary-included-files.
>

Thanks. I like your solution.

The only remaining issue is the main diary file buffer pops up when
saving in included files.

Leo





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-14  7:38         ` Leo
@ 2010-09-14  8:06           ` Glenn Morris
  2010-09-15  2:49             ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-09-14  8:06 UTC (permalink / raw)
  To: Leo; +Cc: 6999

Leo wrote:

> The only remaining issue is the main diary file buffer pops up when
> saving in included files.

I know; see the FIXME comment in appt-check.
It is only displayed if it was being visited beforehand.
It is because (diary) turns on "selective" display and we need to turn
it off again. This whole thing is a mess.





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

* bug#6999: 23.2; [PATCH] appt ignores included diary files
  2010-09-14  8:06           ` Glenn Morris
@ 2010-09-15  2:49             ` Glenn Morris
  0 siblings, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2010-09-15  2:49 UTC (permalink / raw)
  To: 6999-done


Fixed in emacs-23.





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

end of thread, other threads:[~2010-09-15  2:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08 12:31 bug#6999: 23.2; [PATCH] appt ignores included diary files Leo
2010-09-08 12:45 ` Leo
2010-09-08 14:38   ` Stefan Monnier
2010-09-08 15:07     ` Leo
2010-09-14  0:24   ` Glenn Morris
2010-09-14  6:19     ` Leo
2010-09-14  7:20       ` Glenn Morris
2010-09-14  7:38         ` Leo
2010-09-14  8:06           ` Glenn Morris
2010-09-15  2:49             ` Glenn Morris

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.