GNU bug report logs - #62732
29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD

Previous Next

Package: emacs;

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

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sbaugh <at> catern.com, 62732 <at> debbugs.gnu.org
Subject: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD
Date: Fri, 05 May 2023 17:14:56 -0400
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> This patch takes the approach of pulling uniquify-trailing-separator-p
>> out of uniquify and putting it into dired; now the trailing separator is
>> specified when the dired buffer is created.  This is incidentally also
>> vastly more efficient: The old way did n² filesystem accesses which is
>> not something we should be doing on every buffer creation/rename.
>
> It's indeed a better approach, thanks.
> I'm a bit annoyed at the need to add an argument to `create-file-buffer`
> and I wonder if we could avoid that by replacing:
>
>> +(defun dired--create-buffer (dirname)
>> +  "Create a buffer with an appropriate name for visiting this directory.
>> +
>> +Obeys `dired-trailing-separator'."
>> +  (let* ((filename (directory-file-name dirname))
>> +         (base (file-name-nondirectory filename)))
>> +    (create-file-buffer filename
>> +                        (if dired-trailing-separator
>> +                            (cond ((eq uniquify-buffer-name-style 'forward)
>> +	                           (file-name-as-directory base))
>> +	                          ((eq uniquify-buffer-name-style 'reverse)
>> +	                           (concat (or uniquify-separator "\\") base)))))))
>
> with
>
>     (defun dired--create-buffer (dirname)
>       "Create a buffer with an appropriate name for visiting this directory.
>     Obeys `dired-trailing-separator'."
>       (let* ((filename (directory-file-name dirname)))
>         (create-file-buffer (if dired-trailing-separator
>                                 (file-name-as-directory filename)
>                               filename))))
>
> or even just
>
>     (defun dired--create-buffer (dirname)
>       "Create a buffer with an appropriate name for visiting this directory."
>       (create-file-buffer (file-name-as-directory dirname)))
>
> and then do the rest inside `uniquify.el`.
>
>
>         Stefan

Ah, check my most recently sent patch, I revised it a fair bit from the
initial version.  It still adds an argument to create-file-buffer, but I
think it is a much more reasonable one.  Plus it's independent of dired,
so probably useful for other dired-like packages which want to create
buffers which view directories, if there are any such...




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.