Function: diary-add-to-list

diary-add-to-list is a byte-compiled function defined in diary-lib.el.gz.

Signature

(diary-add-to-list DATE STRING SPECIFIER &optional MARKER GLOBCOLOR LITERAL)

Documentation

Add an entry to diary-entries-list.

Do nothing if DATE or STRING are nil. DATE is the (MONTH DAY YEAR) for which the entry applies; STRING is the text of the entry as it will appear in the diary (i.e. with any format strings such as "%d" expanded); SPECIFIER is the date part of the entry as it appears in the diary-file; LITERAL is the entry as it appears in the diary-file (i.e. before expansion). If LITERAL is nil, it is taken to be the same as STRING.

The entry is added to the list as (DATE STRING SPECIFIER LOCATOR GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL), FILENAME being the file containing the diary entry.

Modifies STRING using diary-modify-entry-list-string-function, if non-nil. Also removes the region between diary-comment-start and diary-comment-end, if the former is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-lib.el.gz
(defvar diary-entries-list)             ; bound in diary-list-entries

(defun diary-add-to-list (date string specifier &optional marker
                               globcolor literal)
  "Add an entry to `diary-entries-list'.
Do nothing if DATE or STRING are nil.  DATE is the (MONTH DAY
YEAR) for which the entry applies; STRING is the text of the
entry as it will appear in the diary (i.e. with any format
strings such as \"%d\" expanded); SPECIFIER is the date part of
the entry as it appears in the diary-file; LITERAL is the entry
as it appears in the diary-file (i.e. before expansion).
If LITERAL is nil, it is taken to be the same as STRING.

The entry is added to the list as (DATE STRING SPECIFIER LOCATOR
GLOBCOLOR), where LOCATOR has the form (MARKER FILENAME LITERAL),
FILENAME being the file containing the diary entry.

Modifies STRING using `diary-modify-entry-list-string-function', if non-nil.
Also removes the region between `diary-comment-start' and
`diary-comment-end', if the former is non-nil."
  (when (and date string)
    ;; b-f-n is nil if we are visiting an include file in a temp-buffer.
    (let ((dfile (or (buffer-file-name) diary-file))
          cstart)
      (if diary-file-name-prefix
          (let ((prefix (funcall diary-file-name-prefix-function dfile)))
            (or (string-equal prefix "")
                (setq string (format "[%s] %s" prefix string)))))
      (and diary-modify-entry-list-string-function
           (setq string (funcall diary-modify-entry-list-string-function
                                 string)))
      (when (and diary-comment-start
                 (string-match (setq cstart (regexp-quote diary-comment-start))
                               string))
        ;; Preserve the value with the comments.
        (or literal (setq literal string))
        ;; Handles multiple comments per entry, so long as each is on
        ;; a single line, and each line has no more than one comment.
        (setq string (replace-regexp-in-string
                      (format "%s.*%s" cstart (regexp-quote diary-comment-end))
                      "" string)))
      (setq diary-entries-list
            (append diary-entries-list
                    (list (list date string specifier
                                (list marker dfile literal)
                                globcolor)))))))