[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/uniquify-as-function 5a19bd8 1/2: Enable uniquify-buffer-name-st

From: Jimmy Aguilar Mena
Subject: feature/uniquify-as-function 5a19bd8 1/2: Enable uniquify-buffer-name-style to be a function.
Date: Tue, 15 Sep 2020 07:28:41 -0400 (EDT)

branch: feature/uniquify-as-function
commit 5a19bd834ef8d33716b65cbf2c0ca93b3aa9c618
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Enable uniquify-buffer-name-style to be a function.
    * lisp/uniquify.el (uniquify-buffer-name-style) : Add "Other" custom
    (uniquify-get-proposed-name) : Add condition for when
    uniquify-buffer-name-style is a function.
 lisp/uniquify.el | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index 70e8ece..1df84cc 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -104,6 +104,14 @@ would have the following buffer names in the various 
   post-forward-angle-brackets   name<bar/mumble>   name<quux/mumble>
   nil                           name               name<2>
+The value can be set to a customized function with two mandatory
+arguments BASE and EXTRA-STRINGS where BASE is a string and
+EXTRA-STRINGS is a list of strings.  For example the current
+implementation for post-forward-angle-brackets could be:
+(defun my-post-forward-angle-brackets (base extra-string)
+  (concat base \"<\" (mapconcat 'identity extra-string \"/\") \">\"))
 The \"mumble\" part may be stripped as well, depending on the
 setting of `uniquify-strip-common-suffix'.  For more options that
 you can set, browse the `uniquify' custom group."
@@ -111,6 +119,7 @@ you can set, browse the `uniquify' custom group."
                (const reverse)
                (const post-forward)
                (const post-forward-angle-brackets)
+                (function :tag "Other")
                (const :tag "numeric suffixes" nil))
   :version "24.4"
   :require 'uniquify)
@@ -364,20 +373,22 @@ in `uniquify-list-buffers-directory-modes', otherwise 
returns nil."
      ((null extra-string) base)
      ((string-equal base "") ;Happens for dired buffers on the root directory.
-      (mapconcat 'identity extra-string "/"))
+      (mapconcat #'identity extra-string "/"))
      ((eq uniquify-buffer-name-style 'reverse)
-      (mapconcat 'identity
+      (mapconcat #'identity
                 (cons base (nreverse extra-string))
                 (or uniquify-separator "\\")))
      ((eq uniquify-buffer-name-style 'forward)
-      (mapconcat 'identity (nconc extra-string (list base))
+      (mapconcat #'identity (nconc extra-string (list base))
      ((eq uniquify-buffer-name-style 'post-forward)
       (concat base (or uniquify-separator "|")
-             (mapconcat 'identity extra-string "/")))
+             (mapconcat #'identity extra-string "/")))
      ((eq uniquify-buffer-name-style 'post-forward-angle-brackets)
-      (concat base "<" (mapconcat 'identity extra-string "/")
+      (concat base "<" (mapconcat #'identity extra-string "/")
+     ((functionp uniquify-buffer-name-style)
+      (funcall uniquify-buffer-name-style base extra-string))
      (t (error "Bad value for uniquify-buffer-name-style: %s"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]