From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh 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: Fri, 05 May 2023 17:14:56 -0400 Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1668"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: sbaugh@catern.com, 62732@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 05 23:16:17 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 1pv2mn-0000Hq-Py for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 May 2023 23:16:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pv2mb-0006pK-4n; Fri, 05 May 2023 17:16: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 1pv2mZ-0006oy-46 for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 17:16: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 1pv2mY-00027V-Sg for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 17:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pv2mY-0008Au-Bk for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 17:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 May 2023 21:16: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.168332130731324 (code B ref 62732); Fri, 05 May 2023 21:16:02 +0000 Original-Received: (at 62732) by debbugs.gnu.org; 5 May 2023 21:15:07 +0000 Original-Received: from localhost ([127.0.0.1]:57657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv2le-000897-IV for submit@debbugs.gnu.org; Fri, 05 May 2023 17:15:06 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:50197) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv2lZ-00088I-TP for 62732@debbugs.gnu.org; Fri, 05 May 2023 17:15:05 -0400 In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:13:52 -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:261146 Archived-At: Stefan Monnier writes: >> This patch takes the approach of pulling uniquify-trailing-separator-p >> out of uniquify and putting it into dired; now the trailing separator is >> specified when the dired buffer is created. This is incidentally also >> vastly more efficient: The old way did n=C2=B2 filesystem accesses which= is >> not something we should be doing on every buffer creation/rename. > > It's indeed a better approach, thanks. > I'm a bit annoyed at the need to add an argument to `create-file-buffer` > and I wonder if we could avoid that by replacing: > >> +(defun dired--create-buffer (dirname) >> + "Create a buffer with an appropriate name for visiting this directory. >> + >> +Obeys `dired-trailing-separator'." >> + (let* ((filename (directory-file-name dirname)) >> + (base (file-name-nondirectory filename))) >> + (create-file-buffer filename >> + (if dired-trailing-separator >> + (cond ((eq uniquify-buffer-name-style 'forw= ard) >> + (file-name-as-directory base)) >> + ((eq uniquify-buffer-name-style 'reverse) >> + (concat (or uniquify-separator "\\") base))= ))))) > > with > > (defun dired--create-buffer (dirname) > "Create a buffer with an appropriate name for visiting this directo= ry. > Obeys `dired-trailing-separator'." > (let* ((filename (directory-file-name dirname))) > (create-file-buffer (if dired-trailing-separator > (file-name-as-directory filename) > filename)))) > > or even just > > (defun dired--create-buffer (dirname) > "Create a buffer with an appropriate name for visiting this directo= ry." > (create-file-buffer (file-name-as-directory dirname))) > > and then do the rest inside `uniquify.el`. > > > Stefan Ah, check my most recently sent patch, I revised it a fair bit from the initial version. It still adds an argument to create-file-buffer, but I think it is a much more reasonable one. Plus it's independent of dired, so probably useful for other dired-like packages which want to create buffers which view directories, if there are any such...