Function: diary-pull-attrs

diary-pull-attrs is a byte-compiled function defined in diary-lib.el.gz.

Signature

(diary-pull-attrs ENTRY FILEGLOBATTRS)

Documentation

Search for matches for regexps from diary-face-attrs.

If ENTRY is nil, searches from the start of the current buffer, and prepends all regexps with diary-glob-file-regexp-prefix. If ENTRY is a string, search for matches in that string, and remove them. Returns a list of ENTRY followed by (ATTRIBUTE VALUE) pairs. When ENTRY is non-nil, FILEGLOBATTRS forms the start of the (ATTRIBUTE VALUE) pairs.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-lib.el.gz
(defun diary-pull-attrs (entry fileglobattrs)
  "Search for matches for regexps from `diary-face-attrs'.
If ENTRY is nil, searches from the start of the current buffer, and
prepends all regexps with `diary-glob-file-regexp-prefix'.
If ENTRY is a string, search for matches in that string, and remove them.
Returns a list of ENTRY followed by (ATTRIBUTE VALUE) pairs.
When ENTRY is non-nil, FILEGLOBATTRS forms the start of the (ATTRIBUTE VALUE)
pairs."
  (let (ret-attr)
    (if (null entry)
        (save-excursion
          (dolist (attr diary-face-attrs)
            ;; FIXME inefficient searching.
            (goto-char (point-min))
            (let* ((regexp (concat diary-glob-file-regexp-prefix (car attr)))
                   (regnum (cadr attr))
                   (attrname (nth 2 attr))
                   (type (nth 3 attr))
                   (attrvalue (if (re-search-forward regexp nil t)
                                  (match-string-no-properties regnum))))
              (and attrvalue
                   (setq attrvalue (diary-attrtype-convert attrvalue type))
                   (setq ret-attr (append ret-attr
                                          (list attrname attrvalue)))))))
      (setq ret-attr fileglobattrs)
      (dolist (attr diary-face-attrs)
        (let ((regexp (car attr))
              (regnum (cadr attr))
              (attrname (nth 2 attr))
              (type (nth 3 attr))
              (attrvalue nil))
          ;; If multiple matches, replace all, use the last (which may
          ;; be the first instance in the line, if the regexp is
          ;; anchored with $).
          (while (string-match regexp entry)
            (setq attrvalue (match-string-no-properties regnum entry)
                  entry (replace-match "" t t entry)))
          (and attrvalue
               (setq attrvalue (diary-attrtype-convert attrvalue type))
               (setq ret-attr (append ret-attr (list attrname attrvalue)))))))
    (list entry ret-attr)))