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: Sun, 09 Jul 2023 22:04:54 -0400 Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.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="33137"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: sbaugh@catern.com, 62732@debbugs.gnu.org To: "Eli Zaretskii" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 10 04:06:22 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 1qIgI9-0008Qt-S2 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Jul 2023 04:06:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIgHu-0006Hn-E5; Sun, 09 Jul 2023 22:06:06 -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 1qIgHr-0006H9-MW for bug-gnu-emacs@gnu.org; Sun, 09 Jul 2023 22:06:05 -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 1qIgHq-00079i-3S for bug-gnu-emacs@gnu.org; Sun, 09 Jul 2023 22:06:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qIgHp-000355-V9 for bug-gnu-emacs@gnu.org; Sun, 09 Jul 2023 22:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jul 2023 02:06:01 +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.168895470511776 (code B ref 62732); Mon, 10 Jul 2023 02:06:01 +0000 Original-Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 02:05:05 +0000 Original-Received: from localhost ([127.0.0.1]:47319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIgGv-00033s-0j for submit@debbugs.gnu.org; Sun, 09 Jul 2023 22:05:05 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIgGr-00033H-Sn for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 22:05:04 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 705028017D; Sun, 9 Jul 2023 22:04:56 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4DC5B801B3; Sun, 9 Jul 2023 22:04:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1688954695; bh=FZOnu4DDrdUn4wptY2BMg1yxDcWLJwwpdyW69leH1T0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nSlTKeC9Nfr06YtHGzy/DitQPCn4wyIiAwAqFS/hzL3ZNrzXqwvbNKNRtfSKt3KWB vXDyXUEmhDVPVQ+IEW7Nj869jY9uo1xcVII2kdmOBItS1gmDS/+ynaXProrqhIrSGG Lmw+t1NWFg7ux2isHUraY1VNo/yMnr3bvjltMly/CvuWbc0Hgy+qA32UiLUo7G0aZB oFRzB+6lP9PXp5TP+CHopJGtZseMTZWksZzjTx5EQ+HSaadXTHE7RpSKiHVqDLf/Hz aSHlufpVkRS4bEwNDtPjVIYcbv0wsW51erYpathqkd5nbMEQSGI4emVhSYeazW0vxe tJgnJe3ZdGoBg== Original-Received: from pastel (unknown [24.140.234.50]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2275F1201E4; Sun, 9 Jul 2023 22:04:55 -0400 (EDT) In-Reply-To: <87o7kklf9c.fsf@catern.com> (sbaugh@catern.com's message of "Mon, 10 Jul 2023 01:36:00 +0000 (UTC)") 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:264867 Archived-At: >>> This inspired me to do something not exactly this but which also gets >>> rid of the new argument to create-file-buffer. How about this: >> >> Now you're talking! :-) >> LGTM! Thank you very much, > > Great! Here's that as a complete patch again. Eli, OK to install on `master`? Stefan PS: Nitpicks: > + (let* ((lastname (if (directory-name-p filename) > + (file-name-nondirectory (directory-file-name filename)) > + (file-name-nondirectory filename))) Aka (let* ((lastname (file-name-nondirectory (if (directory-name-p filename) (directory-file-name filename) filename))) or even just (let* ((lastname (file-name-nondirectory (directory-file-name filename))) > + (lastname (if (and (directory-name-p filename) uniquify-trailing-separator-p) > + (cond ((eq uniquify-buffer-name-style 'forward) > + (file-name-as-directory lastname)) > + ((eq uniquify-buffer-name-style 'reverse) > + (concat (or uniquify-separator "\\") lastname)) > + (t lastname)) > + lastname)) Here you can merge the `if` into the `cond` and I'd test `uniquify-trailing-separator-p` first (cheaper and nil by default) and since we know (directory-name-p filename), I'd be tempted to replace (file-name-as-directory lastname) with just `filename`. Also I'd argue that when `uniquify-trailing-separator-p` and (directory-name-p filename) are both true we never want to use just `lastname` so the default should be to return `filename`: (lastname (cond ((not (and uniquify-trailing-separator-p (directory-name-p filename))) lastname) ((eq uniquify-buffer-name-style 'reverse) (concat (or uniquify-separator "\\") lastname)) (t filename))) so for `post-forward` (my personal favorite) /foo/bar/mumble/name/ would turn into name/|bar/mumble. WDYT? Stefan