;;; Code:
(require 'calendar)
-(require 'diary-loaddefs)
+(eval-and-compile (load "diary-loaddefs" nil t))
(defgroup diary nil
"Emacs diary."
(define-obsolete-variable-alias 'diary-display-hook 'diary-display-function
"23.1")
-(defcustom diary-display-function 'diary-simple-display
+(defcustom diary-display-function 'diary-fancy-display
"Function used to display the diary.
-The default is `diary-simple-display'; `diary-fancy-display' is
-an alternative.
+The two standard options are `diary-fancy-display' and `diary-simple-display'.
For historical reasons, `nil' is the same as `diary-simple-display'
\(so you must use `ignore' for no display). Also for historical
entry for the given date. This can be used, for example, to
produce a different buffer for display (perhaps combined with
holidays), or hard copy output."
- :type '(choice (const diary-simple-display :tag "Basic display")
- (const diary-fancy-display :tag "Fancy display")
+ :type '(choice (const diary-fancy-display :tag "Fancy display")
+ (const diary-simple-display :tag "Basic display")
(const ignore :tag "No display")
(const nil :tag "Obsolete way to choose basic display")
(hook :tag "Obsolete form with list of display functions"))
:initialize 'custom-initialize-default
:set 'diary-set-maybe-redraw
- :version "23.1"
+ :version "23.2" ; simple->fancy
:group 'diary)
(define-obsolete-variable-alias 'list-diary-entries-hook
(diary-buffer (find-buffer-visiting diary-file))
diary-entries-list file-glob-attrs)
(message "Preparing diary...")
- (save-excursion
+ (save-current-buffer
(if (not diary-buffer)
(set-buffer (find-file-noselect diary-file t))
(set-buffer diary-buffer)
;; d-s-p is passed to the diary display function.
(let ((diary-saved-point (point)))
(save-excursion
- (setq file-glob-attrs (cadr (diary-pull-attrs nil "")))
- (with-syntax-table diary-syntax-table
+ (save-restriction
+ (widen) ; bug#5093
+ (setq file-glob-attrs (cadr (diary-pull-attrs nil "")))
+ (with-syntax-table diary-syntax-table
+ (goto-char (point-min))
+ (unless list-only
+ (let ((ol (make-overlay (point-min) (point-max) nil t nil)))
+ (set (make-local-variable 'diary-selective-display) t)
+ (overlay-put ol 'invisible 'diary)
+ (overlay-put ol 'evaporate t)))
+ (dotimes (idummy number)
+ (let ((sexp-found (diary-list-sexp-entries date))
+ (entry-found (diary-list-entries-2
+ date diary-nonmarking-symbol
+ file-glob-attrs list-only)))
+ (if diary-list-include-blanks
+ (or sexp-found entry-found
+ (diary-add-to-list date "" "" "" "")))
+ (setq date
+ (calendar-gregorian-from-absolute
+ (1+ (calendar-absolute-from-gregorian date)))))))
(goto-char (point-min))
+ (run-hooks 'diary-nongregorian-listing-hook
+ 'diary-list-entries-hook)
(unless list-only
- (let ((ol (make-overlay (point-min) (point-max) nil t nil)))
- (set (make-local-variable 'diary-selective-display) t)
- (overlay-put ol 'invisible 'diary)
- (overlay-put ol 'evaporate t)))
- (dotimes (idummy number)
- (let ((sexp-found (diary-list-sexp-entries date))
- (entry-found (diary-list-entries-2
- date diary-nonmarking-symbol
- file-glob-attrs list-only)))
- (if diary-list-include-blanks
- (or sexp-found entry-found
- (diary-add-to-list date "" "" "" "")))
- (setq date
- (calendar-gregorian-from-absolute
- (1+ (calendar-absolute-from-gregorian date)))))))
- (goto-char (point-min))
- (run-hooks 'diary-nongregorian-listing-hook
- 'diary-list-entries-hook)
- (unless list-only
- (if (and diary-display-function
- (listp diary-display-function))
- ;; Backwards compatibility.
- (run-hooks 'diary-display-function)
- (funcall (or diary-display-function
- 'diary-simple-display))))
- (run-hooks 'diary-hook)
- diary-entries-list))))))
+ (if (and diary-display-function
+ (listp diary-display-function))
+ ;; Backwards compatibility.
+ (run-hooks 'diary-display-function)
+ (funcall (or diary-display-function
+ 'diary-simple-display))))
+ (run-hooks 'diary-hook)
+ diary-entries-list)))))))
(define-obsolete-function-alias 'list-diary-entries 'diary-list-entries "22.1")
(define-obsolete-function-alias 'simple-diary-display
'diary-simple-display "23.1")
-(define-button-type 'diary-entry
- 'action #'diary-goto-entry
- 'face 'diary-button)
+(define-button-type 'diary-entry 'action #'diary-goto-entry
+ 'face 'diary-button 'help-echo "Find this diary entry"
+ 'follow-link t)
(defun diary-goto-entry (button)
"Jump to the diary entry for the BUTTON at point."
this-loc marks temp-face)
(unless (zerop (length this-entry))
(if (setq this-loc (nth 3 entry))
- (insert-button (concat this-entry "\n")
+ (insert-button this-entry
;; (MARKER FILENAME SPECIFIER LITERAL)
'locator (list (car this-loc)
(cadr this-loc)
(or (nth 2 this-loc)
(nth 1 entry)))
:type 'diary-entry)
- (insert this-entry ?\n))
+ (insert this-entry))
+ (insert ?\n)
;; Doesn't make sense to check font-lock-mode - see
;; comments above diary-entry-marker in calendar.el.
(and ; font-lock-mode
(overlay-put
(make-overlay (match-beginning 0) (match-end 0))
'face temp-face)))))))
- (or (eq major-mode 'diary-fancy-display-mode)
- (diary-fancy-display-mode))
+ ;; FIXME can't remember what this check was for.
+ ;; To prevent something looping, or a minor optimization?
+ (if (eq major-mode 'diary-fancy-display-mode)
+ (run-hooks 'diary-fancy-display-mode-hook)
+ (diary-fancy-display-mode))
(calendar-set-mode-line date-string)
(message "Preparing diary...done"))))
all entries, not just some, are visible. If there is no diary buffer, one
is created."
(interactive)
- (let ((d-file (diary-check-diary-file))
- (pop-up-frames (or pop-up-frames
- (window-dedicated-p (selected-window)))))
+ (let* ((d-file (diary-check-diary-file))
+ (pop-up-frames (or pop-up-frames
+ (window-dedicated-p (selected-window))))
+ (win (selected-window))
+ (height (window-height)))
(with-current-buffer (or (find-buffer-visiting d-file)
(find-file-noselect d-file t))
(when (eq major-mode (default-value 'major-mode)) (diary-mode))
(diary-unhide-everything)
- (display-buffer (current-buffer)))))
+ (display-buffer (current-buffer))
+ (when (and (/= height (window-height win))
+ (with-current-buffer (window-buffer win)
+ (derived-mode-p 'calendar-mode)))
+ (fit-window-to-buffer win)))))
(define-obsolete-function-alias 'show-all-diary-entries
'diary-show-all-entries "22.1")
The function FROMABS converts absolute dates to the appropriate date system.
The function TOABS carries out the inverse operation. Optional argument
COLOR is passed to `calendar-mark-visible-date' as MARK."
- (save-excursion
- (set-buffer calendar-buffer)
+ (with-current-buffer calendar-buffer
(if (and (not (zerop month)) (not (zerop day)))
(if (not (zerop year))
;; Fully specified date.
sexp-start sexp entry specifier entry-start line-start
diary-entry temp literal)
(goto-char (point-min))
- (save-excursion
- (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))))
+ (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
(while (re-search-forward s-entry nil t)
(backward-char 1)
(setq sexp-start (point))
t nil nil nil
(font-lock-fontify-region-function
. diary-fancy-font-lock-fontify-region-function)))
+ (local-set-key "q" 'quit-window)
(set (make-local-variable 'minor-mode-overriding-map-alist)
(list (cons t diary-fancy-overriding-map)))
(view-mode 1))
;; `diary-outlook-formats'.
(defvar subject) ; bound in diary-from-outlook-gnus
+(defvar body)
(defun diary-from-outlook-internal (&optional test-only)
"Snarf a diary entry from a message assumed to be from MS Outlook.