Function: denote--define-retrieve-front-matter

denote--define-retrieve-front-matter is a macro defined in denote.el.

Signature

(denote--define-retrieve-front-matter COMPONENT SCOPE)

Documentation

Define a function to retrieve front matter for COMPONENT given SCOPE.

The COMPONENT is one of the file name components that has a corresponding front matter entry. SCOPE is a symbol of either value or line, referring to what the function should retrieve.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defmacro denote--define-retrieve-front-matter (component scope)
  "Define a function to retrieve front matter for COMPONENT given SCOPE.
The COMPONENT is one of the file name components that has a
corresponding front matter entry.  SCOPE is a symbol of either `value'
or `line', referring to what the function should retrieve."
  (declare (indent 1))
  `(defun ,(intern (format "denote-retrieve-front-matter-%s-%s" component scope)) (file file-type)
     (when file-type
       (denote--file-with-temp-buffer file
         (when (re-search-forward (,(intern (format "denote--%s-key-regexp" component)) file-type) nil t 1)
           ,(cond
             ((eq scope 'value)
              `(funcall (,(intern (format "denote--%s-value-reverse-function" component)) file-type)
                        (buffer-substring-no-properties (point) (line-end-position))))
             ((eq scope 'line)
              '(buffer-substring-no-properties (line-beginning-position) (line-end-position)))
             (t (error "`%s' is not a known scope" scope))))))))