~protesilaos/denote

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

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

Details
Message ID
<20231030170704.58919-1-ved.manerikar@gmail.com>
DKIM signature
missing
Download raw message
Patch: +9 -8
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
Details
Message ID
<87fs1od6rh.fsf@protesilaos.com>
In-Reply-To
<20231030170704.58919-1-ved.manerikar@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Hello Vedang,

> From: Vedang Manerikar <ved.manerikar@gmail.com>
> Date: Mon, 30 Oct 2023 22:37:04 +0530

> [... 21 lines elided]

> ---
>  denote-rename-buffer.el | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)

> [... 29 lines elided]

I just installed the patch. Thank you!

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)