Function: diary-list-entries-2

diary-list-entries-2 is a byte-compiled function defined in diary-lib.el.gz.

Signature

(diary-list-entries-2 DATE MARK GLOBATTR LIST-ONLY &optional MONTHS SYMBOL GDATE)

Documentation

Internal subroutine of diary-list-entries.

Find diary entries applying to DATE, by searching from point-min for each element of diary-date-forms. MARK indicates an entry is non-marking. GLOBATTR is the list of global file attributes. If LIST-ONLY is non-nil, don't change the buffer, only return a list of entries. Optional array MONTHS replaces calendar-month-name-array, and means months cannot be abbreviated. Optional string SYMBOL marks diary entries of the desired type. If DATE is not Gregorian, then the Gregorian equivalent should be provided via GDATE. Returns non-nil if any entries were found.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-lib.el.gz
(defun diary-list-entries-2 (date mark globattr list-only
                                  &optional months symbol gdate)
  "Internal subroutine of `diary-list-entries'.
Find diary entries applying to DATE, by searching from point-min for
each element of `diary-date-forms'.  MARK indicates an entry is non-marking.
GLOBATTR is the list of global file attributes.  If LIST-ONLY is
non-nil, don't change the buffer, only return a list of entries.
Optional array MONTHS replaces `calendar-month-name-array', and
means months cannot be abbreviated.  Optional string SYMBOL marks diary
entries of the desired type.  If DATE is not Gregorian, then the
Gregorian equivalent should be provided via GDATE.  Returns non-nil if
any entries were found."
  (let* ((month (calendar-extract-month date))
         (day (calendar-extract-day date))
         (year (calendar-extract-year date))
         (calendar-month-name-array (or months calendar-month-name-array))
         (case-fold-search t)
         entry-found)
    (calendar-dlet
        ((dayname (format "%s\\|%s\\.?" (calendar-day-name date)
                          (calendar-day-name date 'abbrev)))
         (monthname (format "\\*\\|%s%s" (calendar-month-name month)
                            (if months ""
                              (format "\\|%s\\.?"
                                      (calendar-month-name month 'abbrev)))))
         (month (format "\\*\\|0*%d" month))
         (day (format "\\*\\|0*%d" day))
         (year (format "\\*\\|0*%d%s" year
                       (if diary-abbreviated-year-flag
                           (format "\\|%02d" (% year 100))
                         ""))))
      (dolist (date-form diary-date-forms)
        (let ((backup (when (eq (car date-form) 'backup)
                        (setq date-form (cdr date-form))
                        t))
              ;; date-form uses day etc as set above.
              (regexp (format "^%s?%s\\(%s\\)" (regexp-quote mark)
                              (if symbol (regexp-quote symbol) "")
                              (mapconcat #'eval date-form "\\)\\(?:")))
              entry-start date-start temp)
          (goto-char (point-min))
          (while (re-search-forward regexp nil t)
            (if backup (re-search-backward "\\<" nil t))
            ;; regexp moves us past the end of date, onto the next line.
            ;; Trailing whitespace after date not allowed (see diary-file).
            (if (and (bolp) (not (looking-at "[ \t]")))
                ;; Diary entry that consists only of date.
                (backward-char 1)
              ;; Found a nonempty diary entry--make it
              ;; visible and add it to the list.
                (setq date-start (line-end-position 0))
                ;; Actual entry starts on the next-line?
                (if (looking-at "[ \t]*\n[ \t]") (forward-line 1))
                (setq entry-found t
                      entry-start (point))
                (forward-line 1)
                (while (looking-at "[ \t]") ; continued entry
                  (forward-line 1))
                (unless (and (eobp) (not (bolp)))
                  (backward-char 1))
                (unless list-only
                  (remove-overlays date-start (point) 'invisible 'diary))
                (setq temp (diary-pull-attrs
                            (buffer-substring-no-properties
                             entry-start (point))
                            globattr))
                (diary-add-to-list
                 (or gdate date) (car temp)
                 (buffer-substring-no-properties
                  (1+ date-start) (1- entry-start))
                 (copy-marker entry-start) (cadr temp))))))
      entry-found)))