GNU bug report logs - #77312
[PATCH] Add uniquify-get-unique-names

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Thu, 27 Mar 2025 15:04:03 UTC

Severity: normal

Tags: patch

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: sbaugh <at> janestreet.com, 77312 <at> debbugs.gnu.org, mail <at> daniel-mendler.de
Subject: bug#77312: [PATCH] Add uniquify-get-unique-names
Date: Fri, 20 Jun 2025 10:22:45 +0300
> Cc: 77312 <at> debbugs.gnu.org
> Date: Fri, 20 Jun 2025 06:08:12 +0300
> From: Dmitry Gutov <dmitry <at> gutov.dev>
> 
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 5cf9a68a294..0471daa55b7 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1580,7 +1580,14 @@ project--read-project-buffer
>                     uniquify-buffer-name-style)
>                ;; Forgo the use of `buffer-read-function' (often nil) in
>                ;; favor of uniquifying the buffers better.
> -              (let* ((unique-names (uniquify-get-unique-names buffers))
> +              (let* ((unique-names
> +                      (mapcar
> +                       (lambda (name)
> +                         (cons name
> +                               (and name
> +                                    (get-text-property 0 'uniquify-orig-buffer-name
> +                                                       name))))
> +                       (uniquify-get-unique-names buffers)))
>                       (other-name (when (funcall predicate (cons other-name other-buffer))
>                                     (car (rassoc other-buffer unique-names))))
>                       (result (completing-read
> diff --git a/lisp/uniquify.el b/lisp/uniquify.el
> index 6e25323bf5a..67cf346d204 100644
> --- a/lisp/uniquify.el
> +++ b/lisp/uniquify.el
> @@ -517,10 +517,11 @@ uniquify--stateless-curname
>    "The current unique name of this buffer in `uniquify-get-unique-names'.")
>  
>  (defun uniquify-get-unique-names (buffers)
> -  "Return an alist with a unique name for each buffer in BUFFERS.
> +  "Return a list with unique names for buffers in BUFFERS.
>  
>  The names are unique only among BUFFERS, and may conflict with other
> -buffers not in that list.
> +buffers not in that list.  Each string has a text property
> +`uniquify-orig-buffer-name' that stores the corresponding buffer.
>  
>  This does not rename the buffers or change any state; the unique name is
>  only present in the returned alist."
> @@ -547,8 +548,11 @@ uniquify-get-unique-names
>           (gethash name buffer-names)))))
>    (mapcar (lambda (buf)
>              (with-current-buffer buf
> -              (prog1 (cons uniquify--stateless-curname buf)
> -                (kill-local-variable 'uniquify--stateless-curname))))
> +              (let ((name (copy-sequence uniquify--stateless-curname)))
> +                (when name
> +                  (put-text-property 0 1 'uniquify-orig-buffer-name buf name))
> +                (kill-local-variable 'uniquify--stateless-curname)
> +                name)))
>            buffers))
>  
>  ;;; Hooks from the rest of Emacs

If you decide to install this, please be sure to document this special
text property in the ELisp manual.

Thanks.




This bug report was last modified 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.