GNU bug report logs -
#47132
28.0.50; [PATCH] Uniquify: trailing-separator-p + strip-common-suffix
Previous Next
Reported by: Gabriel <gabriel376 <at> hotmail.com>
Date: Sun, 14 Mar 2021 06:06:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
A possible bug exists on uniquify.el when 'uniquify-strip-common-suffix'
and 'uniquify-trailing-separator-p' are both set to true.
Case 1: when 'uniquify-strip-common-suffix' is t and
'uniquify-trailing-separator-p' is nil
1. emacs -Q
2. Configure uniquify:
(setq-default uniquify-buffer-name-style 'forward
uniquify-strip-common-suffix t
uniquify-trailing-separator-p nil)
3. Open two similar dired buffers, e.g.:
C-x C-f "~/A/gnu/emacs/lisp" RET
C-x C-f "~/B/gnu/emacs/lisp" RET
4. The buffers will be renamed to 'A/lisp' and 'B/lisp' as expected,
because 'uniquify-strip-common-suffix' is true and
'uniquify-trailing-separator-p' is nil
Case 2: when 'uniquify-strip-common-suffix' is nil and
'uniquify-trailing-separator-p' is t
1. emacs -Q
2. Configure uniquify:
(setq-default uniquify-buffer-name-style 'forward
uniquify-strip-common-suffix nil
uniquify-trailing-separator-p t)
3. Open two similar dired buffers, e.g.:
C-x C-f "~/A/gnu/emacs/lisp" RET
C-x C-f "~/B/gnu/emacs/lisp" RET
4. The buffers will be renamed to 'A/gnu/emacs/lisp/' and
'B/gnu/emacs/lisp/' as expected, because 'uniquify-strip-common-suffix' is nil and
'uniquify-trailing-separator-p' is true
Case 3: when 'uniquify-strip-common-suffix' is t and
'uniquify-trailing-separator-p' is t
1. emacs -Q
2. Configure uniquify:
(setq-default uniquify-buffer-name-style 'forward
uniquify-strip-common-suffix t
uniquify-trailing-separator-p t)
3. Open two similar dired buffers, e.g.:
C-x C-f "~/A/gnu/emacs/lisp" RET
C-x C-f "~/B/gnu/emacs/lisp" RET
4. The buffers will be renamed to 'A/lisp' and 'B/lisp'. The common
suffix was removed as expected, but the trailing separator is missing
Cause: It seems that the following verification on 'uniquify-get-proposed-name'
fails because dirname is not the true dirname, but the one with the
common suffix stripped. Thus, 'file-directory-p' fails to find the
directory:
;; Distinguish directories by adding extra separator.
(if (and uniquify-trailing-separator-p
(file-directory-p (expand-file-name base dirname)) ;; <-- HERE
(not (string-equal base "")))
(cond ((eq uniquify-buffer-name-style 'forward)
(setq base (file-name-as-directory base)))
;; (setq base (concat base "/")))
((eq uniquify-buffer-name-style 'reverse)
(setq base (concat (or uniquify-separator "\\") base)))))
The dirname on the line above is '~/A' and '~/B' for each invocation
(common suffix was stripped), so 'expand-file-name' expands to
'~/A/lisp' and '~/B/lisp' and 'file-directory-p' fails to find it. The
function that removes the common suffix is 'uniquify-rationalize'.
I managed to create a patch where the original dirname is preserved in
the 'uniquify-item' struct and passed along as an optional argument, so
'uniquify-get-proposed-name' can properly verify if the directory
exists.
[0001-Make-uniquify-trailing-separator-p-work-with-uniquif.patch (text/x-diff, attachment)]
This bug report was last modified 4 years and 122 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.