Function: denote--get-front-matter-rewrite-prompt

denote--get-front-matter-rewrite-prompt is a byte-compiled function defined in denote.el.

Signature

(denote--get-front-matter-rewrite-prompt FINAL-COMPONENTS TO-ADD TO-REMOVE TO-MODIFY OLD-AND-NEW-FRONT-MATTER-LINES)

Documentation

Return the prompt for the front matter rewrite operation.

FINAL-COMPONENTS is the list of components to handle at the end of the rewrite operation.

TO-ADD, TO-REMOVE, and TO-MODIFY are the list of components that needs to be added, removed or modified.

OLD-AND-NEW-FRONT-MATTER-LINES is an alist containing the old and new front matter lines.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote--get-front-matter-rewrite-prompt (final-components to-add to-remove to-modify old-and-new-front-matter-lines)
  "Return the prompt for the front matter rewrite operation.

FINAL-COMPONENTS is the list of components to handle at the end of the
rewrite operation.

TO-ADD, TO-REMOVE, and TO-MODIFY are the list of components that needs
to be added, removed or modified.

OLD-AND-NEW-FRONT-MATTER-LINES is an alist containing the old and new
front matter lines."
  (let ((prompt "Replace front matter?"))
    (dolist (component final-components)
      (let ((old-line (alist-get 'old (alist-get component old-and-new-front-matter-lines)))
            (new-line (alist-get 'new (alist-get component old-and-new-front-matter-lines)))
            (next-prompt ""))
        (cond ((memq component to-remove)
               (setq next-prompt (format "\n-%s\n"
                                         (propertize (denote-trim-whitespace old-line) 'face 'denote-faces-prompt-old-name))))
              ((memq component to-add)
               (setq next-prompt (format "\n-%s\n"
                                         (propertize (denote-trim-whitespace new-line) 'face 'denote-faces-prompt-new-name))))
              ((memq component to-modify)
               (setq next-prompt (format "\n-%s\n-%s\n"
                                         (propertize (denote-trim-whitespace old-line) 'face 'denote-faces-prompt-old-name)
                                         (propertize (denote-trim-whitespace new-line) 'face 'denote-faces-prompt-new-name)))))
        (setq prompt (concat prompt next-prompt))))
    (concat prompt "?")))