1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-28 10:56:36 +00:00

Merge branch 'feature/uniquify-as-function' into master

This commit is contained in:
Jimmy Aguilar Mena 2020-09-15 16:18:02 +02:00
commit ffe893114f
3 changed files with 33 additions and 5 deletions

View File

@ -697,6 +697,17 @@ forward order after the file name, as in @samp{file|top/middle}. If
@code{uniquify-buffer-name-style} is set to @code{nil}, the buffer
names simply get @samp{<2>}, @samp{<3>}, etc.@: appended.
The value of @code{uniquify-buffer-name-style} can be set to a
customized function with two arguments @var{base} and
@var{extra-strings} where @var{base} is a string and
@var{extra-strings} is a list of strings. For example the current
implementation for @code{post-forward-angle-brackets} could be:
@example
(defun my-post-forward-angle-brackets (base extra-string)
(concat base \"<\" (mapconcat #'identity extra-string \"/\") \">\"))
@end example
Which rule to follow for putting the directory names in the buffer
name is not very important if you are going to @emph{look} at the
buffer names before you type one. But as an experienced user, if you

View File

@ -1425,6 +1425,12 @@ truncating precision field, such as "%.2a".
This can be used to parse RGB color specs in several formats and
convert them to a list '(R G B)' of primary color values.
---
** Variable 'uniquify-buffer-name-style' can now be a function.
This variable can be one of the predefined styles or a function to
personalize the uniquified buffer name.
* Changes in Emacs 28.1 on Non-Free Operating Systems

View File

@ -104,6 +104,14 @@ would have the following buffer names in the various styles:
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 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."
(cond
((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"
uniquify-buffer-name-style)))))