Function: denote-rename-buffer--format

denote-rename-buffer--format is a byte-compiled function defined in denote.el.

Signature

(denote-rename-buffer--format BUFFER)

Documentation

Parse the BUFFER through the denote-rename-buffer-format.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-rename-buffer--format (buffer)
  "Parse the BUFFER through the `denote-rename-buffer-format'."
  (when-let* ((file (buffer-file-name buffer)))
    (let ((type (denote-filetype-heuristics file))
          (should-show-backlink-indicator (and ; only do search if format contains "%b"
                                           (string-match-p "%b" denote-rename-buffer-format)
                                           (denote--file-has-backlinks-p file))))
      (string-trim
       (format-spec denote-rename-buffer-format
                    (list (cons ?t (cond
                                    ((denote-retrieve-front-matter-title-value file type))
                                    ((denote-retrieve-filename-title file))
                                    (t  "")))
                          (cons ?T (or (denote-retrieve-filename-title file) ""))
                          (cons ?b (if should-show-backlink-indicator denote-rename-buffer-backlinks-indicator ""))
                          (cons ?i (or (denote-retrieve-filename-identifier file) ""))
                          ;; TODO 2025-04-03: Maybe we can have something like `denote-date-format' here,
                          ;; but I think we are okay with a hardcoded value.
                          (cons ?I (or (when-let* ((id (denote-retrieve-filename-identifier file))
                                                   (_ (denote-date-identifier-p id)))
                                         (format-time-string "%A, %e %B %Y" (date-to-time (denote-id-to-date id))))
                                       ""))
                          (cons ?d (or (denote-retrieve-filename-identifier file) ""))
                          (cons ?D (cond
                                    ((denote-retrieve-front-matter-title-value file type))
                                    ((denote-retrieve-filename-title file))
                                    ((when-let* ((id (denote-retrieve-filename-identifier file)))
                                       (if (denote-date-identifier-p id)
                                           (format-time-string "%A, %e %B %Y" (date-to-time (denote-id-to-date id)))
                                         id)))
                                    (t  "")))
                          (cons ?s (or (denote-retrieve-filename-signature file) ""))
                          (cons ?k (or (denote-retrieve-filename-keywords file) ""))
                          (cons ?% "%"))
                    'delete)))))