Mercurial > emacs
comparison lisp/calendar/diary-lib.el @ 110641:1b24798e2816
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.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 28 Sep 2010 21:19:30 -0700 |
parents | f7f67bd95f3d |
children | 76088ffbc653 |
comparison
equal
deleted
inserted
replaced
110640:f7f67bd95f3d | 110641:1b24798e2816 |
---|---|
592 | 592 |
593 The entry is added to the list as (DATE STRING SPECIFIER LOCATOR | 593 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 |
613 (defun diary-list-entries-2 (date mark globattr list-only | 614 (defun diary-list-entries-2 (date mark globattr list-only |
614 &optional months symbol gdate) | 615 &optional months symbol gdate) |
758 (let* ((original-date date) ; save for possible use in the hooks | 759 (let* ((original-date date) ; save for possible use in the hooks |
759 (date-string (calendar-date-string date)) | 760 (date-string (calendar-date-string date)) |
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 |
825 (defun diary-unhide-everything () | 833 (defun diary-unhide-everything () |
826 "Show all invisible text in the diary." | 834 "Show all invisible text in the diary." |