GNU bug report logs - #47132
28.0.50; [PATCH] Uniquify: trailing-separator-p + strip-common-suffix

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47132 in the body.
You can then email your comments to 47132 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47132; Package emacs. (Sun, 14 Mar 2021 06:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gabriel <gabriel376 <at> hotmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 Mar 2021 06:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gabriel <gabriel376 <at> hotmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; [PATCH] Uniquify: trailing-separator-p + strip-common-suffix
Date: Sun, 14 Mar 2021 02:50:06 -0300
[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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47132; Package emacs. (Thu, 18 Mar 2021 06:56:01 GMT) Full text and rfc822 format available.

Message #8 received at 47132 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Gabriel <gabriel376 <at> hotmail.com>
Cc: 47132 <at> debbugs.gnu.org
Subject: Re: bug#47132: 28.0.50; [PATCH] Uniquify: trailing-separator-p +
 strip-common-suffix
Date: Thu, 18 Mar 2021 07:55:22 +0100
Gabriel <gabriel376 <at> hotmail.com> writes:

> 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.

Your patch fixes the problem here, too, so I've applied it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 18 Mar 2021 06:56:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47132 <at> debbugs.gnu.org and Gabriel <gabriel376 <at> hotmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 18 Mar 2021 06:56:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Apr 2021 11:24:07 GMT) Full text and rfc822 format available.

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.