Function: diary-mark-entries

diary-mark-entries is an autoloaded, interactive and byte-compiled function defined in diary-lib.el.gz.

Signature

(diary-mark-entries &optional REDRAW)

Documentation

Mark days in the calendar window that have diary entries.

Marks each entry in the diary that is visible in the calendar window.

After marking the entries, runs diary-nongregorian-marking-hook for the main diary file, and each included file. For example, this is the appropriate hook to process Islamic entries in all diary files. Next diary-mark-entries-hook runs, for the main diary file only. If not using include files, there is no difference between these two hooks.

If the optional argument REDRAW is non-nil (which is the case interactively, for example) then this first removes any existing diary marks. This is intended to deal with deleted diary entries.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-lib.el.gz
;;;###cal-autoload
(defun diary-mark-entries (&optional redraw)
  "Mark days in the calendar window that have diary entries.
Marks each entry in the diary that is visible in the calendar window.

After marking the entries, runs `diary-nongregorian-marking-hook'
for the main diary file, and each included file.  For example,
this is the appropriate hook to process Islamic entries in all
diary files.  Next `diary-mark-entries-hook' runs, for the main diary
file only.  If not using include files, there is no difference between
these two hooks.

If the optional argument REDRAW is non-nil (which is the case
interactively, for example) then this first removes any existing diary
marks.  This is intended to deal with deleted diary entries."
  (interactive "p")
  ;; To remove any deleted diary entries. Do not redraw when:
  ;; i) processing #include diary files (else only get the marks from
  ;; the last #include file processed).
  ;; ii) called via calendar-redraw (since calendar has already been
  ;; erased).
  ;; Use of REDRAW handles both of these cases.
  (when (and redraw calendar-mark-diary-entries)
    (setq calendar-mark-diary-entries nil)
    (calendar-redraw))
  (let ((diary-marking-entries-flag t)
        (diary-buffer (find-buffer-visiting diary-file))
        ;; Record current calendar buffer in case this function is
        ;; called in a calendar-mode buffer not named `calendar-buffer'.
        (calendar-buffer (calendar-get-buffer))
        ;; Dynamically bound in diary-include-files.
        (d-incp (and (boundp 'diary-including) diary-including))
        file-glob-attrs temp-buff)
    (unless d-incp
      (setq diary-included-files nil)
      (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 t)
          (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
          (with-syntax-table diary-syntax-table
            (save-excursion
              (save-restriction
                (widen)                 ; bug#33423
                (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"))))