diff options
| author | Glenn Morris | 2010-09-28 21:19:30 -0700 |
|---|---|---|
| committer | Glenn Morris | 2010-09-28 21:19:30 -0700 |
| commit | 17a46341d80fd2ea11a5a77f0932b04db2bddfbb (patch) | |
| tree | 5c116f653f31fb63bb1674230bdb049e6991af19 | |
| parent | 7161e329ef71ee536d94e6cd0328ad1b7540cc23 (diff) | |
| download | emacs-17a46341d80fd2ea11a5a77f0932b04db2bddfbb.tar.gz emacs-17a46341d80fd2ea11a5a77f0932b04db2bddfbb.zip | |
Use temp-buffers when not displaying the diary.
* lisp/calendar/diary-lib.el (diary-list-entries): Use temp buffers when
not displaying the diary.
(diary-add-to-list): If no buffer-file-name, fall back to diary-file.
* lisp/calendar/appt.el (appt-check): No longer need to kill diary.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/calendar/appt.el | 18 | ||||
| -rw-r--r-- | lisp/calendar/diary-lib.el | 146 |
3 files changed, 85 insertions, 84 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5d65ecf5987..655e4d1b240 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2010-09-29 Glenn Morris <rgm@gnu.org> | 1 | 2010-09-29 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * calendar/diary-lib.el (diary-list-entries): Use temp buffers when | ||
| 4 | not displaying the diary. | ||
| 5 | (diary-add-to-list): If no buffer-file-name, fall back to diary-file. | ||
| 6 | * calendar/appt.el (appt-check): No longer need to kill diary. | ||
| 7 | |||
| 3 | * calendar/diary-lib.el (diary-list-entries): Move the | 8 | * calendar/diary-lib.el (diary-list-entries): Move the |
| 4 | "Preparing..." message entirely here. | 9 | "Preparing..." message entirely here. |
| 5 | (diary-simple-display, diary-fancy-display): Move "Preparing..." | 10 | (diary-simple-display, diary-fancy-display): Move "Preparing..." |
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index 4926e79c2b5..cd0f049027b 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el | |||
| @@ -257,8 +257,6 @@ The variable `appt-audible' controls the audible reminder." | |||
| 257 | (message "%s" string))))) | 257 | (message "%s" string))))) |
| 258 | 258 | ||
| 259 | 259 | ||
| 260 | (defvar diary-selective-display) | ||
| 261 | |||
| 262 | (defun appt-check (&optional force) | 260 | (defun appt-check (&optional force) |
| 263 | "Check for an appointment and update any reminder display. | 261 | "Check for an appointment and update any reminder display. |
| 264 | If optional argument FORCE is non-nil, reparse the diary file for | 262 | If optional argument FORCE is non-nil, reparse the diary file for |
| @@ -326,7 +324,7 @@ displayed in a window: | |||
| 326 | (mode-line-only (unless full-check appt-now-displayed)) | 324 | (mode-line-only (unless full-check appt-now-displayed)) |
| 327 | now cur-comp-time appt-comp-time appt-warn-time) | 325 | now cur-comp-time appt-comp-time appt-warn-time) |
| 328 | (when (or full-check mode-line-only) | 326 | (when (or full-check mode-line-only) |
| 329 | (save-excursion | 327 | (save-excursion ; FIXME ? |
| 330 | ;; Convert current time to minutes after midnight (12.01am = 1). | 328 | ;; Convert current time to minutes after midnight (12.01am = 1). |
| 331 | (setq now (decode-time) | 329 | (setq now (decode-time) |
| 332 | cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now))) | 330 | cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now))) |
| @@ -337,23 +335,13 @@ displayed in a window: | |||
| 337 | (ignore-errors | 335 | (ignore-errors |
| 338 | (let ((diary-hook (if (assoc 'appt-make-list diary-hook) | 336 | (let ((diary-hook (if (assoc 'appt-make-list diary-hook) |
| 339 | diary-hook | 337 | diary-hook |
| 340 | (cons 'appt-make-list diary-hook))) | 338 | (cons 'appt-make-list diary-hook)))) |
| 341 | d-buff d-buff2) | ||
| 342 | (if appt-display-diary | 339 | (if appt-display-diary |
| 343 | (diary) | 340 | (diary) |
| 344 | (setq d-buff (find-buffer-visiting diary-file)) | ||
| 345 | ;; Not displaying the diary, so we can ignore | 341 | ;; Not displaying the diary, so we can ignore |
| 346 | ;; diary-number-of-entries. Since appt.el only | 342 | ;; diary-number-of-entries. Since appt.el only |
| 347 | ;; works on a daily basis, no need for more entries. | 343 | ;; works on a daily basis, no need for more entries. |
| 348 | (diary-list-entries (calendar-current-date) 1 t) | 344 | (diary-list-entries (calendar-current-date) 1 t))))) |
| 349 | ;; If diary buffer did not exist before this command, kill it. | ||
| 350 | ;; FIXME does not kill any included diary files. | ||
| 351 | ;; The real issue is that (diary) should not have | ||
| 352 | ;; the side effect of visiting all the diary files. | ||
| 353 | ;; It is not really appt.el's job to clean up this mess... | ||
| 354 | (and (not d-buff) | ||
| 355 | (setq d-buff2 (find-buffer-visiting diary-file)) | ||
| 356 | (kill-buffer d-buff2)))))) | ||
| 357 | (setq appt-prev-comp-time cur-comp-time | 345 | (setq appt-prev-comp-time cur-comp-time |
| 358 | appt-mode-string nil | 346 | appt-mode-string nil |
| 359 | appt-display-count nil) | 347 | appt-display-count nil) |
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 37af75a7164..ddabeb7dbad 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -594,19 +594,20 @@ The entry is added to the list as (DATE STRING SPECIFIER LOCATOR | |||
| 594 | GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL), | 594 | GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL), |
| 595 | FILENAME being the file containing the diary entry." | 595 | FILENAME being the file containing the diary entry." |
| 596 | (when (and date string) | 596 | (when (and date string) |
| 597 | (if diary-file-name-prefix | 597 | ;; b-f-n is nil if we are visiting an include file in a temp-buffer. |
| 598 | (let ((prefix (funcall diary-file-name-prefix-function | 598 | (let ((dfile (or (buffer-file-name) diary-file))) |
| 599 | (buffer-file-name)))) | 599 | (if diary-file-name-prefix |
| 600 | (or (string-equal prefix "") | 600 | (let ((prefix (funcall diary-file-name-prefix-function dfile))) |
| 601 | (setq string (format "[%s] %s" prefix string))))) | 601 | (or (string-equal prefix "") |
| 602 | (and diary-modify-entry-list-string-function | 602 | (setq string (format "[%s] %s" prefix string))))) |
| 603 | (setq string (funcall diary-modify-entry-list-string-function | 603 | (and diary-modify-entry-list-string-function |
| 604 | string))) | 604 | (setq string (funcall diary-modify-entry-list-string-function |
| 605 | (setq diary-entries-list | 605 | string))) |
| 606 | (append diary-entries-list | 606 | (setq diary-entries-list |
| 607 | (list (list date string specifier | 607 | (append diary-entries-list |
| 608 | (list marker (buffer-file-name) literal) | 608 | (list (list date string specifier |
| 609 | globcolor)))))) | 609 | (list marker dfile literal) |
| 610 | globcolor))))))) | ||
| 610 | 611 | ||
| 611 | (define-obsolete-function-alias 'add-to-diary-list 'diary-add-to-list "23.1") | 612 | (define-obsolete-function-alias 'add-to-diary-list 'diary-add-to-list "23.1") |
| 612 | 613 | ||
| @@ -760,65 +761,72 @@ LIST-ONLY is non-nil, in which case it just returns the list." | |||
| 760 | (diary-buffer (find-buffer-visiting diary-file)) | 761 | (diary-buffer (find-buffer-visiting diary-file)) |
| 761 | ;; Dynamically bound in diary-include-other-diary-files. | 762 | ;; Dynamically bound in diary-include-other-diary-files. |
| 762 | (d-incp (and (boundp 'diary-including) diary-including)) | 763 | (d-incp (and (boundp 'diary-including) diary-including)) |
| 763 | diary-entries-list file-glob-attrs) | 764 | diary-entries-list file-glob-attrs temp-buff) |
| 764 | (unless d-incp | 765 | (unless d-incp |
| 765 | (setq diary-included-files nil) | 766 | (setq diary-included-files nil) |
| 766 | (message "Preparing diary...")) | 767 | (message "Preparing diary...")) |
| 767 | (save-current-buffer | 768 | (unwind-protect |
| 768 | (if (not diary-buffer) | 769 | (with-current-buffer (or diary-buffer |
| 769 | (set-buffer (find-file-noselect diary-file t)) | 770 | (if list-only |
| 770 | (set-buffer diary-buffer) | 771 | (setq temp-buff (generate-new-buffer |
| 771 | (or (verify-visited-file-modtime diary-buffer) | 772 | " *diary-temp*")) |
| 772 | (revert-buffer t t))) | 773 | (find-file-noselect diary-file t))) |
| 773 | ;; Setup things like the header-line-format and invisibility-spec. | 774 | (if diary-buffer |
| 774 | (if (eq major-mode (default-value 'major-mode)) | 775 | (or (verify-visited-file-modtime diary-buffer) |
| 775 | (diary-mode) | 776 | (revert-buffer t t))) |
| 776 | ;; This kludge is to make customizations to | 777 | (if temp-buff |
| 777 | ;; diary-header-line-flag after diary has been displayed | 778 | ;; If including, caller has already verified it is readable. |
| 778 | ;; take effect. Unconditionally calling (diary-mode) | 779 | (insert-file-contents diary-file) |
| 779 | ;; clobbers file local variables. | 780 | ;; Setup things like the header-line-format and invisibility-spec. |
| 780 | ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-03/msg00363.html | 781 | (if (eq major-mode (default-value 'major-mode)) |
| 781 | ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-04/msg00404.html | 782 | (diary-mode) |
| 782 | (if (eq major-mode 'diary-mode) | 783 | ;; This kludge is to make customizations to |
| 783 | (setq header-line-format (and diary-header-line-flag | 784 | ;; diary-header-line-flag after diary has been displayed |
| 784 | diary-header-line-format)))) | 785 | ;; take effect. Unconditionally calling (diary-mode) |
| 785 | ;; d-s-p is passed to the diary display function. | 786 | ;; clobbers file local variables. |
| 786 | (let ((diary-saved-point (point))) | 787 | ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-03/msg00363.html |
| 787 | (save-excursion | 788 | ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-04/msg00404.html |
| 788 | (save-restriction | 789 | (if (eq major-mode 'diary-mode) |
| 789 | (widen) ; bug#5093 | 790 | (setq header-line-format (and diary-header-line-flag |
| 790 | (setq file-glob-attrs (cadr (diary-pull-attrs nil ""))) | 791 | diary-header-line-format))))) |
| 791 | (with-syntax-table diary-syntax-table | 792 | ;; d-s-p is passed to the diary display function. |
| 792 | (goto-char (point-min)) | 793 | (let ((diary-saved-point (point))) |
| 793 | (unless list-only | 794 | (save-excursion |
| 794 | (let ((ol (make-overlay (point-min) (point-max) nil t nil))) | 795 | (save-restriction |
| 795 | (set (make-local-variable 'diary-selective-display) t) | 796 | (widen) ; bug#5093 |
| 796 | (overlay-put ol 'invisible 'diary) | 797 | (setq file-glob-attrs (cadr (diary-pull-attrs nil ""))) |
| 797 | (overlay-put ol 'evaporate t))) | 798 | (with-syntax-table diary-syntax-table |
| 798 | (dotimes (idummy number) | 799 | (goto-char (point-min)) |
| 799 | (let ((sexp-found (diary-list-sexp-entries date)) | 800 | (unless list-only |
| 800 | (entry-found (diary-list-entries-2 | 801 | (let ((ol (make-overlay (point-min) (point-max) nil t nil))) |
| 801 | date diary-nonmarking-symbol | 802 | (set (make-local-variable 'diary-selective-display) t) |
| 802 | file-glob-attrs list-only))) | 803 | (overlay-put ol 'invisible 'diary) |
| 803 | (if diary-list-include-blanks | 804 | (overlay-put ol 'evaporate t))) |
| 804 | (or sexp-found entry-found | 805 | (dotimes (idummy number) |
| 805 | (diary-add-to-list date "" "" "" ""))) | 806 | (let ((sexp-found (diary-list-sexp-entries date)) |
| 806 | (setq date | 807 | (entry-found (diary-list-entries-2 |
| 807 | (calendar-gregorian-from-absolute | 808 | date diary-nonmarking-symbol |
| 808 | (1+ (calendar-absolute-from-gregorian date))))))) | 809 | file-glob-attrs list-only))) |
| 809 | (goto-char (point-min)) | 810 | (if diary-list-include-blanks |
| 810 | (run-hooks 'diary-nongregorian-listing-hook | 811 | (or sexp-found entry-found |
| 811 | 'diary-list-entries-hook) | 812 | (diary-add-to-list date "" "" "" ""))) |
| 812 | (unless list-only | 813 | (setq date |
| 813 | (if (and diary-display-function | 814 | (calendar-gregorian-from-absolute |
| 814 | (listp diary-display-function)) | 815 | (1+ (calendar-absolute-from-gregorian date))))))) |
| 815 | ;; Backwards compatibility. | 816 | (goto-char (point-min)) |
| 816 | (run-hooks 'diary-display-function) | 817 | (run-hooks 'diary-nongregorian-listing-hook |
| 817 | (funcall (or diary-display-function | 818 | 'diary-list-entries-hook) |
| 818 | 'diary-simple-display)))) | 819 | (unless list-only |
| 819 | (run-hooks 'diary-hook) | 820 | (if (and diary-display-function |
| 820 | (or d-incp (message "Preparing diary...done")) | 821 | (listp diary-display-function)) |
| 821 | diary-entries-list))))))) | 822 | ;; Backwards compatibility. |
| 823 | (run-hooks 'diary-display-function) | ||
| 824 | (funcall (or diary-display-function | ||
| 825 | 'diary-simple-display)))) | ||
| 826 | (run-hooks 'diary-hook))))) | ||
| 827 | (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff))) | ||
| 828 | (or d-incp (message "Preparing diary...done")) | ||
| 829 | diary-entries-list))) | ||
| 822 | 830 | ||
| 823 | (define-obsolete-function-alias 'list-diary-entries 'diary-list-entries "22.1") | 831 | (define-obsolete-function-alias 'list-diary-entries 'diary-list-entries "22.1") |
| 824 | 832 | ||