Subject: bug#74709: closed (Re: bug#74709: [PATCH] Avoid empty unique qualifier in buffer name)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 21 Dec 2024 09:12:02 +0000

Your bug report

#74709: [PATCH] Avoid empty unique qualifier in buffer name

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74709: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74709
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74709: [PATCH] Avoid empty unique qualifier in buffer name
From: Eli Zaretskii <[email-masked]>
To: Manuel Giraud <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 21 Dec 2024 11:11:36 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked]
> Date: Sat, 07 Dec 2024 11:04:14 +0100
> From:  Manuel Giraud via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> Visuwesh <[email-masked]> writes:
> 
> > [வெள்ளி டிசம்பர் 06, 2024] Manuel Giraud wrote:
> >
> >> Visuwesh <[email-masked]> writes:
> >>
> >>> [வெள்ளி டிசம்பர் 06, 2024] Manuel Giraud via "Bug reports for GNU Emacs,
> >>> the Swiss army knife of text editors" wrote:
> >>>
> >>>> Tags: patch
> >>>>
> >>>> Hi,
> >>>>
> >>>> This patch prevents from having an empty unique qualifier in the buffer
> >>>> name.  Maybe this could happen with others file buffer as well but, most
> >>>> of the time, you could witness it with Dired buffer in homedir.  Here is
> >>>> a recipe:
> >>>>
> >>>>   - emacs -Q
> >>>>   - C-x d /ssh:somewhere: ;; This buffer is named "~</ssh:somewhere:>"
> >>>>   - C-x d /~/             ;; This buffer is named "~<>"
> >>>>
> >>>> With this patch, the last buffer will simply be named "~" instead.
> >>>
> >>> I usually have ~/tmp visited in a Dired buffer.  Sometimes I also visit
> >>> /tmp which gets named as "tmp<>".  With this patch, /tmp's buffer is
> >>> named "tmp" instead.  This confuses me as I am used to seeing "tmp" for
> >>> ~/tmp's Dired buffer more often than not.  Can we gate this new
> >>> behaviour behind a user option please?
> >>
> >> I don't think that there is more confusion then if you only have /tmp
> >> opened which will have its buffer named "tmp", no?
> >
> > Sorry, I meant having /tmp being "tmp" when both ~/tmp and /tmp are open
> > is confusing for the aforementioned reason.
> 
> Yes, you're right.  Thinking a bit more about it, I don't think this
> patch was a good idea anymore.  When a buffer is named "tmp<>" it
> conveys the information that there is another buffer with the same base
> name.  If it is just named "tmp", we have lost this bit of information.

Thanks.  Since there were no further comments withing 2 weeks, I'm now
closing this bug.

Subject: [PATCH] Avoid empty unique qualifier in buffer name
From: Manuel Giraud <[email-masked]>
To: [email-masked]
Date: Fri, 06 Dec 2024 13:17:31 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Hi,

This patch prevents from having an empty unique qualifier in the buffer
name.  Maybe this could happen with others file buffer as well but, most
of the time, you could witness it with Dired buffer in homedir.  Here is
a recipe:

  - emacs -Q
  - C-x d /ssh:somewhere: ;; This buffer is named "~</ssh:somewhere:>"
  - C-x d /~/             ;; This buffer is named "~<>"

With this patch, the last buffer will simply be named "~" instead.

In GNU Emacs 31.0.50 (build 26, x86_64-unknown-openbsd7.6, X toolkit) of
 2024-12-06 built on computer
Repository revision: 2c1dfba7feb67c39299da0579a2be7ff14e13ccb
Repository branch: mgi/unique
Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
System Description: OpenBSD computer 7.6 GENERIC.MP#458 amd64

Configured using:
 'configure CC=egcc CPPFLAGS=-I/usr/local/include
 LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs
 --bindir=/home/manuel/bin --with-x-toolkit=lucid
 --with-toolkit-scroll-bars=no --without-cairo
 --without-compress-install'

>From 70b7e0afe02669df44fd719c2ab35561b565f2df Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Fri, 6 Dec 2024 12:01:29 +0100
Subject: [PATCH] Avoid empty unique qualifier in buffer name

* lisp/uniquify.el (uniquify-get-proposed-name): If the unique
qualifier will end up being empty just return the base name.
---
 lisp/uniquify.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index efe42762a6b..677270d6a91 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -397,7 +397,10 @@ uniquify-get-proposed-name
       (setq uniquify-possibly-resolvable t))
 
     (cond
-     ((null extra-string) base)
+     ((or (null extra-string)
+          (and (= 1 (length extra-string))
+               (string= "" (car extra-string))))
+      base)
      ((string-equal base "") ;Happens for dired buffers on the root directory.
       (mapconcat #'identity extra-string "/"))
      ((eq uniquify-buffer-name-style 'reverse)
-- 
2.47.0

-- 
Manuel Giraud