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

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

Signature

(denote--define-retrieve-front-matter-from-content 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
;; These are private front matter retrieval functions, working with a content parameter

(defmacro denote--define-retrieve-front-matter-from-content (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-from-content" component scope)) (content file-type)
     (when file-type
       (with-temp-buffer
         (insert content)
         (goto-char (point-min))
         (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))))))))