unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56693: 29.0.50; write-file does not respect uniquify.el
@ 2022-07-22  5:30 Gabriel
  2022-07-23  6:30 ` Lars Ingebrigtsen
  2022-08-16 21:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 4+ messages in thread
From: Gabriel @ 2022-07-22  5:30 UTC (permalink / raw)
  To: 56693

Description:
The `write-file' command (C-x C-w) does not respect `uniquify.el'.

Steps to reproduce (correct case):
1) emacs -Q
2) eval (setopt uniquify-buffer-name-style 'forward)
3) C-x C-f "~/tmp/a/x"
4) C-x C-f "~/tmp/b/x"
5) The buffers are renamed are expected: "a/x" and "b/x"

Steps to reproduce (bug case):
1) emacs -Q
2) eval (setopt uniquify-buffer-name-style 'forward)
3) C-x C-f "~/tmp/a/x"
4) C-x C-f "~/tmp/b/y"
5) C-x C-w "~/tmp/b/x"
6) The buffers are not named correctly: "x" and "x<2>"

I did not have time to look deep into this problem, but the following
patch seems to work as expected:
From 3e2ef93862ad13650854a34982c320aaafbf2b6f Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Fri, 22 Jul 2022 01:14:11 -0300
Subject: [PATCH 1/1] * files.el (set-visited-file-name): Respect uniquify.el

---
 lisp/files.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index bc74dfa738..2051cc0f95 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4714,7 +4714,7 @@ set-visited-file-name
          ;; If new-name == old-name, renaming would add a spurious <2>
          ;; and it's considered as a feature in rename-buffer.
          (or (string= new-name (buffer-name))
-             (rename-buffer new-name t))))
+             (uniquify--rename-buffer-advice new-name t))))
     (setq buffer-backed-up nil)
     (or along-with-file
        (clear-visited-file-modtime))
--
2.34.1

But it seems to be an unnecessary change, since `rename-bufer' calls
`uniquify--rename-buffer-advice'. The root-cause might be related to
`rename-buffer' passing the result of `generate-new-buffer-name' (that
generates "x<2>") to `uniquify--rename-buffer-advice'.

---
Gabriel


In GNU Emacs 29.0.50 (build 27, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2022-07-21 built on 4BQPCJ3
Repository revision: 46e07d0a4bdb19b0aed26917227d7846bdb0f43c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04 LTS





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#56693: 29.0.50; write-file does not respect uniquify.el
  2022-07-22  5:30 bug#56693: 29.0.50; write-file does not respect uniquify.el Gabriel
@ 2022-07-23  6:30 ` Lars Ingebrigtsen
  2022-08-16 21:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  6:30 UTC (permalink / raw)
  To: Gabriel; +Cc: Stefan Monnier, 56693

Gabriel <gabriel376@hotmail.com> writes:

> But it seems to be an unnecessary change, since `rename-bufer' calls
> `uniquify--rename-buffer-advice'. The root-cause might be related to
> `rename-buffer' passing the result of `generate-new-buffer-name' (that
> generates "x<2>") to `uniquify--rename-buffer-advice'.

The code in rename-buffer was added in:

commit 1a724cc2d2e7f08b9fcad569c8cacf126ad55791
Author:     Stefan Monnier <monnier@iro.umontreal.ca>
AuthorDate: Mon Dec 27 19:47:23 2021 -0500

I've added Stefan to the CCs; perhaps he has some comments here.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#56693: 29.0.50; write-file does not respect uniquify.el
  2022-07-22  5:30 bug#56693: 29.0.50; write-file does not respect uniquify.el Gabriel
  2022-07-23  6:30 ` Lars Ingebrigtsen
@ 2022-08-16 21:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-14 15:27   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-08-16 21:31 UTC (permalink / raw)
  To: Gabriel; +Cc: 56693

> Steps to reproduce (bug case):
> 1) emacs -Q
> 2) eval (setopt uniquify-buffer-name-style 'forward)
> 3) C-x C-f "~/tmp/a/x"
> 4) C-x C-f "~/tmp/b/y"
> 5) C-x C-w "~/tmp/b/x"
> 6) The buffers are not named correctly: "x" and "x<2>"

Hmm... indeed.

>           (or (string= new-name (buffer-name))
> -             (rename-buffer new-name t))))
> +             (uniquify--rename-buffer-advice new-name t))))

That's an OK workaround, yes.

> But it seems to be an unnecessary change, since `rename-bufer' calls
> `uniquify--rename-buffer-advice'. The root-cause might be related to
> `rename-buffer' passing the result of `generate-new-buffer-name' (that
> generates "x<2>") to `uniquify--rename-buffer-advice'.

Exactly.
I installed the corresponding change, so it should be fixed on `master`.
Thanks,


        Stefan


diff --git a/src/buffer.c b/src/buffer.c
index 98066a2eb60..0d553e7e2d1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1563,7 +1563,8 @@ DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
   (register Lisp_Object newname, Lisp_Object unique)
 {
   register Lisp_Object tem, buf;
-
+  Lisp_Object requestedname = newname;
+
   CHECK_STRING (newname);
 
   if (SCHARS (newname) == 0)
@@ -1599,7 +1601,7 @@ DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
   run_buffer_list_update_hook (current_buffer);
 
   call2 (intern ("uniquify--rename-buffer-advice"),
-         BVAR (current_buffer, name), unique);
+         requestedname, unique);
 
   /* Refetch since that last call may have done GC.  */
   return BVAR (current_buffer, name);






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#56693: 29.0.50; write-file does not respect uniquify.el
  2022-08-16 21:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-14 15:27   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-14 15:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Gabriel, 56693

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> I installed the corresponding change, so it should be fixed on `master`.

Thanks; and I'm therefore closing this bug report now.

(If there are still problems in this area, please respond to the debbugs
address and we'll reopen.)





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-14 15:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  5:30 bug#56693: 29.0.50; write-file does not respect uniquify.el Gabriel
2022-07-23  6:30 ` Lars Ingebrigtsen
2022-08-16 21:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-14 15:27   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).