From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD Date: Sat, 08 Jul 2023 13:48:55 -0400 Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33808"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62732@debbugs.gnu.org To: sbaugh@catern.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 08 19:50:39 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIC4r-0008bU-TM for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Jul 2023 19:50:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIC4L-0002un-AI; Sat, 08 Jul 2023 13:50:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIC4J-0002uP-4I for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 13:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIC4I-0007BA-S2 for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 13:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qIC4I-0008DJ-8B for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 13:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jul 2023 17:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62732 X-GNU-PR-Package: emacs Original-Received: via spool by 62732-submit@debbugs.gnu.org id=B62732.168883854631427 (code B ref 62732); Sat, 08 Jul 2023 17:50:02 +0000 Original-Received: (at 62732) by debbugs.gnu.org; 8 Jul 2023 17:49:06 +0000 Original-Received: from localhost ([127.0.0.1]:45139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIC3N-0008Ao-HL for submit@debbugs.gnu.org; Sat, 08 Jul 2023 13:49:05 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIC3L-0008A7-5z for 62732@debbugs.gnu.org; Sat, 08 Jul 2023 13:49:04 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 48DEF1000DC; Sat, 8 Jul 2023 13:48:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 25CA21000C3; Sat, 8 Jul 2023 13:48:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1688838536; bh=8mNWDZsc7Aoq3KY7059DU8WCj8WOT9C2EJ8dkJjuxdM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=l8pI/bpm4jm+Wng0jgJT7eQucwkL6DGWcXPfi7vvhKofzayQBwV8pfuPVeJtQiBB3 vlVaslppN98HB0XLJWBBLK3DW2WZkOXb3q0b5FDUdBkhtoNVdMLqCCRweF0O5Nehwr dMFt//f6PMoMQI1VUQgBJ3yXL8sEozqd9QOixF3c5W0SlZXgj0oGoKviEAQswBZD3s mZzpTWiH4dn9iVnDk6mPq+lCp2UOnFmM8eXVTtTqMYN5LAgtEN0mym3CN8U/5UBtA8 JgSsoDyihEb2rQtCquTEHihGJzXeXaVSYWZQBjGj46Cgfy15zx9E9lSqBflri2TjTg MTnkSUTpyMr8Q== Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 09D341203D6; Sat, 8 Jul 2023 13:48:56 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:30:28 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264783 Archived-At: > Ping again on this latest version of my patch. I have some actual > features I'd like to add to uniquify, but they're on top of this patch. > Plus it would be nice to land the tests added in my patch. Sorry for not following up further, but I was waiting for a reaction to my proposal to replace the additional arg to `create-file-buffer` by the patch below. If we can't avoid changing the API of `create-file-buffer`, I'd like a comment explaining clearly why. As it stands the patch is a bit vague about that, if not confusing: ;; FIXME we really need to fold the uniquify stuff in here by default, -;; not using advice, and add it to the doc string. -(defun create-file-buffer (filename) +(defun create-file-buffer (filename &optional directory) "Create a suitably named buffer for visiting FILENAME, and return it. FILENAME (sans directory) is used unchanged if that name is free; -otherwise a string <2> or <3> or ... is appended to get an unused name. +otherwise the buffer is renamed according to +`uniquify-buffer-name-style' to get an unused name. Emacs treats buffers whose names begin with a space as internal buffers. To avoid confusion when visiting a file whose name begins with a space, -this function prepends a \"|\" to the final result if necessary." +this function prepends a \"|\" to the final result if necessary. + +If DIRECTORY is non-nil, a file name separator will be added to +the buffer name according to `uniquify-trailing-separator-p'." Where will that separator be added? And why is the arg called `directory`? And why/when is that arg needed, since the separator will often be introduced anyway by uniquify even with a nil arg? Stefan Stefan Monnier [2023-05-05 16:30:28] wrote: >> Ah, while I'm at it, here's a fix (based on the patch in the preceding >> mail) for a different bug which I just noticed: create-file-buffer's >> documentations states: >> >>>Emacs treats buffers whose names begin with a space as internal buffers. >>>To avoid confusion when visiting a file whose name begins with a space, >>>this function prepends a "|" to the final result if necessary. >> >> But uniquify renames the buffer away from having that "|". This patch >> fixes that bug. > > How 'bout the patch below (based on the current code), instead? > > > Stefan > > > diff --git a/lisp/uniquify.el b/lisp/uniquify.el > index dee9ecba2ea..c252d5461aa 100644 > --- a/lisp/uniquify.el > +++ b/lisp/uniquify.el > @@ -498,7 +498,7 @@ uniquify--create-file-buffer-advice > (when uniquify-buffer-name-style > (let ((filename (expand-file-name (directory-file-name filename)))) > (uniquify-rationalize-file-buffer-names > - (file-name-nondirectory filename) > + (buffer-name buf) > (file-name-directory filename) > buf)))) >