~protesilaos/denote

Fix: Trim denote-rename-buffer to avoid "uninteresting buffers" v1 APPLIED

Vedang Manerikar: 1
 Fix: Trim denote-rename-buffer to avoid "uninteresting buffers"

 1 files changed, 9 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~protesilaos/denote/patches/46243/mbox | git am -3
Learn more about email & git

[PATCH] Fix: Trim denote-rename-buffer to avoid "uninteresting buffers" Export this patch

I hit this bug when I did the following:

1. Modify the default `denote-rename-buffer-format` from "%t" to
   "%s %t" to display signatures
2. Open a Denote file which did not have a signature.
3. Wonder why the buffer did not show up in buffer-listing functions,
   and why undo wouldn't work on it and so on.

The answer is here:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Names.html#Buffer-Names

    > Buffers that are ephemeral and generally uninteresting to the
    > user have names starting with a space, so that the list-buffers
    > and buffer-menu commands don't mention them (but if such a
    > buffer visits a file, it is mentioned). A name starting with
    > space also initially disables recording undo information; see
    > Undo.

This commit trims the Buffer Name to ensure that there are no leading
or trailing spaces.
---
 denote-rename-buffer.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/denote-rename-buffer.el b/denote-rename-buffer.el
index 3a5a0d2..03637ec 100644
--- a/denote-rename-buffer.el
+++ b/denote-rename-buffer.el
@@ -92,14 +92,15 @@ buffer will be used, if available."
  "Parse the BUFFER through the `denote-rename-buffer-format'."
  (when-let ((file (buffer-file-name buffer))
             (type (denote-filetype-heuristics file)))
    (format-spec denote-rename-buffer-format
                 (list (cons ?t (denote-retrieve-title-value file type))
                       (cons ?i (denote-retrieve-filename-identifier file))
                       (cons ?d (denote-retrieve-filename-identifier file))
                       (cons ?s (denote-retrieve-filename-signature file))
                       (cons ?k (denote-retrieve-keywords-value-as-string file type))
                       (cons ?% "%"))
                 'delete)))
    (string-trim
     (format-spec denote-rename-buffer-format
                  (list (cons ?t (denote-retrieve-title-value file type))
                        (cons ?i (denote-retrieve-filename-identifier file))
                        (cons ?d (denote-retrieve-filename-identifier file))
                        (cons ?s (denote-retrieve-filename-signature file))
                        (cons ?k (denote-retrieve-keywords-value-as-string file type))
                        (cons ?% "%"))
                  'delete))))

(defun denote-rename-buffer (&optional buffer)
  "Rename current buffer or optional BUFFER with `denote-rename-buffer-format'.
-- 
2.42.0
Hello Vedang,
I just installed the patch. Thank you!

All the best,
Prot