Subject: [PATCH] 'uniquify' user option setters and automatic buffer refresh
From: Ship Mints <[email-masked]>
To: [email-masked]
Date: Fri, 21 Mar 2025 14:11:01 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Okay, here's a fun one that's been on my list for a while that other people
might find useful.  When I have a lot of buffers open, I occasionally want
to increase or decrease uniquify-min-dir-content to make it easier to
discern, with higher precision, one buffer from another with the same name,
and without reloading buffers...

Changing uniquify user options refreshes buffer names.

Use customize interactively, or setopt in Elisp, to refresh buffer names
when changing 'uniquify' user options.  Previously, reloading or renaming
your buffers (or an Emacs restart) was required.

e.g., (setopt uniquify-min-dir-content 2)

In my init file, I have the following which makes this convenient:

  (defun my/uniquify-dir-content-cycle ()
    (interactive)
    (if uniquify-buffer-name-style
        (progn
          (pcase uniquify-min-dir-content
            (0 (setopt uniquify-min-dir-content 1))
            (1 (setopt uniquify-min-dir-content 2))
            (2 (setopt uniquify-min-dir-content 0)))
          (setopt uniquify-strip-common-suffix (= 0
uniquify-min-dir-content))
          (when (< emacs-major-version 31) ; Hopefully deprecated!
            (my/uniquify-refresh)))
      (message "No `uniquify-buffer-name-style' defined")))

-Stephane