GNU bug report logs -
#62732
29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD
Previous Next
Reported by: sbaugh <at> catern.com
Date: Sun, 9 Apr 2023 01:38:02 UTC
Severity: normal
Found in version 29.0.60
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Ping again on this latest version of my patch. I have some actual
> features I'd like to add to uniquify, but they're on top of this patch.
> Plus it would be nice to land the tests added in my patch.
Sorry for not following up further, but I was waiting for a reaction to
my proposal to replace the additional arg to `create-file-buffer`
by the patch below.
If we can't avoid changing the API of `create-file-buffer`, I'd like
a comment explaining clearly why. As it stands the patch is a bit vague
about that, if not confusing:
;; FIXME we really need to fold the uniquify stuff in here by default,
-;; not using advice, and add it to the doc string.
-(defun create-file-buffer (filename)
+(defun create-file-buffer (filename &optional directory)
"Create a suitably named buffer for visiting FILENAME, and return it.
FILENAME (sans directory) is used unchanged if that name is free;
-otherwise a string <2> or <3> or ... is appended to get an unused name.
+otherwise the buffer is renamed according to
+`uniquify-buffer-name-style' to get an unused name.
Emacs treats buffers whose names begin with a space as internal buffers.
To avoid confusion when visiting a file whose name begins with a space,
-this function prepends a \"|\" to the final result if necessary."
+this function prepends a \"|\" to the final result if necessary.
+
+If DIRECTORY is non-nil, a file name separator will be added to
+the buffer name according to `uniquify-trailing-separator-p'."
Where will that separator be added? And why is the arg called `directory`?
And why/when is that arg needed, since the separator will often be
introduced anyway by uniquify even with a nil arg?
Stefan
Stefan Monnier [2023-05-05 16:30:28] wrote:
>> Ah, while I'm at it, here's a fix (based on the patch in the preceding
>> mail) for a different bug which I just noticed: create-file-buffer's
>> documentations states:
>>
>>>Emacs treats buffers whose names begin with a space as internal buffers.
>>>To avoid confusion when visiting a file whose name begins with a space,
>>>this function prepends a "|" to the final result if necessary.
>>
>> But uniquify renames the buffer away from having that "|". This patch
>> fixes that bug.
>
> How 'bout the patch below (based on the current code), instead?
>
>
> Stefan
>
>
> diff --git a/lisp/uniquify.el b/lisp/uniquify.el
> index dee9ecba2ea..c252d5461aa 100644
> --- a/lisp/uniquify.el
> +++ b/lisp/uniquify.el
> @@ -498,7 +498,7 @@ uniquify--create-file-buffer-advice
> (when uniquify-buffer-name-style
> (let ((filename (expand-file-name (directory-file-name filename))))
> (uniquify-rationalize-file-buffer-names
> - (file-name-nondirectory filename)
> + (buffer-name buf)
> (file-name-directory filename)
> buf))))
>
This bug report was last modified 1 year and 312 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.