all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33423: 27.0.50; Marking diary entries from included files
@ 2018-11-18 22:57 Stephen Berman
       [not found] ` <handler.33423.B.154258188322703.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Berman @ 2018-11-18 22:57 UTC (permalink / raw)
  To: 33423

0. Save the following files (this can all be done from emacs -Q but this
is easier and doesn't affect the bug):
~/.emacs with this content:
----------------------------------------------------------------
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(calendar-mark-diary-entries-flag t)
 '(diary-mark-entries-hook '(diary-mark-included-diary-files))
)
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
----------------------------------------------------------------
~/.emacs.d/diary with this content:
----------------------------------------------------------------
#include "~/.emacs.d/todo/test.todo"
Nov 16, 2018 test
----------------------------------------------------------------
~/.emacs.d/todo/test.todo with this content:
----------------------------------------------------------------
(("cat1" . [1 0 0 0]) ("cat2" . [1 1 0 0]))
--==-- cat1
[Nov 18, 2018] Not a diary item

==--== DONE 
--==-- cat2
* *, * Diary item

==--== DONE 
----------------------------------------------------------------

1. Start emacs without -Q

2. M-x calendar
=> The Calendar is displayed with all dates marked red as diary entries
(using the default diary face), as it should be, since the file
~/.emacs.d/todo/test.todo is included as a diary file and in the todo item
"* *, * Diary item" "* *, *" means this is diary item for every day.

3. M-x todo-show
=> The window the Calendar was displayed in now shows a Todo mode buffer
displaying cat1 of the above file:
[Nov 18, 2018] Not a diary item

4. M-x calendar
=> The same window now displays the Calendar again, but now only November
16, 2018 (the date of the item in ~/.emacs.d/diary) is marked as a diary
entry, instead of every date.

The reason is that diary-mark-entries does not take narrowing of
included files into account (todo-mode files are narrowed to the current
category: if after step 3 above you type `f' in the todo-mode buffer, it
then displays the next category, and now doing step 4 does show the
Calendar with all dates marked as diary items).

The following patch fixes this.  (Only nine years after bug#5093; better
late than never.  But I guess too late for 26.2?)

diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index acf4b20d77..1fa1aaacd3 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -1412,13 +1412,15 @@ diary-mark-entries
           (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
           (with-syntax-table diary-syntax-table
             (save-excursion
-              (diary-mark-entries-1 'calendar-mark-date-pattern)
-              (diary-mark-sexp-entries)
-              ;; Although it looks like mark-entries-hook runs every time,
-              ;; diary-mark-included-diary-files binds it to nil
-              ;; (essentially) when it runs in included files.
-              (run-hooks 'diary-nongregorian-marking-hook
-                         'diary-mark-entries-hook))))
+              (save-restriction
+                (widen)
+                (diary-mark-entries-1 'calendar-mark-date-pattern)
+                (diary-mark-sexp-entries)
+                ;; Although it looks like mark-entries-hook runs every time,
+                ;; diary-mark-included-diary-files binds it to nil
+                ;; (essentially) when it runs in included files.
+                (run-hooks 'diary-nongregorian-marking-hook
+                           'diary-mark-entries-hook)))))
       (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff)))
     (or d-incp (message "Marking diary entries...done"))))


In GNU Emacs 27.0.50 (build 13, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-11-18 built on rosalinde
Repository revision: 5d140800398287c20230dda79162a7c40016d88e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12001000
System Description: 8.3





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

* bug#33423: Acknowledgement (27.0.50; Marking diary entries from included files)
       [not found] ` <handler.33423.B.154258188322703.ack@debbugs.gnu.org>
@ 2018-11-25 13:12   ` Stephen Berman
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Berman @ 2018-11-25 13:12 UTC (permalink / raw)
  To: 33423

On Sun, 18 Nov 2018 23:57:32 +0100 Stephen Berman <stephen.berman@gmx.net> wrote:

> The reason is that diary-mark-entries does not take narrowing of
> included files into account (todo-mode files are narrowed to the current
> category: if after step 3 above you type `f' in the todo-mode buffer, it
> then displays the next category, and now doing step 4 does show the
> Calendar with all dates marked as diary items).
>
> The following patch fixes this.  (Only nine years after bug#5093; better
> late than never.  But I guess too late for 26.2?)

I've seen no objections, so I committed this to master.

Steve Berman





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

end of thread, other threads:[~2018-11-25 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-18 22:57 bug#33423: 27.0.50; Marking diary entries from included files Stephen Berman
     [not found] ` <handler.33423.B.154258188322703.ack@debbugs.gnu.org>
2018-11-25 13:12   ` bug#33423: Acknowledgement (27.0.50; Marking diary entries from included files) Stephen Berman

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.