; Documentation followup to last change

* lisp/progmodes/project.el (project-uniquify-dirname-transform):
* lisp/uniquify.el (uniquify-dirname-transform): Doc fixes.

* etc/NEWS: Announce the change.
This commit is contained in:
Eli Zaretskii 2023-07-26 18:11:49 +03:00
parent 2aec67f4de
commit 6572dcc7f5
3 changed files with 30 additions and 20 deletions

View file

@ -102,6 +102,15 @@ plus, minus, check-mark, start, etc.
The 'tool-bar-position' frame parameter can be set to 'bottom' on all
window systems other than Nextstep.
---
** New user option 'uniquify-dirname-transform'.
This can be used to customize how buffer names are uniquified, by
making arbitrary transforms on the buffer's directory name (whose
components are used to uniquify buffer names when they clash). You
can use this to distinguish between buffers visiting files with the
same base name that belong to different projects by using the provided
transform function 'project-uniquify-dirname-transform'.
** cl-print
*** You can expand the "..." truncation everywhere.

View file

@ -1889,12 +1889,12 @@ to directory DIR."
;;;###autoload
(defun project-uniquify-dirname-transform (dirname)
"Include `project-name' in DIRNAME if in a project.
"Uniquify name of directory DIRNAME using `project-name', if in a project.
If you set `uniquify-dirname-transform' to this function,
slash-separated components from `project-name' will be added to
the buffer's name when buffers from two different projects would
otherwise have the same name."
slash-separated components from `project-name' will be appended to
the buffer's directory name when buffers from two different projects
would otherwise have the same name."
(if-let (proj (project-current nil dirname))
(let ((root (project-root proj)))
(expand-file-name

View file

@ -169,25 +169,26 @@ That means that when `buffer-file-name' is set to nil, `list-buffers-directory'
contains the name of the directory which the buffer is visiting.")
(defcustom uniquify-dirname-transform #'identity
"Function to transform buffer's directory for uniquifying its name.
"Function to transform buffer's directory name when uniquifying buffer's name.
If `uniquify-buffer-name-style' is non-nil and a buffer's name
would be the same as some other buffer, then components from the
buffer's directory name are added to the buffer's name until the
buffer's name is unique.
When `uniquify-buffer-name-style' is non-nil, Emacs makes buffer
names unique by adding components of the buffer's directory name
until the resulting name is unique. This function is used to
transform the buffer's directory name during this uniquifying
process, allowing the unique buffer name to include strings
from sources other than the buffer's directory. The default is
`identity', so the unmodified buffer's directory name is used for
uniquifying.
This function is used to transform the buffer's directory name
before the uniquifying process, allowing the unique buffer name
to include components from other sources. The default is
`identity', so only the buffer's directory name is used for
uniquifying. This function is called with the buffer's directory
name and should return a file name (which does not need to
actually exist in the filesystem) to use components from.
This function is called with the buffer's directory name and
should return a string which names a file (that does not need to
actually exist in the filesystem); the components of this file
name will then be used to uniquify the buffer's name.
To include components from `project-name', set this variable to
`project-uniquify-dirname-transform'."
:type '(choice (function-item :tag "Don't change the dirname" identity)
(function-item :tag "Include project name in dirname"
To include components from the `project-name' of the buffer, set
this variable to `project-uniquify-dirname-transform'."
:type '(choice (function-item :tag "Use directory name as-is" identity)
(function-item :tag "Include project name in directory name"
#'project-uniquify-dirname-transform)
function)
:version "30.1"