]> git.eshelyaron.com Git - emacs.git/commitdiff
When marking, visit included diary-files in temp buffers.
authorGlenn Morris <rgm@gnu.org>
Sat, 25 Jun 2011 22:10:21 +0000 (15:10 -0700)
committerGlenn Morris <rgm@gnu.org>
Sat, 25 Jun 2011 22:10:21 +0000 (15:10 -0700)
Ref: bug#8920, but not a bug.

* lisp/calendar/diary-lib.el (diary-mark-entries)
(diary-mark-included-diary-files):
Visit included diary-files in temp buffers.

lisp/ChangeLog
lisp/calendar/diary-lib.el

index a86a20fc7379838688005aa5a8be7be8092019d0..19ec366de71a24ec60d3011ba26db355747c44f0 100644 (file)
@@ -1,5 +1,9 @@
 2011-06-25  Glenn Morris  <rgm@gnu.org>
 
+       * calendar/diary-lib.el (diary-mark-entries)
+       (diary-mark-included-diary-files):
+       Visit included diary-files in temp buffers.
+
        * progmodes/f90.el (f90-keywords-re, f90-font-lock-keywords-1)
        (f90-blocks-re, f90-program-block-re, f90-end-block-re)
        (f90-start-block-re, f90-imenu-generic-expression)
index f21247e9c93dc80a81cdc16e7cded2d385e2b65f..0b0d05a8fc019586f9296f348569887842936c61 100644 (file)
@@ -1405,22 +1405,36 @@ marks.  This is intended to deal with deleted diary entries."
     (setq calendar-mark-diary-entries-flag nil)
     (calendar-redraw))
   (let ((diary-marking-entries-flag t)
-        file-glob-attrs)
-    (with-current-buffer (find-file-noselect (diary-check-diary-file) t)
-      (save-excursion
-        (when (eq major-mode (default-value 'major-mode)) (diary-mode))
-        (setq calendar-mark-diary-entries-flag t)
-        (message "Marking diary entries...")
-        (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
-        (with-syntax-table diary-syntax-table
-          (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))
-        (message "Marking diary entries...done")))))
+        (diary-buffer (find-buffer-visiting diary-file))
+        ;; Dynamically bound in diary-mark-included-diary-files.
+        (d-incp (and (boundp 'diary-including) diary-including))
+        file-glob-attrs temp-buff)
+    (unless d-incp
+      (message "Marking diary entries..."))
+    (unwind-protect
+        (with-current-buffer (or diary-buffer
+                                 (if d-incp
+                                     (setq temp-buff (generate-new-buffer
+                                                        " *diary-temp*"))
+                                   (find-file-noselect
+                                    (diary-check-diary-file) t)))
+          (if temp-buff
+              ;; If including, caller has already verified it is readable.
+              (insert-file-contents diary-file)
+            (if (eq major-mode (default-value 'major-mode)) (diary-mode)))
+          (setq calendar-mark-diary-entries-flag t)
+          (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))))
+      (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff)))
+    (or d-incp (message "Marking diary entries...done"))))
 
 ;;;###cal-autoload
 (define-obsolete-function-alias 'mark-diary-entries 'diary-mark-entries "23.1")
@@ -1514,15 +1528,12 @@ See also `diary-include-other-diary-files'."
   (while (re-search-forward
           (format "^%s \"\\([^\"]*\\)\"" (regexp-quote diary-include-string))
           nil t)
-    (let* ((diary-file (match-string-no-properties 1))
-           (diary-mark-entries-hook 'diary-mark-included-diary-files)
-           (dbuff (find-buffer-visiting diary-file)))
+    (let ((diary-file (match-string-no-properties 1))
+          (diary-mark-entries-hook 'diary-mark-included-diary-files)
+          (diary-including t))
       (if (file-exists-p diary-file)
           (if (file-readable-p diary-file)
-              (progn
-                (diary-mark-entries)
-                (unless dbuff
-                  (kill-buffer (find-buffer-visiting diary-file))))
+              (diary-mark-entries)
             (beep)
             (message "Can't read included diary file %s" diary-file)
             (sleep-for 2))