From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 08 21:37:51 2023 Received: (at submit) by debbugs.gnu.org; 9 Apr 2023 01:37:51 +0000 Received: from localhost ([127.0.0.1]:59942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plK06-00080p-6j for submit@debbugs.gnu.org; Sat, 08 Apr 2023 21:37:50 -0400 Received: from lists.gnu.org ([209.51.188.17]:42058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plK04-00080h-6i for submit@debbugs.gnu.org; Sat, 08 Apr 2023 21:37:49 -0400 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 1plK03-0003c4-S4 for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2023 21:37:47 -0400 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plK01-0007eG-JF for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2023 21:37:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:mime-version:to:content-type:content-transfer-encoding: cc:content-type:from:subject:to; s=s1; bh=D66ZWYezmEDJJfA44snFc9gYmKyehr9xRtsNEfrCNwM=; b=mTHo1bq670KUMQNdwjPLfuns4P9gGlgsoM/YhvlQbD2MIcOFiT7UmlFC7iZ6RrbA27s0 LchnIFx/x4EQE6czMmAce8yMEFTwN7tzaQmrq1R4LnlBedKNNsVp0W7kCFiIcSkZVZKTe+ a1HYoQul3y2ZvkXVv6hsxqAqe7pmPJHuaZj1sl10h7vhSvARXo5ssMh1nfYy35gjcqRNkI RFJ/7saQNAuCicEqPHKHoUChIBCGQ2scd4lLYXNxC3aCXGrRmaaa5nxdBEr/bMUpRJQQpZ okbyt/kPXR0nIVVE9HoJVmXinJKusUInanswXhRwVdNMwhzl2vjpYAzdRwLaGRhw== Received: by filterdrecv-7946957d94-r22tt with SMTP id filterdrecv-7946957d94-r22tt-1-643216E7-A 2023-04-09 01:37:43.459061637 +0000 UTC m=+3981903.892405101 Received: from earth.catern.com (unknown) by geopod-ismtpd-19 (SG) with ESMTP id mQD9VZgtQHWvGrp5YwXnAA for ; Sun, 09 Apr 2023 01:37:43.113 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver= Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id B819D62A0E for ; Sat, 8 Apr 2023 21:37:42 -0400 (EDT) From: sbaugh@catern.com Subject: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD Date: Sun, 09 Apr 2023 01:37:43 +0000 (UTC) Message-ID: <87h6tpn8d5.fsf@catern.com> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKWUJonp9hgPtvxgm0xRA?= =?us-ascii?Q?HgBWctHH7ln+z+HXUspUTpjtDuN0s4jiZ7kqnzP?= =?us-ascii?Q?nK1rY43EbWe4BTRnepgq8MjFIXTmxQ0niRAMKP=2F?= =?us-ascii?Q?irhsJ1j1=2FyjeguCrTirUQERQO2ysiGUZIDOh+mj?= =?us-ascii?Q?XvcxcaXh389XZE8uO3AhE46HsIl6E797JUg=3D=3D?= To: bug-gnu-emacs@gnu.org X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=149.72.154.232; envelope-from=bounces+21787432-3678-bug-gnu-emacs=gnu.org@em8926.catern.com; helo=s.wrqvwxzv.outbound-mail.sendgrid.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 1. emacs -Q 2. Eval: (setq uniquify-buffer-name-style 'forward uniquify-trailing-separator-p t) 3. Open "Makefile" in the Emacs source tree 4. M-x rename-buffer lisp RET 5. Observe as it is renamed to lisp/ because there happens to be a directory named lisp in the same directory. This seems surprising, and also uniquify-trailing-separator-p is documented to only affect dired buffers, so seems like a bug. I have a patch which fixes this (and adds tests!) which I'll send in a followup. In GNU Emacs 29.0.60 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) Repository revision: 4b6f2a7028b91128934a19f83572f24106782225 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 System Description: NixOS 21.11 (Porcupine) Configured using: 'configure --prefix=/nix/store/6d12l6xgg6bdqbv2l0k1nkpbixh93ib7-emacs-git-20220225.0 --disable-build-details --with-modules --with-x-toolkit=lucid --with-xft --with-cairo' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XAW3D XDBE XIM XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/l Minor modes in effect: bug-reference-prog-mode: t envrc-global-mode: t envrc-mode: t global-git-commit-mode: t magit-auto-revert-mode: t auto-revert-mode: t shell-dirtrack-mode: t server-mode: t windmove-mode: t tracking-mode: t savehist-mode: t save-place-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /home/sbaugh/.emacs.d/elpa/transient-0.3.7/transient hides /home/sbaugh/.local/src/emacs29/lisp/transient Features: (emacs-news-mode shadow emacsbug vc-annotate vc-dir vc-filewise mode-local pcvs pcvs-defs pcvs-parse pcvs-info conf-mode magit-bundle magit-gitignore magit-subtree ibuf-ext ibuf-macs mule-diag dos-w32 find-cmd apropos finder autoinsert pcmpl-unix pcmpl-gnu make-mode ido benchmark term ehelp eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util ibuffer ibuffer-loaddefs package-x eat term/xterm xterm eat-autoloads tramp-adb tramp-container tramp-ftp loadhist timezone rect ediff-vers debbugs-browse time flow-fill qp sort smiley gnus-cite mail-extr gnus-async gnus-bcklg gnus-agent gnus-srvr gnus-score score-mode nnvirtual nntp gnus-ml gnus-msg disp-table nndoc gnus-cache gnus-dup debbugs-gnu debbugs-compat debbugs soap-client rng-xsd xsd-regexp debbugs-autoloads tar-mode arc-mode archive-mode forge-list forge-commands forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy gsexp ghub forge-notify forge-revnote forge-pullreq forge-issue forge-topic yaml forge-post let-alist markdown-mode forge-repo forge forge-core forge-db closql emacsql-sqlite emacsql emacsql-compiler emoji-labels emoji multisession sqlite org-attach tramp-cmds tramp-cache time-stamp tramp-sh shr-color textsec uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check skeleton mhtml-mode css-mode js c-ts-common sgml-mode facemenu nix-mode nix-repl nix-shell nix-store nix-log nix-instantiate nix-shebang nix-format nix ediff-ptch magit-patch tramp-archive tramp-gvfs tramp tramp-loaddefs trampver tramp-integration tramp-compat ls-lisp cursor-sensor magit-bookmark bookmark man find-dired grep org-capture ob-ditaa ob-plantuml org-clock org-colview org-crypt org-ctags org-habit org-mouse org-plot org-protocol novice pulse color git-rebase canlock view image-file image-converter rmail goto-addr whitespace eglot external-completion array jsonrpc ert flymake-proc flymake warnings diary-lib diary-loaddefs cal-iso cus-dep loaddefs-gen cus-theme oc-basic ol-eww eww url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader range ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex iso8601 ol-bbdb ol-w3m ol-doi org-link-doi dired-aux sh-script smie executable files-x tabify ggtags etags fileloop xref compile ewoc cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs debug backtrace cus-edit cus-start cus-load wid-edit lisp-mnt dabbrev pp cl-print shortdoc completion help-fns radix-tree mm-archive network-stream url-cache url-http url-auth url-gw nsm display-line-numbers misc tmm mule-util misearch multi-isearch vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util vc-git vc-dispatcher face-remap ob-python python pcase treesit agda2 envrc inheritenv page-ext dired-x magit-extras project magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff git-commit log-edit message sendmail yank-media dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor shell server magit-mode transient edmacro kmacro magit-git magit-section magit-utils crm dash cl-extra windmove lui-autopaste circe advice diff-mode lui-irc-colors irc gnutls puny lcs lui-logging lui-format lui tracking shorten help-mode flyspell ispell circe-compat ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table ox-ascii ox-publish ox org-element org-persist xdg org-id org-refile avl-tree generator org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete org-list org-footnote org-faces org-entities time-date noutline outline icons ob-emacs-lisp ob-core ob-eval org-cycle org-table ol rx org-fold org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar cal-loaddefs org-version org-compat org-macs format-spec gdb-mi bindat gud easy-mmode comint ansi-osc ansi-color ring ffap thingatpt cyberpunk-theme savehist saveplace finder-inf envrc-autoloads nix-mode-autoloads forge-autoloads htmlize-autoloads slime-volleyball-autoloads graphviz-dot-mode-autoloads yaml-autoloads auctex-autoloads tex-site notmuch-autoloads csv-mode-autoloads ghub-autoloads treepy-autoloads circe-autoloads inheritenv-autoloads mentor-autoloads url-scgi-autoloads xml-rpc-autoloads async-autoloads ggtags-autoloads closql-autoloads emacsql-sqlite-autoloads emacsql-autoloads magit-autoloads magit-section-autoloads git-commit-autoloads with-editor-autoloads transient-autoloads cyberpunk-theme-autoloads info dash-autoloads markdown-mode-autoloads package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 5991041 619218) (symbols 48 79996 40) (strings 32 571790 315988) (string-bytes 1 40038796) (vectors 16 186257) (vector-slots 8 3516735 1014181) (floats 8 10132 8490) (intervals 56 582407 12855) (buffers 976 373)) From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 08 21:50:00 2023 Received: (at 62732) by debbugs.gnu.org; 9 Apr 2023 01:50:00 +0000 Received: from localhost ([127.0.0.1]:59948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plKBs-0008Mc-12 for submit@debbugs.gnu.org; Sat, 08 Apr 2023 21:50:00 -0400 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:24018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plKBp-0008MM-Ad for 62732@debbugs.gnu.org; Sat, 08 Apr 2023 21:49:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=xMxMGrGAiL1j3d7N/4OFC79q0UFdtvIw8UBYKcavgq0=; b=XSmv+47lGB7d/6dP/NluY9dhOFBHT5db1oBiK/ZY8gqb3GdZpxdhpIQ5y3QvjZQwuRO+ QTl6cISDI+4Z2LmnwSSM/IBm6Ml3bbeNy0IDEYxcnUIR/wO/D6CdGjCAYKoFfXKadSIQhw OO46jmN7UjiOqdV4bSHRfpMy8BOex2ZehVDNZN1e45gtLl4I0m8LQo4FfN/2XxvspEqrmU eleudXHHpfvdfCptpIrzWXu+Pamix1oX6kr9FPzPPmhX3HG8uZ4OM/wleOciAS6H6bO13H K5uIucEhxnXDIffpL5/Ea7VcaEIKzOLSMBb9Tnr5Tu5h8+5agKtW4LsAfDP6M9NQ== Received: by filterdrecv-7946957d94-7d6jw with SMTP id filterdrecv-7946957d94-7d6jw-1-643219BF-3 2023-04-09 01:49:51.209939843 +0000 UTC m=+3982687.670017880 Received: from earth.catern.com (unknown) by geopod-ismtpd-18 (SG) with ESMTP id 7wIUmP5QT4OebarwdsCWAw for <62732@debbugs.gnu.org>; Sun, 09 Apr 2023 01:49:51.000 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver= Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 9B27262A0E for <62732@debbugs.gnu.org>; Sat, 8 Apr 2023 21:49:50 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87h6tpn8d5.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Apr 2023 01:37:43 +0000 (UTC)") References: <87h6tpn8d5.fsf@catern.com> Date: Sun, 09 Apr 2023 01:49:51 +0000 (UTC) Message-ID: <87edotn7sx.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbIB2D2HNRtltp3TjkUXZm?= =?us-ascii?Q?SfcKc=2FcQsPTSO=2FfdxeZOeeyqoulPfNxgCmVfay=2F?= =?us-ascii?Q?bApcJShL++Q0ONcQYjY6kx2gcB=2FKiiwGTdwx3vo?= =?us-ascii?Q?z=2FKXkAuXrVSoPxjDG4Xmh+dN0VAi8zyx0acfWQU?= =?us-ascii?Q?TBsfQ01ufdb3Zu2pi0e6jz4=2F612fhhOkMyA=3D=3D?= To: 62732@debbugs.gnu.org X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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=B2 filesystem accesses which is not something we should be doing on every buffer creation/rename. Also, this approach is in line with other simplifications of uniquify that I'd like to make (as part of implementing bug#62621). Also, now there are tests for uniquify. diff --git a/lisp/dired.el b/lisp/dired.el index 4a4ecc901c4..12629dbbd87 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -490,6 +490,17 @@ dired-guess-shell-znew-switches (string :tag "Switches")) :version "29.1") =20 +(defcustom dired-trailing-separator nil + "If non-nil, add a file name separator to dired buffer names. +For example, \"dir/\" instead of \"dir\". + +Normally the separator is added at the end and matches the +platform convention for path separators. If +`uniquify-buffer-name-style' is `reverse', add the separator at +the beginning, and use `uniquify-separator' for the separator." + :type 'boolean + :group 'dired) + =0C ;;; Internal variables =20 @@ -1285,6 +1296,19 @@ dired--align-all-files (insert-char ?\s distance 'inherit)) (forward-line))))))) =20 +(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 'forward= ) + (file-name-as-directory base)) + ((eq uniquify-buffer-name-style 'reverse) + (concat (or uniquify-separator "\\") base)))))= )) + (defun dired-internal-noselect (dir-or-list &optional switches mode) ;; If DIR-OR-LIST is a string and there is an existing dired buffer ;; for it, just leave buffer as it is (don't even call dired-revert). @@ -1306,7 +1330,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (dired--create-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..75495ab608e 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,27 @@ find-alternate-file (kill-buffer obuf)))))) =0C ;; 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 basename) "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. =20 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 BASENAME is non-nil, it will be used as the buffer name. +FILENAME will only be used to rename the buffer according to +`uniquify-buffer-name-style' to get an unused name. +" (let* ((lastname (file-name-nondirectory filename)) (lastname (if (string=3D lastname "") filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) + (buf (generate-new-buffer (or basename (if (string-prefix-p " " lastname= ) (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + lastname))))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) =20 (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..6c0f5468faa 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -147,12 +147,14 @@ uniquify-separator file name components (default \"\\\")." :type '(choice (const nil) string)) =20 -(defcustom uniquify-trailing-separator-p nil - "If non-nil, add a file name separator to dired buffer names. -If `uniquify-buffer-name-style' is `forward', add the separator at the end= ; -if it is `reverse', add the separator at the beginning; otherwise, this -variable is ignored." - :type 'boolean) +(defvaralias + 'uniquify-trailing-separator-p + 'dired-trailing-separator) + +(make-obsolete-variable + 'uniquify-trailing-separator-p + 'dired-trailing-separator + "30.1") =20 (defcustom uniquify-strip-common-suffix ;; Using it when uniquify-min-dir-content>0 doesn't make much sense. @@ -174,8 +176,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) =20 ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +213,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +294,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname it= em))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +317,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +345,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) =20 -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing s= lash. =20 - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +410,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string=3D old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,15 +480,14 @@ uniquify--rename-buffer-advice =20 =20 ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-= advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style - (let ((filename (expand-file-name (directory-file-name filename)))) - (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) - (file-name-directory filename) - buf)))) + (uniquify-rationalize-file-buffer-names + (or basename (file-name-nondirectory filename)) + (file-name-directory (expand-file-name (directory-file-name filename)= )) + buf))) =20 (defun uniquify-unload-function () "Unload the uniquify library." diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..70f7125cbe9 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,111 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: = t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniqui= fy + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose nam= es don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'n= osave) + ;; somewhat confusing behavior results if a buffer is renamed to m= atch an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z= ") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#4= 7132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buf= fer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 09 08:13:39 2023 Received: (at 62732) by debbugs.gnu.org; 9 Apr 2023 12:13:39 +0000 Received: from localhost ([127.0.0.1]:60340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plTvP-0006P8-8o for submit@debbugs.gnu.org; Sun, 09 Apr 2023 08:13:39 -0400 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:40296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plTvN-0006On-C0 for 62732@debbugs.gnu.org; Sun, 09 Apr 2023 08:13:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=FP5ptdJhEYMpVyfVQz8/IOIwD00g8leNb30rALGBWvU=; b=HLZAZXWao50msID9bAKiJbofTfbzW9izQvXmmJIEnBQ6OU9lDyMxyXc1LyGpB6tmmZ9t kwbh4h+mnh7zbolWA5SPbCCCzWb4gaOzfr75lMFq9lJipNbiuhJGS1O6fGWYeT+cBsBvkb lyknOwGTfXqc7OKhJ+LyVGrHme1FwtZRFrXchMDQBcPl6r1pqbsoSmpkWVpkZWPJF94vfF usRD+fvMJrf2oG7KGd/YKXMBl36RHQPxaLyCFGEfOSd+riNnDJYLOZLmmeeu0LXo/mRr9V 5Hk0q6BJu9nCU53qQ7vyaWFnFCEKv2NcMNwQR0FdOxu4uCyyOqD526MmLbMBzgCQ== Received: by filterdrecv-68f8d557c9-bsxpv with SMTP id filterdrecv-68f8d557c9-bsxpv-1-6432ABEB-2E 2023-04-09 12:13:31.751136809 +0000 UTC m=+4020119.600749193 Received: from earth.catern.com (unknown) by geopod-ismtpd-15 (SG) with ESMTP id GhPmrrcLSCa7LX2pMumcDA for <62732@debbugs.gnu.org>; Sun, 09 Apr 2023 12:13:31.537 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver= Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 1362C60091 for <62732@debbugs.gnu.org>; Sun, 9 Apr 2023 08:13:31 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87edotn7sx.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Apr 2023 01:49:51 +0000 (UTC)") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Date: Sun, 09 Apr 2023 12:13:31 +0000 (UTC) Message-ID: <87a5zhmexh.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbIh=2FbIniysfjlNHl9ggUi?= =?us-ascii?Q?35Np=2FGvFrGVboVIsL9UzR48ObBo9Wug3kyBiYJh?= =?us-ascii?Q?Nsaq9YwNHZaLlD5Yg4R7o8Yfc3ntfruB+Aac2VH?= =?us-ascii?Q?OtvH8cRl6PCE9P+CBV0cYBk6+skfaZpyWKq5yP0?= =?us-ascii?Q?L61Op39PyHy8UQccIolax6fWYMFBQ6x1qVw=3D=3D?= To: 62732@debbugs.gnu.org X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. diff --git a/lisp/files.el b/lisp/files.el index c9433938729..e1e8e905fb0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2079,9 +2079,10 @@ create-file-buffer (let* ((lastname (or basename (file-name-nondirectory filename))) (lastname (if (string= lastname "") filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) (uniquify--create-file-buffer-advice buf filename basename) buf)) diff --git a/lisp/uniquify.el b/lisp/uniquify.el index 6c0f5468faa..ad6f9797381 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -485,7 +485,7 @@ uniquify--create-file-buffer-advice "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style (uniquify-rationalize-file-buffer-names - (or basename (file-name-nondirectory filename)) + basename (file-name-directory (expand-file-name (directory-file-name filename))) buf))) From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 21 16:59:40 2023 Received: (at 62732) by debbugs.gnu.org; 21 Apr 2023 20:59:40 +0000 Received: from localhost ([127.0.0.1]:41278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxr1-00056g-Oz for submit@debbugs.gnu.org; Fri, 21 Apr 2023 16:59:40 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:28982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxqy-00056P-5g for 62732@debbugs.gnu.org; Fri, 21 Apr 2023 16:59:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:content-type:cc: content-type:from:subject:to; s=s1; bh=nkVGh2Gt6JU0yRYvhSpiUTWgAOyAbShXStLritVK+QI=; b=N+WLK09VHVx4wc+BRvVPyNyhq08l/bBPbClsgtyQBR9jIl3igqv3grKGlz0XV6GAkl61 wzcY9delzUKuz/37nQvRR/BG9UBxsE+ZlKMRdwhYZ3BMDqFapbPmgb4u3ULzqeL4yanei7 ES53aOfDxDDNfrNGOj+GMdZE8+qo7DkxYarb6LIJu82GbOJAT0qbL3IAQwSlq0VGY2t7J5 w0H5g+CIDBewjID2PXxl2kGst20bvIF7JGDRnImAzaa/VOhJ8R1utkQVnFIUhgUn5R3Lxz z4QqPBj4oqRdT52QsCOjyYrWnSFbdV9NO0Bs+fpUuInJtXu7jgjvYlpoUrXL7zqg== Received: by filterdrecv-7946957d94-d4bhm with SMTP id filterdrecv-7946957d94-d4bhm-1-6442F932-2 2023-04-21 20:59:30.056140684 +0000 UTC m=+5088463.725224881 Received: from earth.catern.com (unknown) by geopod-ismtpd-23 (SG) with ESMTP id hwTauytyThee53fyBrSUuA for <62732@debbugs.gnu.org>; Fri, 21 Apr 2023 20:59:29.855 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver= Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 4C67760044 for <62732@debbugs.gnu.org>; Fri, 21 Apr 2023 16:59:29 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87a5zhmexh.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Apr 2023 12:13:31 +0000 (UTC)") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> Date: Fri, 21 Apr 2023 20:59:30 +0000 (UTC) Message-ID: <87leilkl3i.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKUChhXOPgLxgIoL6nH2x?= =?us-ascii?Q?wgfcWI6K6qvsJpoGwbCQoMy22MkfZqsgmS8MKLl?= =?us-ascii?Q?Mf=2Ff78ZevwWLAZOXOagRSDPVvKJYvM7BllNU1ZB?= =?us-ascii?Q?LMs3dcSWAemyasbHCp1To7wxpxMPUS=2FyHbWTLje?= =?us-ascii?Q?drq+KTKtBGnANVysXSgaCPrZbyoNBQhEFjw=3D=3D?= To: 62732@debbugs.gnu.org X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Simplified and combined the previous two patches, now with a nice commit message and changelog. Also, stopped moving this functionality into dired, that's not really necessary. Most of this change is tests, and most of the remainder is moving the uniquify-trailing-separator-p code without changes from uniquify.el into create-file-buffer. Hopefully it is fairly easy to review. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-recalculate-the-buffer-basename-inside-uniquif.patch >From ebd49cb05f5c0db643e4a616bad23565eef53b75 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 9 Apr 2023 08:10:52 -0400 Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Previously, uniquify--create-file-buffer-advice would use the filename of the buffer to calculate what the buffer's basename should be. Now that gets passed in from create-file-buffer, which lets us fix several bugs: 1. Before this patch, if a buffer happened to be named the same thing as directory in its default-directory, the buffer would get renamed with a directory separator according to uniquify-trailing-separator-p. 2. Buffers with a leading space should get a leading |, as described by create-file-buffer's docstring; before this patch, uniquify would remove that leading |. * lisp/dired.el (dired-internal-noselect): Pass t to create-file-buffer for the new directory argument. * lisp/files.el (create-file-buffer): Add a new directory argument to handle uniquify-trailing-separator-p, and pass the desired basename to uniquify directly. * lisp/uniquify.el (uniquify-item): (uniquify-rationalize-file-buffer-names, uniquify-rationalize, uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): Remove uniquify-trailing-separator-p handling. (uniquify--create-file-buffer-advice): Take new basename argument and use it, instead of recalculating the basename from the filename. --- lisp/dired.el | 2 +- lisp/files.el | 26 +++++--- lisp/uniquify.el | 32 +++------- test/lisp/uniquify-tests.el | 118 ++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 32 deletions(-) create mode 100644 test/lisp/uniquify-tests.el diff --git a/lisp/dired.el b/lisp/dired.el index 4a4ecc901c4..62ff98c5279 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer (directory-file-name dirname) t))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..ada3d19442f 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,32 @@ find-alternate-file (kill-buffer obuf)))))) ;; 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'." (let* ((lastname (file-name-nondirectory filename)) (lastname (if (string= lastname "") filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + (lastname (if (and directory 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))) + lastname)) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..bfb61eca16d 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname item))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string= old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,13 +478,13 @@ uniquify--rename-buffer-advice ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style (let ((filename (expand-file-name (directory-file-name filename)))) (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) + basename (file-name-directory filename) buf)))) diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..89976add164 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,118 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniquify + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buffer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-space-prefix () + "If a buffer starts with a space, | is added at the start" + (save-excursion + (find-file " foo") + (should (equal (buffer-name) "| foo")) + (kill-buffer))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here -- 2.38.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri May 05 02:05:52 2023 Received: (at 62732) by debbugs.gnu.org; 5 May 2023 06:05:52 +0000 Received: from localhost ([127.0.0.1]:52963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puoZj-0006zj-AU for submit@debbugs.gnu.org; Fri, 05 May 2023 02:05:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puoZh-0006zU-7T for 62732@debbugs.gnu.org; Fri, 05 May 2023 02:05:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puoZb-0005AU-Mo; Fri, 05 May 2023 02:05:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=oiq+tBT7Yv991Gd48NVMTUaQUQT7tOy6HwObSbU8/as=; b=TJsWMR/fiRr4 Trhh9Nv9dwn0faf6yTAXEy4Fhn8n2kgLSSm/hLpPWFBPG72wR+Pjxr2pPMuhnjSw9aebZj8/Qt7Ws HVRdtazRWg2TShMt08GPyVrfvuFn8CnZ+erdNqXMp1pQAbDX3XQnwBPNYfAyt7RD1ak0Yf3zetW3K eOfqUhylpoLbSs/B0SSViyy/XEbrwvY/Q3SD2j4RSZowT8ffrRNhBlTa1MG2nXz0KJKlst+hoEoTI 9GuqYS9ylRCOJwiDefTpcITIrt4PicVwEGUb7/u6+gWLYB6lAMYjRP51OQXJ78gXlhQBZ8reqGJm5 +BCpAjyL0EmtQYEGCOga1A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puoZb-0008AH-5o; Fri, 05 May 2023 02:05:43 -0400 Date: Fri, 05 May 2023 09:06:35 +0300 Message-Id: <837ctnjor8.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com, Stefan Monnier , Lars Ingebrigtsen In-Reply-To: <87leilkl3i.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> <87leilkl3i.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Stefan, Lars: any comments? > From: sbaugh@catern.com > Date: Fri, 21 Apr 2023 20:59:30 +0000 (UTC) > > Simplified and combined the previous two patches, now with a nice commit > message and changelog. Also, stopped moving this functionality into > dired, that's not really necessary. > > Most of this change is tests, and most of the remainder is moving the > uniquify-trailing-separator-p code without changes from uniquify.el into > create-file-buffer. Hopefully it is fairly easy to review. > > > >From ebd49cb05f5c0db643e4a616bad23565eef53b75 Mon Sep 17 00:00:00 2001 > From: Spencer Baugh > Date: Sun, 9 Apr 2023 08:10:52 -0400 > Subject: [PATCH] Don't recalculate the buffer basename inside uniquify > > Previously, uniquify--create-file-buffer-advice would use the filename > of the buffer to calculate what the buffer's basename should be. Now > that gets passed in from create-file-buffer, which lets us fix several > bugs: > > 1. Before this patch, if a buffer happened to be named the same thing > as directory in its default-directory, the buffer would get renamed > with a directory separator according to uniquify-trailing-separator-p. > > 2. Buffers with a leading space should get a leading |, as described > by create-file-buffer's docstring; before this patch, uniquify would > remove that leading |. > > * lisp/dired.el (dired-internal-noselect): Pass t to > create-file-buffer for the new directory argument. > * lisp/files.el (create-file-buffer): Add a new directory argument to > handle uniquify-trailing-separator-p, and pass the desired basename to > uniquify directly. > * lisp/uniquify.el (uniquify-item): > (uniquify-rationalize-file-buffer-names, uniquify-rationalize, > uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): > Remove uniquify-trailing-separator-p handling. > (uniquify--create-file-buffer-advice): Take new basename argument and > use it, instead of recalculating the basename from the filename. > --- > lisp/dired.el | 2 +- > lisp/files.el | 26 +++++--- > lisp/uniquify.el | 32 +++------- > test/lisp/uniquify-tests.el | 118 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 146 insertions(+), 32 deletions(-) > create mode 100644 test/lisp/uniquify-tests.el > > diff --git a/lisp/dired.el b/lisp/dired.el > index 4a4ecc901c4..62ff98c5279 100644 > --- a/lisp/dired.el > +++ b/lisp/dired.el > @@ -1306,7 +1306,7 @@ dired-internal-noselect > ;; Note that buffer already is in dired-mode, if found. > (new-buffer-p (null buffer))) > (or buffer > - (setq buffer (create-file-buffer (directory-file-name dirname)))) > + (setq buffer (create-file-buffer (directory-file-name dirname) t))) > (set-buffer buffer) > (if (not new-buffer-p) ; existing buffer ... > (cond (switches ; ... but new switches > diff --git a/lisp/files.el b/lisp/files.el > index d325729bf4d..ada3d19442f 100644 > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -2062,22 +2062,32 @@ find-alternate-file > (kill-buffer obuf)))))) > > ;; 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'." > (let* ((lastname (file-name-nondirectory filename)) > (lastname (if (string= lastname "") > filename lastname)) > - (buf (generate-new-buffer (if (string-prefix-p " " lastname) > - (concat "|" lastname) > - lastname)))) > - (uniquify--create-file-buffer-advice buf filename) > + (lastname (if (and directory 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))) > + lastname)) > + (basename (if (string-prefix-p " " lastname) > + (concat "|" lastname) > + lastname)) > + (buf (generate-new-buffer basename))) > + (uniquify--create-file-buffer-advice buf filename basename) > buf)) > > (defvar abbreviated-home-dir nil > diff --git a/lisp/uniquify.el b/lisp/uniquify.el > index dee9ecba2ea..bfb61eca16d 100644 > --- a/lisp/uniquify.el > +++ b/lisp/uniquify.el > @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes > (cl-defstruct (uniquify-item > (:constructor nil) (:copier nil) > (:constructor uniquify-make-item > - (base dirname buffer &optional proposed original-dirname))) > - base dirname buffer proposed original-dirname) > + (base dirname buffer &optional proposed))) > + base dirname buffer proposed) > > ;; Internal variables used free > (defvar uniquify-possibly-resolvable nil) > @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names > (when dirname > (setq dirname (expand-file-name (directory-file-name dirname))) > (let ((fix-list (list (uniquify-make-item base dirname newbuf > - nil dirname))) > + nil))) > items) > (dolist (buffer (buffer-list)) > (when (and (not (and uniquify-ignore-buffers-re > @@ -292,8 +292,7 @@ uniquify-rationalize > (setf (uniquify-item-proposed item) > (uniquify-get-proposed-name (uniquify-item-base item) > (uniquify-item-dirname item) > - nil > - (uniquify-item-original-dirname item))) > + nil)) > (setq uniquify-managed fix-list))) > ;; Strip any shared last directory names of the dirname. > (when (and (cdr fix-list) uniquify-strip-common-suffix) > @@ -316,8 +315,7 @@ uniquify-rationalize > (uniquify-item-dirname item)))) > (and f (directory-file-name f))) > (uniquify-item-buffer item) > - (uniquify-item-proposed item) > - (uniquify-item-original-dirname item)) > + (uniquify-item-proposed item)) > fix-list))))) > ;; If uniquify-min-dir-content is 0, this will end up just > ;; passing fix-list to uniquify-rationalize-conflicting-sublist. > @@ -345,21 +343,10 @@ uniquify-rationalize-a-list > (uniquify-rationalize-conflicting-sublist conflicting-sublist > old-proposed depth))) > > -(defun uniquify-get-proposed-name (base dirname &optional depth > - original-dirname) > +(defun uniquify-get-proposed-name (base dirname &optional depth) > (unless depth (setq depth uniquify-min-dir-content)) > (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. > > - ;; Distinguish directories by adding extra separator. > - (if (and uniquify-trailing-separator-p > - (file-directory-p (expand-file-name base original-dirname)) > - (not (string-equal base ""))) > - (cond ((eq uniquify-buffer-name-style 'forward) > - (setq base (file-name-as-directory base))) > - ;; (setq base (concat base "/"))) > - ((eq uniquify-buffer-name-style 'reverse) > - (setq base (concat (or uniquify-separator "\\") base))))) > - > (let ((extra-string nil) > (n depth)) > (while (and (> n 0) dirname) > @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist > (uniquify-get-proposed-name > (uniquify-item-base item) > (uniquify-item-dirname item) > - depth > - (uniquify-item-original-dirname item)))) > + depth))) > (uniquify-rationalize-a-list conf-list depth)) > (unless (string= old-name "") > (uniquify-rename-buffer (car conf-list) old-name))))) > @@ -492,13 +478,13 @@ uniquify--rename-buffer-advice > > > ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) > -(defun uniquify--create-file-buffer-advice (buf filename) > +(defun uniquify--create-file-buffer-advice (buf filename basename) > ;; BEWARE: This is called directly from `files.el'! > "Uniquify buffer names with parts of directory name." > (when uniquify-buffer-name-style > (let ((filename (expand-file-name (directory-file-name filename)))) > (uniquify-rationalize-file-buffer-names > - (file-name-nondirectory filename) > + basename > (file-name-directory filename) > buf)))) > > diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el > new file mode 100644 > index 00000000000..89976add164 > --- /dev/null > +++ b/test/lisp/uniquify-tests.el > @@ -0,0 +1,118 @@ > +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- > + > +;; Copyright (C) 2023 Free Software Foundation, Inc. > + > +;; Author: Spencer Baugh > + > +;; This program is free software; you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; This program is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with this program. If not, see . > + > +;;; Commentary: > + > +;;; Code: > + > +(require 'ert) > + > +(ert-deftest uniquify-basic () > + (let (bufs old-names) > + (cl-flet ((names-are (current-names &optional nosave) > + (should (equal (mapcar #'buffer-name bufs) current-names)) > + (unless nosave (push current-names old-names)))) > + (should (eq (get-buffer "z") nil)) > + (push (find-file-noselect "a/b/z") bufs) > + (names-are '("z")) > + (push (find-file-noselect "a/b/c/z") bufs) > + (names-are '("z" "z")) > + (push (find-file-noselect "a/b/d/z") bufs) > + (names-are '("z" "z" "z")) > + (push (find-file-noselect "e/b/z") bufs) > + (names-are '("z" "z" "z" "z")) > + ;; buffers without a buffer-file-name don't get uniquified by uniquify > + (push (generate-new-buffer "z") bufs) > + (names-are '("z" "z" "z" "z" "z")) > + ;; but they do get uniquified by the C code which uses > + (push (generate-new-buffer "z") bufs) > + (names-are '("z<2>" "z" "z" "z" "z" "z")) > + (save-excursion > + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name > + (find-file "f/y") > + (push (current-buffer) bufs) > + (rename-buffer "z" t) > + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) > + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer > + (rename-buffer "z" t) > + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) > + (while bufs > + (kill-buffer (pop bufs)) > + (names-are (pop old-names) 'nosave))))) > + > +(ert-deftest uniquify-dirs () > + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" > + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) > + (a-path (file-name-concat root "a/x/y/dir")) > + (b-path (file-name-concat root "b/x/y/dir"))) > + (make-directory a-path 'parents) > + (make-directory b-path 'parents) > + (let ((uniquify-buffer-name-style 'forward) > + (uniquify-strip-common-suffix t) > + (uniquify-trailing-separator-p nil)) > + (let ((bufs (list (find-file-noselect a-path) > + (find-file-noselect b-path)))) > + (should (equal (mapcar #'buffer-name bufs) > + '("a/dir" "b/dir"))) > + (mapc #'kill-buffer bufs))) > + (let ((uniquify-buffer-name-style 'forward) > + (uniquify-strip-common-suffix nil) > + (uniquify-trailing-separator-p t)) > + (let ((bufs (list (find-file-noselect a-path) > + (find-file-noselect b-path)))) > + (should (equal (mapcar #'buffer-name bufs) > + '("a/x/y/dir/" "b/x/y/dir/"))) > + (mapc #'kill-buffer bufs))) > + (let ((uniquify-buffer-name-style 'forward) > + (uniquify-strip-common-suffix t) > + (uniquify-trailing-separator-p t)) > + (let ((bufs (list (find-file-noselect a-path) > + (find-file-noselect b-path)))) > + (should (equal (mapcar #'buffer-name bufs) > + '("a/dir/" "b/dir/"))) > + (mapc #'kill-buffer bufs))))) > + > +(ert-deftest uniquify-rename-to-dir () > + "Giving a buffer a name which matches a directory doesn't rename the buffer" > + (let ((uniquify-buffer-name-style 'forward) > + (uniquify-trailing-separator-p t)) > + (save-excursion > + (find-file "../README") > + (rename-buffer "lisp" t) > + (should (equal (buffer-name) "lisp")) > + (kill-buffer)))) > + > +(ert-deftest uniquify-separator-style-reverse () > + (let ((uniquify-buffer-name-style 'reverse) > + (uniquify-trailing-separator-p t)) > + (save-excursion > + (should (file-directory-p "../lib-src")) > + (find-file "../lib-src") > + (should (equal (buffer-name) "\\lib-src")) > + (kill-buffer)))) > + > +(ert-deftest uniquify-space-prefix () > + "If a buffer starts with a space, | is added at the start" > + (save-excursion > + (find-file " foo") > + (should (equal (buffer-name) "| foo")) > + (kill-buffer))) > + > +(provide 'uniquify-tests) > +;;; uniquify-tests.el ends here > -- > 2.38.0 > From debbugs-submit-bounces@debbugs.gnu.org Fri May 05 16:14:04 2023 Received: (at 62732) by debbugs.gnu.org; 5 May 2023 20:14:04 +0000 Received: from localhost ([127.0.0.1]:57601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv1oa-0006Jb-Eg for submit@debbugs.gnu.org; Fri, 05 May 2023 16:14:04 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:49800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv1oX-0006Ii-Sn for 62732@debbugs.gnu.org; Fri, 05 May 2023 16:14:03 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id F0222442D2B; Fri, 5 May 2023 16:13:55 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5DC4D442D29; Fri, 5 May 2023 16:13:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683317634; bh=b2E9Xwr/sONmmFeDalug4Kg+X5P2gy43k4QCB/Of+q0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=dr64vIdvrcGolfYNhIhzTH4iS8jJkWLzUm9nQD2JkrMd6rfa1dBpfAH4aHdvcECnr SLDVDZA2gySgRpf6f1C/cTR0MaceEHNxxTDyrYPlvbiKmtlDNHD46Y/RyrSw1D0Jx5 RZ3voTiE1XH9HwR1pp4UIywGZ1HoOJZMvo1hkWSAcaDaQHp0azjZahMM3dMhGaEkD/ 3SnHvQssKYNeNcIppehlBJvcyWZYaaOjQ94EWOVh/EACh57DUVC7s7runcJK8T07iw IITVnaSs1bCiI8wsFM2JtQ2N1r5L8RfDZWhSlpIN+TaJatBxjgdjKIZHNJZH9ZdG7T IEkHeMxs9JAdA== Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2FD3D120099; Fri, 5 May 2023 16:13:54 -0400 (EDT) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87edotn7sx.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Apr 2023 01:49:51 +0000 (UTC)") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Date: Fri, 05 May 2023 16:13:52 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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=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 'forwa= rd) > + (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 directory. 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 directory= ." (create-file-buffer (file-name-as-directory dirname))) and then do the rest inside `uniquify.el`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri May 05 16:30:42 2023 Received: (at 62732) by debbugs.gnu.org; 5 May 2023 20:30:42 +0000 Received: from localhost ([127.0.0.1]:57632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv24g-0006n7-4M for submit@debbugs.gnu.org; Fri, 05 May 2023 16:30:42 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:9420) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv24d-0006ms-4t for 62732@debbugs.gnu.org; Fri, 05 May 2023 16:30:40 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7049A442D2C; Fri, 5 May 2023 16:30:33 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0342A442D1F; Fri, 5 May 2023 16:30:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683318632; bh=kjXlyhYg9gg0DHikRCmEHwawTwoWV/pIhWJaqGLBjxA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=oQqlrnLzYSIqsQvv5zPgTCGzFTguYe7E32cpTs/ZVhiPNdrMpPcYvdt3niiprMJGa 0NtBxo0hluTpc4i80+q0nP7jN81EpIe6OhxtdFLPhVpjHIrEq1CMhscL6rMWz8ycDq gFQ4XwSfmLuzDljwAraCurUYBMV32hRnP4o0FGpUN7dmmqpr6//U6B02kQuEd6uLwn IUmV4TWMWK4x0fJZ6ShttFvotJKJAgm5aCbSz2Hy4Rm1xAQjJkWqnIrDenBFVzXa8y dpcX1B8pRD+Aj/+qDN88mQVtAvsCGVM3bNS2J8Ijf01HhT1AWtW3Yn62odLF0w2Ami uJrj+ehUWDKYw== Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A85931204BA; Fri, 5 May 2023 16:30:31 -0400 (EDT) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87a5zhmexh.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Apr 2023 12:13:31 +0000 (UTC)") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> Date: Fri, 05 May 2023 16:30:28 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.052 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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)))) From debbugs-submit-bounces@debbugs.gnu.org Fri May 05 16:37:50 2023 Received: (at 62732) by debbugs.gnu.org; 5 May 2023 20:37:50 +0000 Received: from localhost ([127.0.0.1]:57642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv2Ba-0006xq-Kr for submit@debbugs.gnu.org; Fri, 05 May 2023 16:37:50 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv2BY-0006xb-Au for 62732@debbugs.gnu.org; Fri, 05 May 2023 16:37:49 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E32E5100485; Fri, 5 May 2023 16:37:42 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 982671000B9; Fri, 5 May 2023 16:37:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683319061; bh=lOkVnOPqwmueHpFQMcb0EwTAYfItc59qNSET5O3nmnY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ma3PwHipsQi2VrwCdPy35xLnsXhfRlKxz+Rol+0vcJ+7NeHvtNnxVJvxyuGKeR6yp uCv2N82dImUFT4gtX3MA9sFRu8RSXd143FwyFzb75ZzphUB8CqX6YwC1rbNHRVFg/0 CdUotKvuxu0WHX6mAlVbzALVYgaM5LbqbqAEAG2ah6TdCPFKNS9A+5wQmJVwj7BViY ElnAcPCK7OybxPgOrOyDNUEiiCAgDwli/ZppnnsJVdLkKpkBLg25b51qIgRmAiEVOq RF+pHcgreW22T8WUn59Ub8bNezMqlZ+e4gN0QqMUOn5SHmwx9IxCaaT+BKsEooL9mm gkOYHNkU+JLPg== Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4B69A120905; Fri, 5 May 2023 16:37:41 -0400 (EDT) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:13:52 -0400") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Date: Fri, 05 May 2023 16:37:39 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.200 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > (defun dired--create-buffer (dirname) > "Create a buffer with an appropriate name for visiting this directory." > (create-file-buffer (file-name-as-directory dirname))) > > and then do the rest inside `uniquify.el`. Or inside `create-file-buffer`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri May 05 17:15:06 2023 Received: (at 62732) by debbugs.gnu.org; 5 May 2023 21:15:07 +0000 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 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 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:13:52 -0400") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Date: Fri, 05 May 2023 17:14:56 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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... From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 03 14:55:08 2023 Received: (at 62732) by debbugs.gnu.org; 3 Jul 2023 18:55:08 +0000 Received: from localhost ([127.0.0.1]:34503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGOhX-00026S-RO for submit@debbugs.gnu.org; Mon, 03 Jul 2023 14:55:08 -0400 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:46928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGOhU-00025l-OG for 62732@debbugs.gnu.org; Mon, 03 Jul 2023 14:55:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=3FmeiZHuwMKlf+GO92SklNyZSNrt8LK9/0FH1FZ1w7s=; b=K3fAcdCchjZZ1tnlca7YzdgPfoh+F/Zu6zR9kIivQ+W0buh3pOdiVy7bs1/XPiOAIx7D BIyjrIZ6/68uPcSL6UOis3wHaRwfckm8+C4CCXBsLUeqo6vcFpWiQLDnLcxFcmniu2R9vv zcSMrV9v0P4IKZ/HMfCDLEnDR5UnmeLGG4YtsjqRhpWFvSm5E80/EDw2p/MokmH6obqlPq bf3HagwIcrN9cz+Lj/8yAKsscZiDgAwwK903/KHjzwkj3ceLcCKLo2dtTVJ54srU4rYCWZ z2JA0/uN+SrxymRA1RxjJ9l+pYaVesdBJ378aFFeX6biuyO0hEALLSyWTvcvqxVg== Received: by filterdrecv-d7bbbc8bf-7m5fp with SMTP id filterdrecv-d7bbbc8bf-7m5fp-1-64A31982-2D 2023-07-03 18:54:58.50467151 +0000 UTC m=+4648521.653641355 Received: from earth.catern.com (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id eNgGOXAeSTObgnHmjCULCw Mon, 03 Jul 2023 18:54:58.435 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 80B676009A; Mon, 3 Jul 2023 14:54:57 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <837ctnjor8.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 May 2023 09:06:35 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> <87leilkl3i.fsf@catern.com> <837ctnjor8.fsf@gnu.org> Date: Mon, 03 Jul 2023 18:54:58 +0000 (UTC) Message-ID: <87h6qkrfjy.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKN4aC13YvLrZmvTRIVK2?= =?us-ascii?Q?8ZZ8+lRhyM1=2FJhd0Nnb9uGyeciVqRkH9KeYbp3u?= =?us-ascii?Q?3Ubqb2iViI2Sdj90GLEomeloPh1tPtnz77I40Wu?= =?us-ascii?Q?+z=2FbOsq6fFSP9gRHDH5jjCc0RrUgiAaj5VG4Dnt?= =?us-ascii?Q?1P2a0DO2xqHes4y6Dq8zWztN5j8WOD2NgTg=3D=3D?= To: Eli Zaretskii X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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. Eli Zaretskii writes: > Stefan, Lars: any comments? Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [149.72.154.232 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-Debbugs-Envelope-To: 62732 Cc: Lars Ingebrigtsen , Stefan Monnier , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) 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. Eli Zaretskii writes: > Stefan, Lars: any comments? From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 03 15:19:12 2023 Received: (at 62732) by debbugs.gnu.org; 3 Jul 2023 19:19:12 +0000 Received: from localhost ([127.0.0.1]:34522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGP4q-0002jX-1J for submit@debbugs.gnu.org; Mon, 03 Jul 2023 15:19:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGP4l-0002j8-6G for 62732@debbugs.gnu.org; Mon, 03 Jul 2023 15:19:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGP4e-0002fi-H0; Mon, 03 Jul 2023 15:19:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=P2p6Zhzas0QDObGcBJVQ2K3FL65Iv0O2U7/tQpb5BaE=; b=iqwPRUQ2bgjL lrOdobNNeVZcjknFB1oZdI9BG78tIIjTn+2CHTu4cNZKc8csmNCAhAakN2wEZJFSjEEUzeL8CQBuJ ILJqJnQT4bjgWWrrPS/q0yFNi9q3ulge61pZfq4rH5UojY1IrsPDeoVf2V+1/uPPyTW1IjlZEcYmS eOv0nGunmtBRbciZxu/8wWIaZfFE/hCtC8lOfug6zuaJvb6yKECAcOzPH8OqNSDBzQKB3oJEFH0RT g4RM4JQJk++ObZDo8Yz9MD9H9FqrXh6lVuM6GUkJswWCjBZimdS5xnrPKEifTUSwCilOgIRVBPCZq 28BMv/G11UwINxDwT09Qqw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGP4e-0008BT-01; Mon, 03 Jul 2023 15:19:00 -0400 Date: Mon, 03 Jul 2023 22:19:37 +0300 Message-Id: <831qhon6pi.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <87h6qkrfjy.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> <87leilkl3i.fsf@catern.com> <837ctnjor8.fsf@gnu.org> <87h6qkrfjy.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Mon, 03 Jul 2023 18:54:58 +0000 (UTC) > Cc: Stefan Monnier , Lars Ingebrigtsen > , 62732@debbugs.gnu.org > > > 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. > > Eli Zaretskii writes: > > Stefan, Lars: any comments? I still want to hear someone else's opinion, because the changeset looks waaay larger and more complex than can be justified by the tiny problem in rare corner situations that triggered it. If no one else is interested enough to voice any opinion, I tend to "wontfix" it, TBH. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 08 13:49:05 2023 Received: (at 62732) by debbugs.gnu.org; 8 Jul 2023 17:49:06 +0000 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 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 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) 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== 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) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:30:28 -0400") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> Date: Sat, 08 Jul 2023 13:48:55 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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)))) > From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 10:49:32 2023 Received: (at 62732) by debbugs.gnu.org; 9 Jul 2023 14:49:33 +0000 Received: from localhost ([127.0.0.1]:46983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIVjA-0001in-Gr for submit@debbugs.gnu.org; Sun, 09 Jul 2023 10:49:32 -0400 Received: from s.wrqvtbkv.outbound-mail.sendgrid.net ([149.72.123.24]:36106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIVj8-0001ia-6Y for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 10:49:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=Q0AC9LCvwlAI5F5LEYTeFmfQVxPkqIQy6ccZSVzIQJM=; b=ZVi8OImeWOZoGsEA4JVxVMa2qcsmyfPkWDklBCZeSVHodjEigMeWxt7KHXaxK2vTYCto cB8LgpUSKFx/oJX9QKV3aTtCZ9CO/VYa+h8Tjl+4aor2c+TawwEX92Q0J9/HocV1gAUq8K NdnTWCPQ80s9X1W06fnPeMETjuqaPt/I7VRKw5q0qqDx34fqS6RPPxnzPZlpbDXevWdcbd /15n59tVykunmJR7w88JMD6VTo5TVJ11oaaKkcHCPKIxSnu2KEtGiC69BGnR4pabdbGvFM QWG9IAhTs4jmA5ciwM9SWnCPRa/QNRizptclfbnqSV8GIeMKJx8ZJy7a2elfu7oQ== Received: by filterdrecv-66949dbc98-gwbzx with SMTP id filterdrecv-66949dbc98-gwbzx-1-64AAC8F4-17 2023-07-09 14:49:24.70791341 +0000 UTC m=+5152176.490730328 Received: from earth.catern.com (unknown) by geopod-ismtpd-0 (SG) with ESMTP id Yo7Qb36mQ3Gr_QPX11zyGQ Sun, 09 Jul 2023 14:49:24.555 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=iro.umontreal.ca Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 0DC3F60077; Sun, 9 Jul 2023 10:49:23 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Sat, 08 Jul 2023 13:48:55 -0400") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87a5zhmexh.fsf@catern.com> Date: Sun, 09 Jul 2023 14:49:24 +0000 (UTC) Message-ID: <87h6qdm970.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbK6mWrOJW9S248jf8F2zd?= =?us-ascii?Q?=2FLlSA4SWAyIihuHZsV8Ai9eKsB0zAteHJhjAbKF?= =?us-ascii?Q?S5coM1K4eT8rTysm9fx5RWlVoAnziBVxGKgM=2FVJ?= =?us-ascii?Q?5B6sIFRyXIVwC4vhOrK0n2hcogoW=2F+F0gI+FbBQ?= =?us-ascii?Q?02iywDp9DnPRZIvHpTHG9p78sJJhX7KIj+A=3D=3D?= To: Stefan Monnier X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> 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. Ah, that unfortunately doesn't work, at least on its own. It causes the tests I added for uniquify to immediately fail. The reason it doesn't work, I believe, is that it makes us try to uniquify buffers with their numeric suffix included (which is the initial name the buffer gets). And such buffers are of course already unique, so uniquify stops doing anything. We could remove the suffix, but what we really want is just "the name we wanted to give the buffer, before any uniquifying", aka the basename. And we have that in create-file-buffer, so it seems better to just pass it down directly. > If we can't avoid changing the API of `create-file-buffer`, I'd like > a comment explaining clearly why. So, the thing we want to communicate to uniquify is, the basename of the buffer: the name we want for the buffer before it's made unique. For regular files this is (file-name-nondirectory file), the last component of the file name. Before this patch, the basename (as passed to uniquify) was always (file-name-nondirectory (directory-file-name dir)) for directories. So directories and regular files looked the same to uniquify. So it needed to add the trailing separator some other way (by checking file-directory-p). After this patch, the trailing separator is added *as part of the basename* as passed to uniquify. So uniquify doesn't need to do anything, just uniquify the buffer like it would any other, and indeed uniquify.el no longer uses uniquify-trailing-separator-p at all. > 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? It is added in create-file-buffer, in the calculation of basename. > And why is the arg called `directory`? Because we are indicating that this filename is a directory, or at least that we want to visit this filename as if it was a directory. > And why/when is that arg needed, since the separator will often be > introduced anyway by uniquify even with a nil arg? This is now the only place that uniquify-trailing-separator-p is used, so the separator won't be introduced if DIRECTORY is nil. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 11:38:57 2023 Received: (at 62732) by debbugs.gnu.org; 9 Jul 2023 15:38:57 +0000 Received: from localhost ([127.0.0.1]:46989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIWUy-0002s0-Ux for submit@debbugs.gnu.org; Sun, 09 Jul 2023 11:38:57 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:38976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIWUu-0002rf-PZ for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 11:38:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=jUsELwxdb7ddXHKLHU44T2BC/UZcaHYLVAdGJJBxRWg=; b=mf9YNOTOMGBNU/JVaITHoyyuBNMHr9Jiv1zOjUcbV5U29yzSJrtJ8Mjo8m41RpnSy4YU 3Slgq3JrsRXE0P2sZAAx2TMTVgP01krV+n+6kx8tgGQ4bBLtXfohnyoHF2ZPeZWDA0q5wB dzvO8H2V6ztzvLh8UTMKFaWbh02G8rXNcW0OtlVwrdrHVF4RKSSvnkgQW54nJMVHCsvujN ErA9l13Wis2uFk4xeRmMRpee2XUgXaEPMBFQpyuGJAUMMUyUjP2dG4jltXwxzPbfHmJfdI asqz9yUAwGFUFkqcnacR7VVxQD6U8bsn/xVDSPTUo92WFUv7Mz0rC9ulDYrMAgFg== Received: by filterdrecv-84b96456cb-6l8hp with SMTP id filterdrecv-84b96456cb-6l8hp-1-64AAD486-F 2023-07-09 15:38:46.347736046 +0000 UTC m=+5155216.943145572 Received: from earth.catern.com (unknown) by geopod-ismtpd-24 (SG) with ESMTP id JpByjBsfRamGnQsc9YE1xQ Sun, 09 Jul 2023 15:38:46.175 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=iro.umontreal.ca Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id ACD266016A; Sun, 9 Jul 2023 11:38:45 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Fri, 05 May 2023 16:13:52 -0400") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> Date: Sun, 09 Jul 2023 15:38:46 +0000 (UTC) Message-ID: <87edlhm6wq.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbLYDRRWAdCrwe=2FrlQ+y3R?= =?us-ascii?Q?OIrtmltgL6XTJQdwvTGbkD5n3jYbclNPoTB4Wob?= =?us-ascii?Q?1WKe30+PoSLPrNx90Y58B2hFcaQK1ZRNEzRwfw6?= =?us-ascii?Q?8GL9x0P4rMoPYVds7aI8O8MWHqovZ0ZBtWbPCSP?= =?us-ascii?Q?PbDcNV1p8Twe6KPvA8FF=2FbzoUvf+0DjwXsA=3D=3D?= To: Stefan Monnier X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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=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`. 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: diff --git a/lisp/dired.el b/lisp/dired.el index d14cf47ffd5..3c9e6e40f9b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..4b5a877d1e3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,30 @@ find-alternate-file (kill-buffer obuf)))))) =0C ;; 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) "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. =20 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." - (let* ((lastname (file-name-nondirectory filename)) - (lastname (if (string=3D lastname "") - filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + (let* ((lastname (if (directory-name-p filename) + (file-name-nondirectory (directory-file-name filena= me)) + (file-name-nondirectory 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)) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) =20 (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..bfb61eca16d 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) =20 ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname it= em))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) =20 -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing s= lash. =20 - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string=3D old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,13 +478,13 @@ uniquify--rename-buffer-advice =20 =20 ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-= advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style (let ((filename (expand-file-name (directory-file-name filename)))) (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) + basename (file-name-directory filename) buf)))) =20 From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 12:16:13 2023 Received: (at 62732) by debbugs.gnu.org; 9 Jul 2023 16:16:13 +0000 Received: from localhost ([127.0.0.1]:47009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIX52-0003w2-R2 for submit@debbugs.gnu.org; Sun, 09 Jul 2023 12:16:13 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIX50-0003vn-55 for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 12:16:11 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4A3A0440F61; Sun, 9 Jul 2023 12:16:04 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BD2A6441035; Sun, 9 Jul 2023 12:15:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1688919358; bh=VlNjqL7kTC51JhdGUQcvhN5EAAIBqXOx6VS6ziiv/IA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nY7lZxvZDsCkzwqiOTpKhhfEP+px96IGCENHGBX+KJbyyob829Y7DKleiqHm4E0C9 GVQAIsXH7n8Tz5aWa3IxYPrXWJGLMOUj8TnS3hC50HTiMmw/6u9ED7o4IvyBCHOjAG 8EmL98t6wUTE8INqZfwlRTc8GygFMd8k0zRkyCngdEp/Eoh0f7CxdRSGvGY7iJjeKJ o13nIDh3pFbu1QF29MYJe3JFQVobDzOWnpfjSqQNskkw2+SPWGdL78u5KB233NSLH1 XmtsyHAwzKyh+BMmzIX+xTbAaKIiJhU1tybw/MOg3J9bqbkgIQRPDmXXzU5ZLL+A56 QXFGrU+RZxPtA== Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8C0881202C3; Sun, 9 Jul 2023 12:15:58 -0400 (EDT) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87edlhm6wq.fsf@catern.com> (sbaugh@catern.com's message of "Sun, 09 Jul 2023 15:38:46 +0000 (UTC)") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> Date: Sun, 09 Jul 2023 12:15:58 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.279 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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, Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 21:36:12 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 01:36:12 +0000 Received: from localhost ([127.0.0.1]:47309 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIfox-0002Je-2K for submit@debbugs.gnu.org; Sun, 09 Jul 2023 21:36:12 -0400 Received: from s.wrqvtbkv.outbound-mail.sendgrid.net ([149.72.123.24]:32576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIfos-0002Iu-6n for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 21:36:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=AYRQ5wNp8IFTjCVhfQ5BZSsvHU9+dHVS4RDVhhwHdCM=; b=lUY6bq3gqCEtuKUIL6yu/iTCKdbpLvO/Blz8YTwrQ+6d/3zf1ifz3lMjXtpykXqCHxRj 64h8GYFITQ21qFF4Opp7oaYCCbCFt0PKeSc6ndMg2sjA0EGMB6xppawiaZw+UON+u70C1N kZNlRRbQ+NTipJqgfD4UmWOosNXfym7BvVuhuSqvJTUHQoCEGHmWdJEesA0arFkQNgEsNt M76s5cJCWJjILIBfAevZ2BFQhjbT8u7zsABxntXRTLmqLAKUE5IiPVnCMB50fBtoKc4z2t D9LrZCWw8t2vvyhKmoyyCSD5bIeIT/pVTUocLyguoZoZA24TX/cMghp6Am9o4I8w== Received: by filterdrecv-66949dbc98-p7b6v with SMTP id filterdrecv-66949dbc98-p7b6v-1-64AB6080-18 2023-07-10 01:36:00.641123427 +0000 UTC m=+5190974.692755383 Received: from earth.catern.com (unknown) by geopod-ismtpd-22 (SG) with ESMTP id xOSBESbrQ5a5WVimM4TRhw Mon, 10 Jul 2023 01:36:00.490 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=iro.umontreal.ca Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 0EF086016A; Sun, 9 Jul 2023 21:36:00 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Sun, 09 Jul 2023 12:15:58 -0400") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> Date: Mon, 10 Jul 2023 01:36:00 +0000 (UTC) Message-ID: <87o7kklf9c.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbLYiKz3yMGw8pAU5CrcTd?= =?us-ascii?Q?V6hGP=2FGpJBzd6DAJP1Kx5cCniTeQWhlVkB5nxAS?= =?us-ascii?Q?IOE2CL9tQTLx7bZQ8Syhg61B8d9h0LML82OMw07?= =?us-ascii?Q?9uMIOpG+V6zcbubINDdleCKNC0wEN7g9lxLUksK?= =?us-ascii?Q?Ul=2F6ZJVgf2uwl8d9+vw+WTjdLRSNNYk8V2Q=3D=3D?= To: Stefan Monnier X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Stefan Monnier writes: >> 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-recalculate-the-buffer-basename-inside-uniquif.patch >From 46804cd388d3ca05c0ad2054a0fcf3aba80b651c Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 9 Jul 2023 10:24:33 -0400 Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Previously, uniquify--create-file-buffer-advice would use the filename of the buffer to calculate what the buffer's basename should be. Now that gets passed in from create-file-buffer, which lets us fix several bugs: 1. before this patch, if a buffer happened to be named the same thing as directory in its default-directory, the buffer would get renamed with a directory separator according to uniquify-trailing-separator-p. 2. buffers with a leading space should get a leading |, as described by create-file-buffer's docstring; before this patch, uniquify would remove that leading |. * lisp/dired.el (dired-internal-noselect): Pass a directory name to create-file-buffer. * lisp/files.el (create-file-buffer): Do uniquify-trailing-separator-p handling if passed a directory filename. * lisp/uniquify.el (uniquify-item): (uniquify-rationalize-file-buffer-names, uniquify-rationalize, uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): Remove uniquify-trailing-separator-p handling. (uniquify--create-file-buffer-advice): Take new basename argument and use it, instead of recalculating the basename from the filename. --- lisp/dired.el | 2 +- lisp/files.el | 26 +++++--- lisp/uniquify.el | 39 ++++------- test/lisp/uniquify-tests.el | 129 ++++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 37 deletions(-) create mode 100644 test/lisp/uniquify-tests.el diff --git a/lisp/dired.el b/lisp/dired.el index d14cf47ffd5..3c9e6e40f9b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..4b5a877d1e3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,30 @@ find-alternate-file (kill-buffer obuf)))))) ;; 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) "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." - (let* ((lastname (file-name-nondirectory filename)) - (lastname (if (string= lastname "") - filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + (let* ((lastname (if (directory-name-p filename) + (file-name-nondirectory (directory-file-name filename)) + (file-name-nondirectory 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)) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..d1ca455b673 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname item))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string= old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,15 +478,14 @@ uniquify--rename-buffer-advice ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style - (let ((filename (expand-file-name (directory-file-name filename)))) - (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) - (file-name-directory filename) - buf)))) + (uniquify-rationalize-file-buffer-names + basename + (file-name-directory (expand-file-name (directory-file-name filename))) + buf))) (defun uniquify-unload-function () "Unload the uniquify library." diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..abd61fa3504 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,129 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniquify + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buffer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-ignored () + "If uniquify-buffer-name-style isn't forward or reverse, +uniquify-trailing-separator-p is ignored" + (let ((uniquify-buffer-name-style 'post-forward-angle-brackets) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-space-prefix () + "If a buffer starts with a space, | is added at the start" + (save-excursion + (find-file " foo") + (should (equal (buffer-name) "| foo")) + (kill-buffer))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 22:05:05 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 02:05:05 +0000 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 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 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) 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== 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) From: Stefan Monnier To: "Eli Zaretskii" Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87o7kklf9c.fsf@catern.com> (sbaugh@catern.com's message of "Mon, 10 Jul 2023 01:36:00 +0000 (UTC)") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> Date: Sun, 09 Jul 2023 22:04:54 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.125 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 22:55:38 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 02:55:38 +0000 Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIh3p-0004YO-Dd for submit@debbugs.gnu.org; Sun, 09 Jul 2023 22:55:38 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:4040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIh3k-0004Y1-Fr for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 22:55:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=uFRyYbm3GSkuO3R5B2xPtdsjW7Y6VhcY/I0fwzgRzE8=; b=wXr28QjlEEiZ28/VL0vEHs+Dgp4K0LraZq1C1XmWJEe17+697UlzOPvhpfq8DrAmOn3L Ex6/EKnwFDNXL7t4fONdeJoIVpNGG1BkflqwS/2l3KuEtr4+FZBTpD+LBYzoYcnpyi8e1k eW5UfLG5ZmoxIp9aL7ALgwFBElxc+B6gN2GQ4CVF7p12hwqo8N2ro/HSufQhUCr1ycVKTH Ukshl6XIF+Qe677scbQEXhaWg+N4wDY/mx6KbPb065E81miZCAOFobiDHZUskoIei3lYXx feBiGH5piOTD5idGCn0o+CE/XV00EQiYBhKPWh6/ZDEtH1JSu0SX7VDmPzLcAXvA== Received: by filterdrecv-d7bbbc8bf-pldp9 with SMTP id filterdrecv-d7bbbc8bf-pldp9-1-64AB731E-21 2023-07-10 02:55:26.941619254 +0000 UTC m=+5195736.423576764 Received: from earth.catern.com (unknown) by geopod-ismtpd-13 (SG) with ESMTP id XYgu2vm2SgKq-4p1z6j-0A Mon, 10 Jul 2023 02:55:26.744 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=iro.umontreal.ca Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 498F26251B; Sun, 9 Jul 2023 22:55:26 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Stefan Monnier's message of "Sun, 09 Jul 2023 22:04:54 -0400") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> Date: Mon, 10 Jul 2023 02:55:26 +0000 (UTC) Message-ID: <87zg44jx0h.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbIGZ81a+TGt7j=2F7oYPDxi?= =?us-ascii?Q?pq8eiulZb43kHdwaJV=2FlusLbJid0Jg0C376zDIn?= =?us-ascii?Q?NhnoYMtD06ur8+mYQhVv7PRQKpyarjTqzFnQRI3?= =?us-ascii?Q?sHhI2ImgOtBJAf2zuumFwW1nAgWIzsYJWBWlTEx?= =?us-ascii?Q?dSnGpfBn03us=2Fg5kfH0euUS1Mh57wZYQKcg=3D=3D?= To: Stefan Monnier X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: Eli Zaretskii , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Stefan Monnier writes: >>>> 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))) Absolutely, makes sense. >> + (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) Yes, makes sense. Revised patch for these two below. > and since we know (directory-name-p filename), I'd be tempted to replace > (file-name-as-directory lastname) with just `filename`. (file-name-as-directory lastname) and filename are different though: the former is only the last component of filename, but as a directory name. The latter is the full filename, which is not what the basename of the buffer should be. (since it gets no further processing) > 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? I agree that would be good (modulo that it does need to be (file-name-as-directory lastname) rather than filename), but it would change the existing behavior and not comply with the docstring of `uniquify-trailing-separator-p'. (I think it would be a reasonable change though, but probably as a subsequent change) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-recalculate-the-buffer-basename-inside-uniquif.patch >From 023b8e7a715374e59a5456075b98d1422659cfe6 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 9 Jul 2023 10:24:33 -0400 Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Previously, uniquify--create-file-buffer-advice would use the filename of the buffer to calculate what the buffer's basename should be. Now that gets passed in from create-file-buffer, which lets us fix several bugs: 1. before this patch, if a buffer happened to be named the same thing as directory in its default-directory, the buffer would get renamed with a directory separator according to uniquify-trailing-separator-p. 2. buffers with a leading space should get a leading |, as described by create-file-buffer's docstring; before this patch, uniquify would remove that leading |. * lisp/dired.el (dired-internal-noselect): Pass a directory name to create-file-buffer. * lisp/files.el (create-file-buffer): Do uniquify-trailing-separator-p handling if passed a directory filename. (bug#62732) * lisp/uniquify.el (uniquify-item): (uniquify-rationalize-file-buffer-names, uniquify-rationalize, uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): Remove uniquify-trailing-separator-p handling. (uniquify--create-file-buffer-advice): Take new basename argument and use it, instead of recalculating the basename from the filename. --- lisp/dired.el | 2 +- lisp/files.el | 25 ++++--- lisp/uniquify.el | 39 ++++------- test/lisp/uniquify-tests.el | 129 ++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 test/lisp/uniquify-tests.el diff --git a/lisp/dired.el b/lisp/dired.el index d14cf47ffd5..3c9e6e40f9b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..f1b3b6be4f4 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,29 @@ find-alternate-file (kill-buffer obuf)))))) ;; 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) "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." - (let* ((lastname (file-name-nondirectory filename)) - (lastname (if (string= lastname "") - filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + (let* ((lastname (file-name-nondirectory (directory-file-name filename))) + (lastname (cond + ((not (and uniquify-trailing-separator-p (directory-name-p filename))) + lastname) + ((eq uniquify-buffer-name-style 'forward) + (file-name-as-directory lastname)) + ((eq uniquify-buffer-name-style 'reverse) + (concat (or uniquify-separator "\\") lastname)) + (t lastname))) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..d1ca455b673 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname item))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string= old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,15 +478,14 @@ uniquify--rename-buffer-advice ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style - (let ((filename (expand-file-name (directory-file-name filename)))) - (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) - (file-name-directory filename) - buf)))) + (uniquify-rationalize-file-buffer-names + basename + (file-name-directory (expand-file-name (directory-file-name filename))) + buf))) (defun uniquify-unload-function () "Unload the uniquify library." diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..abd61fa3504 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,129 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniquify + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buffer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-ignored () + "If uniquify-buffer-name-style isn't forward or reverse, +uniquify-trailing-separator-p is ignored" + (let ((uniquify-buffer-name-style 'post-forward-angle-brackets) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-space-prefix () + "If a buffer starts with a space, | is added at the start" + (save-excursion + (find-file " foo") + (should (equal (buffer-name) "| foo")) + (kill-buffer))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 09 23:39:00 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 03:39:00 +0000 Received: from localhost ([127.0.0.1]:47360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIhjn-00065c-W1 for submit@debbugs.gnu.org; Sun, 09 Jul 2023 23:39:00 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIhjk-00065F-JX for 62732@debbugs.gnu.org; Sun, 09 Jul 2023 23:38:59 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1C5131000BA; Sun, 9 Jul 2023 23:38:51 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 269C2100091; Sun, 9 Jul 2023 23:38:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1688960330; bh=YETh5Bg67S2BjmLaURc2P2UOtP/lsY0qN+xXDJy0kL0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Uj6DrwjJv7g/9+wLe+i/tp1PzX2lIgBEBB8Aoa5Qz7oEVqAi3caP0pUwpfqFuamrO OvV1uNCvZknLi8N479NruDobmugc/+KpxPeMbtOeYP8YzVv/+L9QRzvrcl5A47g1dA JEs7tvjJhFq8oxOJhd74cZ0+patC0850MJq/tf9B0WLNdGODSqMd6ve+oMb/8MEwdM 5gf2LBuWeoiTQnvBN+1LMDLlnoWLkLNUPufLdyIE1ntGIL3LFQ4fI+9fs8Cx/UEsJb HlqOeDxRjMHoDAx0YdqntKEXJ37JtdcPm3yfd7yPtxyE/nx7LuqA8KC49uijS9WBIc lCFCbbYlMj8Ig== Received: from pastel (unknown [24.140.234.50]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F33261200FC; Sun, 9 Jul 2023 23:38:49 -0400 (EDT) From: Stefan Monnier To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87zg44jx0h.fsf@catern.com> (sbaugh@catern.com's message of "Mon, 10 Jul 2023 02:55:27 +0000 (UTC)") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <87zg44jx0h.fsf@catern.com> Date: Sun, 09 Jul 2023 23:38:49 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: Eli Zaretskii , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> and since we know (directory-name-p filename), I'd be tempted to replace >> (file-name-as-directory lastname) with just `filename`. > > (file-name-as-directory lastname) and filename are different though: the > former is only the last component of filename, but as a directory name. Duh! You're right. > I agree that would be good (modulo that it does need to be > (file-name-as-directory lastname) rather than filename), but it would > change the existing behavior and not comply with the docstring of > `uniquify-trailing-separator-p'. (I think it would be a reasonable > change though, but probably as a subsequent change) Good point. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 08:56:40 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 12:56:40 +0000 Received: from localhost ([127.0.0.1]:47931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIqRU-0001yS-1M for submit@debbugs.gnu.org; Mon, 10 Jul 2023 08:56:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIqRQ-0001yA-9S for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 08:56:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIqRK-0008Cz-J0; Mon, 10 Jul 2023 08:56:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=W9EqjNQZ4w2c0J4WrgQEDBaM3w3R0uZGH19ApMA6o5Y=; b=bBg5U14dk2H9 xGwLdafo/hBwGE9OWvlj/r0W5z8eCTeha2u4HAwkh1hZZzoz+DElbUut+QoABHE/D72xGtj+9rmNA d/BtEdvAVpXe63aBt8mGvXZd8GMW9bNlnkbIquCRHQdLl2/LdXrCUfH36YYUMpmcQ3ZnsxD0XKjUP Fq5+2xINWgirSUfcoX/MJUM2N7QgQTrOmqtpnuM4AVgfhlyLAkgBHz4R4AvgXxO1ivuH8vsocan42 K7NtJIkkAreLujy6WNc1FhzHnx+v+WEOFttfxB79CuDXETHWGy5wIsC/HouOdSarl9j5awjJuE11m YFhXdFCc012gL/3fgLGNwQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIqRI-0003JB-M2; Mon, 10 Jul 2023 08:56:30 -0400 Date: Mon, 10 Jul 2023 15:56:38 +0300 Message-Id: <83r0pf9b7d.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <87o7kklf9c.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 62732@debbugs.gnu.org > From: sbaugh@catern.com > Date: Mon, 10 Jul 2023 01:36:00 +0000 (UTC) > > Great! Here's that as a complete patch again. > --- a/lisp/dired.el > +++ b/lisp/dired.el > @@ -1306,7 +1306,7 @@ dired-internal-noselect > ;; Note that buffer already is in dired-mode, if found. > (new-buffer-p (null buffer))) > (or buffer > - (setq buffer (create-file-buffer (directory-file-name dirname)))) > + (setq buffer (create-file-buffer dirname))) This seems to imply that callers of create-file-buffer will now have to remember to ensure the argument ends in a slash if it is the name of a directory. If so, I'd prefer that create-file-buffer did that internally, when its argument is a directory. Callers shouldn't know to much about the internals of the callee. Does this changeset have any user-facing behavior changes? If so, they should be at least in NEWS. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 08:57:15 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 12:57:15 +0000 Received: from localhost ([127.0.0.1]:47936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIqS3-000209-CN for submit@debbugs.gnu.org; Mon, 10 Jul 2023 08:57:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIqRz-0001zm-RQ for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 08:57:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIqRu-0008Ip-JM; Mon, 10 Jul 2023 08:57:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=/g518DF8Olx3xXZ9W3fSfZswVfM6CdeE7pBgeIKw7DA=; b=TGzhxjOgsJu3 gau4u2/tDMNqnAMEzjLLmATvlJz/2eGyFIDg92SCXj5/DXC55L9DnO6wnLWQYaM08GSP708lgp901 fIwuhy7LKlD6VjG88RU8lNEQB3IXhPyr6xDFoiuarY7xBbnB8Hw1nfsojtZKYy9/kUQudigRhlBFs ENFHw8CaLabtNhtk1Wpli1yQ3JGXhNK3HP+ApesUeVdRrNJ9wVMKzR/rL9ZFRCes79giY569hy7vo gIypN1ZhBbfUBar6E/8mU+tAe3n2RFy22ZSql0kkc8DcbqzKB5CQz2a7767PNuIoKw2NJrZIb/pUA bJGqvjiP9vuGTazryyXcHw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIqRu-0003SC-3A; Mon, 10 Jul 2023 08:57:06 -0400 Date: Mon, 10 Jul 2023 15:57:15 +0300 Message-Id: <83pm4z9b6c.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sun, 09 Jul 2023 22:04:54 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: 62732@debbugs.gnu.org, sbaugh@catern.com > Date: Sun, 09 Jul 2023 22:04:54 -0400 > > >>> 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`? Yes, but see my comments to the patch. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 09:39:19 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 13:39:19 +0000 Received: from localhost ([127.0.0.1]:48027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIr6l-00039U-51 for submit@debbugs.gnu.org; Mon, 10 Jul 2023 09:39:19 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:35659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIr6h-00039G-Lh for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 09:39:17 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83r0pf9b7d.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 10 Jul 2023 15:56:38 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> Date: Mon, 10 Jul 2023 09:39:10 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Cc: 62732@debbugs.gnu.org >> From: sbaugh@catern.com >> Date: Mon, 10 Jul 2023 01:36:00 +0000 (UTC) >> >> Great! Here's that as a complete patch again. > >> --- a/lisp/dired.el >> +++ b/lisp/dired.el >> @@ -1306,7 +1306,7 @@ dired-internal-noselect >> ;; Note that buffer already is in dired-mode, if found. >> (new-buffer-p (null buffer))) >> (or buffer >> - (setq buffer (create-file-buffer (directory-file-name dirname)))) >> + (setq buffer (create-file-buffer dirname))) > > This seems to imply that callers of create-file-buffer will now have > to remember to ensure the argument ends in a slash if it is the name > of a directory. If so, I'd prefer that create-file-buffer did that > internally, when its argument is a directory. Callers shouldn't know > to much about the internals of the callee. I can (and should) add this to the docstring of create-file-buffer. It seems intuitive to me that the last non-empty component of the filename passed in by the caller is what create-file-buffer uses, including if that "last component" ends in a slash. (It's a nice way to avoid the additional DIRECTORY argument which says whether the filename is intended to refer to a directory) By doing this internally in create-file-buffer, you mean running file-directory-p to see if the filename actually points to an existing directory? I'm hesitant to do that: - That prevents running create-file-buffer to create a buffer to visit a directory which does not yet exist (in the same way you can visit a file which does not yet exist). dired doesn't currently support that but other packages might want to. - Checking file-directory-p is what uniquify did which caused these bugs in the first place, and I think this could partially recreate the same bug, where we add a trailing slash just because there happens to be a directory of the right name. (Although I'm not sure, just worried) - It adds filesystem access to what is currently a pure function. > Does this changeset have any user-facing behavior changes? If so, > they should be at least in NEWS. The only user-facing behavior change is fixing the two bugs mentioned in the commit message. Is that appropriate to include in NEWS? From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 10:25:48 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 14:25:48 +0000 Received: from localhost ([127.0.0.1]:48928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIrpj-0004Zg-Pe for submit@debbugs.gnu.org; Mon, 10 Jul 2023 10:25:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIrpe-0004ZM-RE for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 10:25:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIrpX-0004LA-QK; Mon, 10 Jul 2023 10:25:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=s2hARU43Ixusy/v2f+K2Z5HW68lWAv/i8oyXqZ4jFW4=; b=kZlDOJVxT9S5 cPlaNa+jDKmHIClFOaL/D4wvzAoDAkEN9eD3mGm2plsky5YrXBp/VT6inb+qSaCNZi0wKu0AlQhyb tRJfC8MMPNaqNGH3Jk/+pZgQ1+Rjnghp4wC1U81568ZgmMWDMIVOqyEPdHEcLwvGdAW5qjW32jXEE jze42V5kOLwi5RNJb9S8TcUNy8whHU+XEU/oLQf262EBJP5+3x1b6NAgdTi2sQhCAVhKTvINCxnBp m0WRCUdcBtQ+48lTjgzCqfCw0l3yci6MZRGbmP5Y/jApNOnXSBgfRqH5ntcoOXD7y6BoH5X/ycCjC ue7OTven0iqH2J8TrqSHOA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIrpX-0005sy-AN; Mon, 10 Jul 2023 10:25:35 -0400 Date: Mon, 10 Jul 2023 17:25:45 +0300 Message-Id: <83jzv7972u.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Mon, 10 Jul 2023 09:39:10 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: sbaugh@catern.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org > Date: Mon, 10 Jul 2023 09:39:10 -0400 > > Eli Zaretskii writes: > > >> - (setq buffer (create-file-buffer (directory-file-name dirname)))) > >> + (setq buffer (create-file-buffer dirname))) > > > > This seems to imply that callers of create-file-buffer will now have > > to remember to ensure the argument ends in a slash if it is the name > > of a directory. If so, I'd prefer that create-file-buffer did that > > internally, when its argument is a directory. Callers shouldn't know > > to much about the internals of the callee. > > I can (and should) add this to the docstring of create-file-buffer. It > seems intuitive to me that the last non-empty component of the filename > passed in by the caller is what create-file-buffer uses, including if > that "last component" ends in a slash. (It's a nice way to avoid the > additional DIRECTORY argument which says whether the filename is > intended to refer to a directory) If the only reason is to avoid an additional argument, I'd prefer an additional argument. Documenting a problematic design doesn't mean the design ceases to be problematic, and relies too heavily on people paying attention to subtle aspects of the documented behavior. > By doing this internally in create-file-buffer, you mean running > file-directory-p to see if the filename actually points to an existing > directory? I'm hesitant to do that: > > - That prevents running create-file-buffer to create a buffer to visit a > directory which does not yet exist (in the same way you can visit a file > which does not yet exist). dired doesn't currently support that but > other packages might want to. Didn't that problem exist before your changes? And anyway, if we want to support that, adding an extra variable, or even requiring the trailing slash only for non-existing directories, would be a better solution. > - Checking file-directory-p is what uniquify did which caused these bugs > in the first place, and I think this could partially recreate the same > bug, where we add a trailing slash just because there happens to be a > directory of the right name. (Although I'm not sure, just worried) I don't see why that would follow. It is a very minor change in the code, and doesn't affect the logic, AFAICT. > - It adds filesystem access to what is currently a pure function. But create-file-buffer is not documented as not hitting the disk, so I don't see a problem here. > > Does this changeset have any user-facing behavior changes? If so, > > they should be at least in NEWS. > > The only user-facing behavior change is fixing the two bugs mentioned in > the commit message. Is that appropriate to include in NEWS? Does the fix result in different buffer names? If so, it is not just a bugfix, it changes user-facing behavior. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 12:53:14 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 16:53:14 +0000 Received: from localhost ([127.0.0.1]:49031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIu8Q-00005m-GG for submit@debbugs.gnu.org; Mon, 10 Jul 2023 12:53:14 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32277) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIu8O-00005Y-Gj for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 12:53:13 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D04BA4417FA; Mon, 10 Jul 2023 12:53:06 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E42384417E0; Mon, 10 Jul 2023 12:53:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689007980; bh=kCeA65A+kv9Aja9NQRKz/FtR7YZKPUtgehOvgIsLKOo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nL155+Mjc1FxafxhrYixFS5JmjlhVkBRQWkDmLsC/VAEN/a05XEnqUewNv+p3Nunm VaM8DllVDbdENts3Vat2bTA6odotMRD/NF7AtsgbFo9ifCp6td4/SpQxCYaHoScNLW vHX5k1jkjLQl5CUXuKLlSO1cjN8/6an6kmKcfbQ6k8TKivrhMANTZ++ZGBqH9k5R3S GPMwd7A7zo7vhspvGKsVxMnJpQHbHYSLdnf33TfQOoQ8koFE9uDzoEN6XC5Mm8If3o EWvG2wfkrZ3Nno3FXR4lPzJ3iIdEYxE6X+tVZLXgewSRLER28//wYG4AXIYHnAkjjP x19Obt6660vfg== Received: from pastel (unknown [24.140.234.50]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B9415120330; Mon, 10 Jul 2023 12:53:00 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83r0pf9b7d.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 10 Jul 2023 15:56:38 +0300") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> Date: Mon, 10 Jul 2023 12:53:00 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.139 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> --- a/lisp/dired.el >> +++ b/lisp/dired.el >> @@ -1306,7 +1306,7 @@ dired-internal-noselect >> ;; Note that buffer already is in dired-mode, if found. >> (new-buffer-p (null buffer))) >> (or buffer >> - (setq buffer (create-file-buffer (directory-file-name dirname)))) >> + (setq buffer (create-file-buffer dirname))) > > This seems to imply that callers of create-file-buffer will now have > to remember to ensure the argument ends in a slash if it is the name > of a directory. Which callers are you thinking of? I think the fact that the callers get to control this regardless of whether there is a file or directory by that name is one of the best part of this change. > If so, I'd prefer that create-file-buffer did that internally, when > its argument is a directory. What would be the benefit? > Callers shouldn't know to much about the internals of the callee. Indeed: currently `create-file-buffer` doesn't pay attention to the file system at all, it just creates a buffer with a name based on the FILENAME that's passed. Spencer's patch just offers more control to the callers by making `create-file-buffer` respect the choice of the callers (whether they used a file name or a dire name, which is an important distinction in Emacs's file name APIs, not just here). There's no need for the callers to know about the internals of the callee. If they call `create-file-buffer` with /foo/bar/baz the buffer will be called "baz" and if they call it with /foo/bar/baz/ the buffer will be called "baz/" (depending on `uniquify-trailing-separator-p`, of course). It's the most natural/obvious semantics. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 15:12:31 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 19:12:31 +0000 Received: from localhost ([127.0.0.1]:49153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIwJC-0003k3-Sy for submit@debbugs.gnu.org; Mon, 10 Jul 2023 15:12:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIwJA-0003jq-JN for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 15:12:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIwJ5-0002pj-1H; Mon, 10 Jul 2023 15:12:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=nMqQGS8Hmf9BWolGlZSVlhdCIgoUfmE3ceWidDCUN0U=; b=c+/MO8+A5qiD NE454NvsxLrZK4A1tM952ZHK2/aeYrdV1mHG86IdvL3okITomiEm+XPrXiqRgy0OL3TL8/98sj9Q9 l9J+JsFl+O2PrBG+rlsHM2zlYVMisHI2Xs8rFGSewIWT1tBwi1khFXkTRkTShoBeXBGWxaw+76gqG YWhqU+vJmPhzqNgjpUEGmolz/9uqgz2HWS+rHK2vUXamaj+xWcjyh0buqKCkT1FWmonAdwxNyCuF7 tVXL7JNC5V6CDvoRztCfk5hIxhq+zd/iTRb53h7YlaUlw6h+HpmTzYBto0DBQq6htLY2JOz6SJTW4 NQEBbyV6QvEmQmaFDVO8sA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIwJ4-00007A-HP; Mon, 10 Jul 2023 15:12:22 -0400 Date: Mon, 10 Jul 2023 22:12:31 +0300 Message-Id: <83fs5v8tsw.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Mon, 10 Jul 2023 12:53:00 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: sbaugh@catern.com, 62732@debbugs.gnu.org > Date: Mon, 10 Jul 2023 12:53:00 -0400 > > > Callers shouldn't know to much about the internals of the callee. > > Indeed: currently `create-file-buffer` doesn't pay attention to the file > system at all, it just creates a buffer with a name based on the > FILENAME that's passed. Spencer's patch just offers more control to the > callers by making `create-file-buffer` respect the choice of the callers > (whether they used a file name or a dire name, which is an important > distinction in Emacs's file name APIs, not just here). > > There's no need for the callers to know about the internals of > the callee. If they call `create-file-buffer` with /foo/bar/baz the > buffer will be called "baz" and if they call it with /foo/bar/baz/ the > buffer will be called "baz/" (depending on > `uniquify-trailing-separator-p`, of course). > It's the most natural/obvious semantics. Wasn't the fact that the trailing slash was absent part of the reason for the bug this tries to fix? If so, then this is not just "if you want it, use it", is it? From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 15:18:59 2023 Received: (at 62732) by debbugs.gnu.org; 10 Jul 2023 19:18:59 +0000 Received: from localhost ([127.0.0.1]:49160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIwPS-0003tU-Po for submit@debbugs.gnu.org; Mon, 10 Jul 2023 15:18:59 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:7835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qIwPQ-0003tC-3a for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 15:18:57 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 665E5441813; Mon, 10 Jul 2023 15:18:50 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0575344180D; Mon, 10 Jul 2023 15:18:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689016729; bh=FWzeD3Nh7LBGb0SeBNf/J4zDSqYu4fbTvkdGHtRNcQs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PAvOEkSUzdtHNcgI8o3X+FPKD/bekkheVwx9AwQJXNP9z1+U8+JZIrBh0hWG8Q4yp etVXUGJLKqMtj2/gJNz8wfK3Pnbf+cpqE+ZjCKGjHIO4xslCIe8v4KrIOPvXZ4Bv3X DAJUr8dn6vbdUZgOLWz/grzHeczCA2kik14huGcNhfjWZh2YurJocpXP1OJswd5O8r PP+ENlTYLO00lbVMmGs04KV0dqw6xquwUNz3m+PrxU3S3gwBdsCjLGzA4FkrP16h8H 64XNO+sTGpq5avJBRILqsHVuyajFbdHBeReTwJPW2PK0tQE7OpKW+Pa/fjZiPygXoh o+7oc8E/0eylQ== Received: from pastel (unknown [24.140.234.50]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D197612020D; Mon, 10 Jul 2023 15:18:48 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83fs5v8tsw.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 10 Jul 2023 22:12:31 +0300") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> Date: Mon, 10 Jul 2023 15:18:48 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.127 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> > Callers shouldn't know to much about the internals of the callee. >> >> Indeed: currently `create-file-buffer` doesn't pay attention to the file >> system at all, it just creates a buffer with a name based on the >> FILENAME that's passed. Spencer's patch just offers more control to the >> callers by making `create-file-buffer` respect the choice of the callers >> (whether they used a file name or a dire name, which is an important >> distinction in Emacs's file name APIs, not just here). >> >> There's no need for the callers to know about the internals of >> the callee. If they call `create-file-buffer` with /foo/bar/baz the >> buffer will be called "baz" and if they call it with /foo/bar/baz/ the >> buffer will be called "baz/" (depending on >> `uniquify-trailing-separator-p`, of course). >> It's the most natural/obvious semantics. > > Wasn't the fact that the trailing slash was absent part of the reason > for the bug this tries to fix? If so, then this is not just "if you > want it, use it", is it? No, `create-file-buffer` used to throw away the trailing slash, rather than make use of this information. Not sure why Dired bothered to remove the tailing slash when calling it, maybe because a long time ago `create-file-buffer` had a bug if the name had a trailing slash. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 22:25:49 2023 Received: (at 62732) by debbugs.gnu.org; 11 Jul 2023 02:25:50 +0000 Received: from localhost ([127.0.0.1]:49452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJ34X-0002uj-JW for submit@debbugs.gnu.org; Mon, 10 Jul 2023 22:25:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58912) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJ34V-0002uV-5U for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 22:25:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJ34P-0003vg-Am; Mon, 10 Jul 2023 22:25:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=P5ahyB9EiawwVISkbcn1t3agyTPR0qkJ5HtUvlBVFTY=; b=M5sDbaS2x5Ux TtxTVu276Tj7M2lpsSehKDayEJoeNVaQHC+ZLEJbbmXR9nJa4+4bcF+9U4vxaPxZ79D/l0jzHlKhd vwwTGtNO4wZmQADiXlYYWK51hNsEWtj9QwjNj5nw2Y8mGAJY3kifN3hTiNrpTCtEINmgCkY2uTnwA pSfEKE9s9O2OBe6F+QPYvsxwBH0Ohx0m9t/or/uZXmCawfnlUwLfTojq9GZRVYKj3DpsxdtbU4d/R MPxkdMO6q2PdgYuFgJuL7wzbIHdgoqYsIQnFmlcXPMdJ6o/WLWBjLUxCMaed0NOLf+Vp5ovRAjP7H midyD4yjCZ41mX/SUT9LCQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJ34O-0007MN-L6; Mon, 10 Jul 2023 22:25:40 -0400 Date: Tue, 11 Jul 2023 05:25:50 +0300 Message-Id: <83edlf89qp.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Mon, 10 Jul 2023 15:18:48 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: sbaugh@catern.com, 62732@debbugs.gnu.org > Date: Mon, 10 Jul 2023 15:18:48 -0400 > > >> > Callers shouldn't know to much about the internals of the callee. > >> > >> Indeed: currently `create-file-buffer` doesn't pay attention to the file > >> system at all, it just creates a buffer with a name based on the > >> FILENAME that's passed. Spencer's patch just offers more control to the > >> callers by making `create-file-buffer` respect the choice of the callers > >> (whether they used a file name or a dire name, which is an important > >> distinction in Emacs's file name APIs, not just here). > >> > >> There's no need for the callers to know about the internals of > >> the callee. If they call `create-file-buffer` with /foo/bar/baz the > >> buffer will be called "baz" and if they call it with /foo/bar/baz/ the > >> buffer will be called "baz/" (depending on > >> `uniquify-trailing-separator-p`, of course). > >> It's the most natural/obvious semantics. > > > > Wasn't the fact that the trailing slash was absent part of the reason > > for the bug this tries to fix? If so, then this is not just "if you > > want it, use it", is it? > > No, `create-file-buffer` used to throw away the trailing slash, rather > than make use of this information. Not sure why Dired bothered to > remove the tailing slash when calling it, maybe because a long time ago > `create-file-buffer` had a bug if the name had a trailing slash. So why the need for the change in dired.el? From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 10 22:55:40 2023 Received: (at 62732) by debbugs.gnu.org; 11 Jul 2023 02:55:40 +0000 Received: from localhost ([127.0.0.1]:49458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJ3XQ-0003lE-Ce for submit@debbugs.gnu.org; Mon, 10 Jul 2023 22:55:40 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJ3XO-0003l1-Du for 62732@debbugs.gnu.org; Mon, 10 Jul 2023 22:55:38 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id DF71444184B; Mon, 10 Jul 2023 22:55:32 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9C94B441844; Mon, 10 Jul 2023 22:55:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689044131; bh=pk49SFa2KajRy4H54NaD5iG6NKj01VCjciYGyEYHijw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VLOQQVpY/Z8NoJ2f1tx3ftg6URAQopiVjZGuKnu3hSRJNT+3LX4UbnWSnk1FW7iZ7 WHc0EAjpuquV4+wH2fDJxadSTdv10r+sNEEusGuqabaUBmCZhyRo7oB0d0rt03r9oM oSy1fKUtpZgCPn5Pj+8Lx0D/ye/JaFurhrdaj5G/TU7vyqEX4tOzGdGER2GhMtXA+d WkGek/6qQHW9p0zo3DczIyuf46wvgq8yoPp11sbMLWadXnA8UJ0PuIOO4syy4bx2Rr 73tHKTm7iNTYhIRL6k8U0d976ImP60aV88M1F28oWc7mnFuy1zYXyxLcA1ynJ6M9Xo qIo7qH3Gj22wQ== Received: from pastel (69-165-150-192.dsl.teksavvy.com [69.165.150.192]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6B4D812026C; Mon, 10 Jul 2023 22:55:31 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83edlf89qp.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 11 Jul 2023 05:25:50 +0300") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Mon, 10 Jul 2023 22:55:23 -0400 MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> No, `create-file-buffer` used to throw away the trailing slash, rather >> than make use of this information. [ And instead uniquify had to try and recover that information by checking the file-system. ] >> Not sure why Dired bothered to remove the tailing slash when calling >> it, maybe because a long time ago `create-file-buffer` had a bug if >> the name had a trailing slash. > So why the need for the change in dired.el? Because we do want Dired to tell `create-file-buffer` that this is a directory and it should thus obey `uniquify-trailing-separator-p`. Otherwise `uniquify-trailing-separator-p` would end up never used (since Dired is AFAIK the only package that creates "directory file buffers"). Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 11 08:01:27 2023 Received: (at 62732) by debbugs.gnu.org; 11 Jul 2023 12:01:27 +0000 Received: from localhost ([127.0.0.1]:49896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJC3b-0008Um-ES for submit@debbugs.gnu.org; Tue, 11 Jul 2023 08:01:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJC3R-0008US-Qi for 62732@debbugs.gnu.org; Tue, 11 Jul 2023 08:01:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJC3M-0008OB-C3; Tue, 11 Jul 2023 08:01:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=GqTH9xYtmGvO73TNRg6oaVtF8/GZdUlotDW1G3/5Ikg=; b=YAOKJgUWi6qv yoiZx2DgJqoU0m9v6he7ReF2HYrsKSbVEcN9Ce5mkoxFrCODzhBkX969X6nSqGsQoLvEf7p8tgpxM M2AbgZQjdpCm5imwCh2iSTOdh4tsxnOQALTRm3/Cuo7Pt9AzKjQpr3W1DcV6NaLE0cqVGj2piuWwg DhAxYIlLs5N8F/5+nHTvwWj0msPkT3kkFcu835UCyyPDy4NGYTLeA9X9NgXrQT+YyYXqR4kr5t2Sf Ivp2dQpNjgZFYHizJ1oPYFBqh3nWBArJYd9olp5QzD73QNPL2MX5x/+p01PVIJaMBuw+jGWHXMXpj OfY7d9CYS5hfPXz0RnOoLg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJC3I-0004OO-T6; Tue, 11 Jul 2023 08:01:12 -0400 Date: Tue, 11 Jul 2023 15:01:21 +0300 Message-Id: <83v8eq7j3i.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Mon, 10 Jul 2023 22:55:23 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: sbaugh@catern.com, 62732@debbugs.gnu.org > Date: Mon, 10 Jul 2023 22:55:23 -0400 > > >> No, `create-file-buffer` used to throw away the trailing slash, rather > >> than make use of this information. > > [ And instead uniquify had to try and recover that information by checking > the file-system. ] > > >> Not sure why Dired bothered to remove the tailing slash when calling > >> it, maybe because a long time ago `create-file-buffer` had a bug if > >> the name had a trailing slash. > > So why the need for the change in dired.el? > > Because we do want Dired to tell `create-file-buffer` that this is > a directory and it should thus obey `uniquify-trailing-separator-p`. When will we NOT want to tell create-file-buffer that the file is a directory? Your original response, viz.: > I think the fact that the callers get to control this regardless of > whether there is a file or directory by that name is one of the best > part of this change. seemed to indicate that there are cases where we would not want create-file-buffer to know that, but I suspect that we will always want, because otherwise uniquify will not work in those cases, and Spencer will report a bug. My comments assumed that indeed we will (almost) always want to tell create-file-buffer this is a directory. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 11 08:32:06 2023 Received: (at 62732) by debbugs.gnu.org; 11 Jul 2023 12:32:06 +0000 Received: from localhost ([127.0.0.1]:49916 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJCXC-0000lg-FF for submit@debbugs.gnu.org; Tue, 11 Jul 2023 08:32:05 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:35971) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJCX7-0000l8-5P for 62732@debbugs.gnu.org; Tue, 11 Jul 2023 08:32:00 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83v8eq7j3i.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 11 Jul 2023 15:01:21 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> Date: Tue, 11 Jul 2023 08:31:51 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, Stefan Monnier , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Stefan Monnier >> Cc: sbaugh@catern.com, 62732@debbugs.gnu.org >> Date: Mon, 10 Jul 2023 22:55:23 -0400 >> >> >> No, `create-file-buffer` used to throw away the trailing slash, rather >> >> than make use of this information. >> >> [ And instead uniquify had to try and recover that information by checking >> the file-system. ] >> >> >> Not sure why Dired bothered to remove the tailing slash when calling >> >> it, maybe because a long time ago `create-file-buffer` had a bug if >> >> the name had a trailing slash. >> > So why the need for the change in dired.el? >> >> Because we do want Dired to tell `create-file-buffer` that this is >> a directory and it should thus obey `uniquify-trailing-separator-p`. > > When will we NOT want to tell create-file-buffer that the file is a > directory? Your original response, viz.: > >> I think the fact that the callers get to control this regardless of >> whether there is a file or directory by that name is one of the best >> part of this change. > > seemed to indicate that there are cases where we would not want > create-file-buffer to know that, but I suspect that we will always > want, because otherwise uniquify will not work in those cases, and > Spencer will report a bug. > > My comments assumed that indeed we will (almost) always want to tell > create-file-buffer this is a directory. One contribution, not intended to be exhaustive of all use cases, and not intended to be definitively a good idea: a user could want opened tar files with their file listing view to have a trailing slash, even though they aren't actually directories. And with my approach that is possibly just by running file-name-as-directory over the name before passing it to create-file-buffer. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 11 11:31:07 2023 Received: (at 62732) by debbugs.gnu.org; 11 Jul 2023 15:31:07 +0000 Received: from localhost ([127.0.0.1]:50908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJFKV-0008LQ-4L for submit@debbugs.gnu.org; Tue, 11 Jul 2023 11:31:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJFKS-0008Ko-3W for 62732@debbugs.gnu.org; Tue, 11 Jul 2023 11:31:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFKL-0004ky-Dt; Tue, 11 Jul 2023 11:30:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1tjrciK26dT/c7b5qWVtqeTqGVN1hAU/HTA8t5u84Mk=; b=iBdiMCODnzFt D2d2FDyuDrdHlQU5zxjeTHqJwn71VoWp9c8AOxNX0INfRc4Y4L0CqVmPcj5/Zxc4HriW5GBgQsoCP yUvio5fMsNaSNInPxLI19s8dZPHCqr0mzvFYDBlYicKsIcNp5lvLJQKeuRDgaR9mOp9Tu+RIMVIgb u49bMPUHAT/HQSYN5szP75lO6qV8dp+ygOF2kHdvV7z9jixPKmlXMTKpUcTSxyRl6rfDNY3idU4Cr y02HcDgHpdadrEFDsTA/04hg+7pIjPEXAGmHUPXJuLMZ/hWuAJuKu1aC0WbTjB63Cs2XZfn8OR6u1 82S5olh+VmeSFvR1++ITRQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJFKK-000570-LS; Tue, 11 Jul 2023 11:30:57 -0400 Date: Tue, 11 Jul 2023 18:31:07 +0300 Message-Id: <83pm4y79dw.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Tue, 11 Jul 2023 08:31:51 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: Stefan Monnier , sbaugh@catern.com, > 62732@debbugs.gnu.org > Date: Tue, 11 Jul 2023 08:31:51 -0400 > > Eli Zaretskii writes: > > My comments assumed that indeed we will (almost) always want to tell > > create-file-buffer this is a directory. > > One contribution, not intended to be exhaustive of all use cases, and > not intended to be definitively a good idea: a user could want opened > tar files with their file listing view to have a trailing slash, even > though they aren't actually directories. But users don't call create-file-buffer, do they? So this is not user-level option, at least not directly so. > And with my approach that is possibly just by running > file-name-as-directory over the name before passing it to > create-file-buffer. If you worry about users, they can be told to append a slash by hand, when they mean a directory and that directory does not yet exist. We do this elsewhere in Emacs. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 12 09:04:59 2023 Received: (at 62732) by debbugs.gnu.org; 12 Jul 2023 13:04:59 +0000 Received: from localhost ([127.0.0.1]:51900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJZWa-0006uJ-53 for submit@debbugs.gnu.org; Wed, 12 Jul 2023 09:04:59 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJZWX-0006u6-Vg for 62732@debbugs.gnu.org; Wed, 12 Jul 2023 09:04:54 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 664421000C4; Wed, 12 Jul 2023 09:04:48 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 48E6710008C; Wed, 12 Jul 2023 09:04:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689167087; bh=IKiclIWtN6rLYr5x8YQ5YzmbsHMAWcIgI6DjxavSbUI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=A5hMJa9Yp+/BVG4OvZ4FJL9X9GVcFw6e8pjB72clhJukuaHGsoQccI9EB2q+fVYU3 tygZ7DJ8T9a/C5AqyK53cPgIBpk2C8S6MrqNjljFNCmFzveiPX/GJYpRXIn+N04JSA Vi/tP8xsM03uEvF3Um5oUhmC5E7R06+5mNnmBQ7PA3cwMTWLpEjFJogqR6Z8MYLS0V mNlQdOu+2C/eTvAfljfwgLwYubHBzBFk/8ItGXl2qF7Fk30Hlqhs0Uemhk+Ee9l9S6 4IBQ4PsktCOZZK6p64mpK6ZjZ3vNTaSEMiqy4syJHSgWZgQD+DUR/5040+oDLwhFVC t6AX0X3K6mWiQ== Received: from pastel (69-165-150-192.dsl.teksavvy.com [69.165.150.192]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 94D9E1202C3; Wed, 12 Jul 2023 09:04:46 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83pm4y79dw.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 11 Jul 2023 18:31:07 +0300") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> Date: Wed, 12 Jul 2023 09:04:40 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.146 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: Spencer Baugh , 62732@debbugs.gnu.org, sbaugh@catern.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I'm not sure what to make of this discussion. The issue at hand is the following: `create-file-buffer` needs to know if the filename it receives is for a directory or not so it can decide whether the buffer name should end in / or not according to `uniquify-trailing-separator-p`. I can see 3 ways to provide this info: 1- use `file-directory-p`. 2- add a boolean `directory` argument to `create-file-buffer`. 3- use the presence of a trailing directory separator in the filename. Those 3 are very close to each other, in practice, so we're pretty much in bikeshed territory. My preference is (3) first, (2) second, and (1) last. (1) is my least favorite because it makes it impossible/difficult to create a "directory buffer" if `file-directory-p` returns nil and vice versa, even tho I can imagine scenarios where this could be useful (such as the scenario mentioned by Spencer where we want to create a "directory buffer" for an archive that Emacs's file-name-handlers don't understand). (3) is my favorite because it doesn't need an extra argument and instead uses an existing piece of information: if I pass "/a/b/c/" then it seems clear that I mean this to be a "directory buffer" rather than a "file buffer". Representing the information "this is meant to be a directory" in the file name via a trailing / is a standard practice in ELisp (and POSIX in general), embodied by things like `file-name-as-directory` and `directory-file-name`, so it seems only natural (or even a mere a bug fix) to let `create-file-buffer` make use of that info instead of throwing it away. But I prefer any one of those 3 choices over the status quo, so I'll stop arguing here. Just let me know which one I should install. Stefan Eli Zaretskii [2023-07-11 18:31:07] wrote: >> From: Spencer Baugh >> Cc: Stefan Monnier , sbaugh@catern.com, >> 62732@debbugs.gnu.org >> Date: Tue, 11 Jul 2023 08:31:51 -0400 >> >> Eli Zaretskii writes: >> > My comments assumed that indeed we will (almost) always want to tell >> > create-file-buffer this is a directory. >> >> One contribution, not intended to be exhaustive of all use cases, and >> not intended to be definitively a good idea: a user could want opened >> tar files with their file listing view to have a trailing slash, even >> though they aren't actually directories. > > But users don't call create-file-buffer, do they? So this is not > user-level option, at least not directly so. > >> And with my approach that is possibly just by running >> file-name-as-directory over the name before passing it to >> create-file-buffer. > > If you worry about users, they can be told to append a slash by hand, > when they mean a directory and that directory does not yet exist. We > do this elsewhere in Emacs. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 12 09:42:16 2023 Received: (at 62732) by debbugs.gnu.org; 12 Jul 2023 13:42:16 +0000 Received: from localhost ([127.0.0.1]:51947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJa6i-0007ob-3m for submit@debbugs.gnu.org; Wed, 12 Jul 2023 09:42:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJa6f-0007oO-Cy for 62732@debbugs.gnu.org; Wed, 12 Jul 2023 09:42:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJa6U-000148-A4; Wed, 12 Jul 2023 09:42:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=EaayxoCpNRlLhPGthskhyBbQVZqQ0uvnLPgmFyzWwPQ=; b=aqlINd/SyV5v I74SE0G6jRe9eRnbWvTA2MzmvVgUK3Rbb93p7WLK4bBMr2Lm1VXg+DbuROuruczWtXFEaWpCPelby dygGGJRf6M4KMrM2Xz5WgSR8UKwbc9RwYtP89utSd+ggY5yUeuTfnrI41Y23M5mUN2gTU8Wfu+GbU HLGqpMw2Sl58vKK0c+oqGM6GvTqctxhWuBRs7DNGDxvSPXZ/453APW03n6dQuRRmnx/TfWF+MDhdI KjwbMP4W2Lg59twfbWwBogWqHYhFvPpXAXluRl8kAHUi79xOwub1Xd4xvuoJ785F49VIWspsM+BcU zSWK3CvjEd8y+1+0pGpP9w==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJa6F-0006d1-T1; Wed, 12 Jul 2023 09:41:55 -0400 Date: Wed, 12 Jul 2023 16:42:01 +0300 Message-Id: <83y1jl5jrq.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Wed, 12 Jul 2023 09:04:40 -0400) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@janestreet.com, 62732@debbugs.gnu.org, sbaugh@catern.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: Spencer Baugh , sbaugh@catern.com, > 62732@debbugs.gnu.org > Date: Wed, 12 Jul 2023 09:04:40 -0400 > > I'm not sure what to make of this discussion. > > The issue at hand is the following: `create-file-buffer` needs to know > if the filename it receives is for a directory or not so it can decide > whether the buffer name should end in / or not according to > `uniquify-trailing-separator-p`. > > I can see 3 ways to provide this info: > > 1- use `file-directory-p`. > 2- add a boolean `directory` argument to `create-file-buffer`. > 3- use the presence of a trailing directory separator in the filename. > > Those 3 are very close to each other, in practice, so we're pretty much > in bikeshed territory. > > My preference is (3) first, (2) second, and (1) last. I prefer (1), because it avoids requesting the callers to remember to ensure that every directory ends in a slash. The trailing-slash semantics is indeed pretty much standard, but only in interactive usage (where it is made easier by the file-name completion machinery, both in Emacs and in other programs that ask users to type file names). And even in interactive usage it is problematic: recall the many complaints when we started requiring the slash in copy-file and such likes. Here we are talking about a low-level function, not an interactive command, which then places this burden on the callers, and I worry that many of them will not pay attention to this subtlety, and will cause subtle bugs, because AFAIK the uniquify modes where that is important are rarely used, and thus such problems could go undetected for many years. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 12 09:57:11 2023 Received: (at 62732) by debbugs.gnu.org; 12 Jul 2023 13:57:11 +0000 Received: from localhost ([127.0.0.1]:52701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJaL8-0008SA-N1 for submit@debbugs.gnu.org; Wed, 12 Jul 2023 09:57:11 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:42673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJaL5-0008Rq-Qf for 62732@debbugs.gnu.org; Wed, 12 Jul 2023 09:57:08 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83y1jl5jrq.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 12 Jul 2023 16:42:01 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> Date: Wed, 12 Jul 2023 09:57:02 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, Stefan Monnier , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Stefan Monnier >> Cc: Spencer Baugh , sbaugh@catern.com, >> 62732@debbugs.gnu.org >> Date: Wed, 12 Jul 2023 09:04:40 -0400 >> >> I'm not sure what to make of this discussion. >> >> The issue at hand is the following: `create-file-buffer` needs to know >> if the filename it receives is for a directory or not so it can decide >> whether the buffer name should end in / or not according to >> `uniquify-trailing-separator-p`. >> >> I can see 3 ways to provide this info: >> >> 1- use `file-directory-p`. >> 2- add a boolean `directory` argument to `create-file-buffer`. >> 3- use the presence of a trailing directory separator in the filename. >> >> Those 3 are very close to each other, in practice, so we're pretty much >> in bikeshed territory. >> >> My preference is (3) first, (2) second, and (1) last. > > I prefer (1), because it avoids requesting the callers to remember to > ensure that every directory ends in a slash. > > The trailing-slash semantics is indeed pretty much standard, but only > in interactive usage (where it is made easier by the file-name > completion machinery, both in Emacs and in other programs that ask > users to type file names). And even in interactive usage it is > problematic: recall the many complaints when we started requiring the > slash in copy-file and such likes. Here we are talking about a > low-level function, not an interactive command, which then places this > burden on the callers, and I worry that many of them will not pay > attention to this subtlety, and will cause subtle bugs, because AFAIK > the uniquify modes where that is important are rarely used, and thus > such problems could go undetected for many years. Not to prelong the discussion any further, but one more detail: This uniquify-trailing-separator-p variable really IMO should be a dired variable, since it only affects dired buffer naming (at least in core Emacs, for now). This behavior has really nothing to do with uniquify. So IMO it should never have been a uniquify variable in the first place, and in an earlier version of my patch I moved the variable to dired and obsoleted the old one. I dropped that move because it wasn't particularly necessary and could be done in a followup, but of these three options, 2 and 3 work much better with moving this variable to dired, because only 2 and 3 let dired control this without affecting other packages. Option 1 forces the same behavior on every package. I guess we could still have that as a dired variable, but it seems weirder. (As a dired variable, it could control just "does dired pass a directory name or a file name to create-file-buffer?", and create-file-buffer could always include the trailing slash when it sees a directory name) From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 12 15:44:12 2023 Received: (at 62732) by debbugs.gnu.org; 12 Jul 2023 19:44:12 +0000 Received: from localhost ([127.0.0.1]:52981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJfkx-0003ur-6O for submit@debbugs.gnu.org; Wed, 12 Jul 2023 15:44:11 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:1670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJfkk-0003tl-Ok for 62732@debbugs.gnu.org; Wed, 12 Jul 2023 15:44:10 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B12951000C4; Wed, 12 Jul 2023 15:43:51 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 94B2A10008C; Wed, 12 Jul 2023 15:43:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689191030; bh=pu9BEaoLQXN34tv1eWrrw4heSgXq7X88/vY1O0CNee0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Vive27mgEsWSWB2NO+m0xluCHJK70GEEvhatCW8SgMKFtfAcDe8CsX2DKiUb5TrEY Ls1pOliyfWkR2MGtvnhGFO4HyFU8sKJbd3GKBrtMH+/1KvXbYr9acKbSbPy6ALu+g0 E7t2j3gf5lz1A8SO6qsbO9lCjbp4QRWDTGIqgTXNo4OcuCGxUoY9j/9Ti/7qrm/TB2 zr7ZZhhydPy5T+UhW0JflvxGmX8EVvlJqzGBGpHI+tC7TZLbMI+wYjs18qkLAMk0UC ZsiMLMN/C1MeKIaqp0zgcgNHspYCFYxV64cHS9YPrF2R1Pvam2VkvU+tQ1udt9wL/D t0RVWCS/A6qcQ== Received: from pastel (69-165-150-192.dsl.teksavvy.com [69.165.150.192]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 672C412022E; Wed, 12 Jul 2023 15:43:50 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: (Spencer Baugh's message of "Wed, 12 Jul 2023 09:57:02 -0400") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> Date: Wed, 12 Jul 2023 15:43:49 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.144 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, Eli Zaretskii , 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Not to prelong the discussion any further, but one more detail: This > uniquify-trailing-separator-p variable really IMO should be a dired > variable, since it only affects dired buffer naming (at least in core > Emacs, for now). This behavior has really nothing to do with uniquify. > So IMO it should never have been a uniquify variable in the first place, > and in an earlier version of my patch I moved the variable to dired and > obsoleted the old one. FWIW, I agree, and I'd also recommend to make this variable default to t. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 00:50:42 2023 Received: (at 62732) by debbugs.gnu.org; 13 Jul 2023 04:50:42 +0000 Received: from localhost ([127.0.0.1]:53146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJoHp-0002g6-WC for submit@debbugs.gnu.org; Thu, 13 Jul 2023 00:50:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJoHo-0002fl-6z for 62732@debbugs.gnu.org; Thu, 13 Jul 2023 00:50:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJoHi-0005jF-Qt; Thu, 13 Jul 2023 00:50:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=HORoIiBM8mJeXd+XTvaOthjsk5/btsuSMpE53vqHJpQ=; b=JHqNBrrpZppr u1+YMXoae1EIH0wMQhUsSE/cZcecraymYvZYRyczfk0nSWgWkmXse5DGCgJq570jb75dDK/mOXRjg nh0pptUxi2qH6MJNBUZj622FA2N2g0SULbo4QYT8rTwuLXXnXgQelIm4uLQxjMQ2lv+HIKDvmSI+q 5on3HypFOkDYC7B3iSkXCU7NhrohxxgMmJLHphSyCQ9svr/VpldRbdj0b2iwKh2up3b81Ang56OIR 89MlcXPuCw+1mwAVdHPjs6mIIdCQ19L5fhOw/wOrmOcXqV7eRax052MPe6LrM7M+5Zihj2Q7QqyWZ +KDUfuIV94F47nfWzkoa2A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJoHc-0000XG-8D; Thu, 13 Jul 2023 00:50:32 -0400 Date: Thu, 13 Jul 2023 07:50:43 +0300 Message-Id: <83o7kg5s9o.fsf@gnu.org> From: Eli Zaretskii To: monnier@iro.umontreal.ca, sbaugh@janestreet.com In-Reply-To: <83y1jl5jrq.fsf@gnu.org> (message from Eli Zaretskii on Wed, 12 Jul 2023 16:42:01 +0300) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: sbaugh@janestreet.com, 62732@debbugs.gnu.org, sbaugh@catern.com > Date: Wed, 12 Jul 2023 16:42:01 +0300 > From: Eli Zaretskii > > > I can see 3 ways to provide this info: > > > > 1- use `file-directory-p`. > > 2- add a boolean `directory` argument to `create-file-buffer`. > > 3- use the presence of a trailing directory separator in the filename. > > > > Those 3 are very close to each other, in practice, so we're pretty much > > in bikeshed territory. > > > > My preference is (3) first, (2) second, and (1) last. > > I prefer (1), because it avoids requesting the callers to remember to > ensure that every directory ends in a slash. So how about compromising on a variant of (2): we add an optional DIRECTORY-P argument, and if FILENAME doesn't end in a slash, but DIRECTORY-P is non-nil, create-file-buffer will append a slash? From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 11:53:03 2023 Received: (at 62732) by debbugs.gnu.org; 13 Jul 2023 15:53:03 +0000 Received: from localhost ([127.0.0.1]:40624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJyco-0001VN-TR for submit@debbugs.gnu.org; Thu, 13 Jul 2023 11:53:03 -0400 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:56420) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJycl-0001Uq-Gx for 62732@debbugs.gnu.org; Thu, 13 Jul 2023 11:53:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=RI6NGXYLZKTTSPDI88D0//A4eN5G9DeWw4aie8nduu4=; b=A3SDDQWHEUD+DIU/rvQkgnS7vsh2Fx/QRWgya7ejWfPfvLwE5F+a+eSgUBeTRFsUtkA1 nWiCNP1Jd8dzHtEyvuj1MP7FcV0f2+mscJD/9dy10zuNl6ZfU17urZiB6HyAcg9EyKqXKR 7GoQvxmL+rlgbS5/en6XgBXQOtYM+zd6IfgpwNQ64Wd7xC2V6YOGKX3vbsRp62d2xyUerq m2Vvr34KqyS2F1plpruvtj+vRYleGXiST9OfLkgZ+YIOM1Xm6ikQMEWj2cO5liNJMFmetI zDW6/5NvDkJxVXqfF4fc56iGc8dc0nVe0kvHqJgP0FrnBC5Erzt4cSROgVW1B87Q== Received: by filterdrecv-66949dbc98-fl57f with SMTP id filterdrecv-66949dbc98-fl57f-1-64B01DD5-46 2023-07-13 15:52:53.951187742 +0000 UTC m=+1603060.932133059 Received: from earth.catern.com (unknown) by geopod-ismtpd-27 (SG) with ESMTP id P0n59xcxROO-yv_TnRdaUQ Thu, 13 Jul 2023 15:52:53.864 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 5EED66009C; Thu, 13 Jul 2023 11:52:53 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83o7kg5s9o.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 13 Jul 2023 07:50:43 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> Date: Thu, 13 Jul 2023 15:52:54 +0000 (UTC) Message-ID: <87mszzkduy.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKvBGMA+vX4QcKaH0JOXN?= =?us-ascii?Q?kBPTOp4MzTbLTQ2U7UFm6M8hCLsuXcP16Bmxohn?= =?us-ascii?Q?3klLenuNRf=2FnN1HICSRPVAKOjwCn2M4kU=2FWggWG?= =?us-ascii?Q?MGK7WqypJ7dglvXIzmtgDQCuIPcVYYOmMrhCasW?= =?us-ascii?Q?dtJRe7QEXPOZ2XqKUA2qxZz9YfLXE9g9pxA=3D=3D?= To: Eli Zaretskii X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii writes: >> Cc: sbaugh@janestreet.com, 62732@debbugs.gnu.org, sbaugh@catern.com >> Date: Wed, 12 Jul 2023 16:42:01 +0300 >> From: Eli Zaretskii >> >> > I can see 3 ways to provide this info: >> [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [149.72.154.232 listed in wl.mailspike.net] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 62732 Cc: sbaugh@janestreet.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> Cc: sbaugh@janestreet.com, 62732@debbugs.gnu.org, sbaugh@catern.com >> Date: Wed, 12 Jul 2023 16:42:01 +0300 >> From: Eli Zaretskii >> >> > I can see 3 ways to provide this info: >> > >> > 1- use `file-directory-p`. >> > 2- add a boolean `directory` argument to `create-file-buffer`. >> > 3- use the presence of a trailing directory separator in the filename. >> > >> > Those 3 are very close to each other, in practice, so we're pretty much >> > in bikeshed territory. >> > >> > My preference is (3) first, (2) second, and (1) last. >> >> I prefer (1), because it avoids requesting the callers to remember to >> ensure that every directory ends in a slash. > > So how about compromising on a variant of (2): we add an optional > DIRECTORY-P argument, and if FILENAME doesn't end in a slash, but > DIRECTORY-P is non-nil, create-file-buffer will append a slash? Okay, so like this? BTW, would you be okay with moving uniquify-trailing-separator-p into dired, as I described in my other recent email? Then create-file-buffer wouldn't need to check it, which would simplify its docstring slightly; instead dired would just decide whether to pass a directory name or file name based on uniquify-trailing-separator-p. Since I'm changing this area anyway, now would be the time to make that change, as a nice cleanup which Stefan also likes. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-recalculate-the-buffer-basename-inside-uniquif.patch >From 023b8e7a715374e59a5456075b98d1422659cfe6 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 9 Jul 2023 10:24:33 -0400 Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Previously, uniquify--create-file-buffer-advice would use the filename of the buffer to calculate what the buffer's basename should be. Now that gets passed in from create-file-buffer, which lets us fix several bugs: 1. before this patch, if a buffer happened to be named the same thing as directory in its default-directory, the buffer would get renamed with a directory separator according to uniquify-trailing-separator-p. 2. buffers with a leading space should get a leading |, as described by create-file-buffer's docstring; before this patch, uniquify would remove that leading |. * lisp/dired.el (dired-internal-noselect): Pass a directory name to create-file-buffer. * lisp/files.el (create-file-buffer): Do uniquify-trailing-separator-p handling if passed a directory filename. (bug#62732) * lisp/uniquify.el (uniquify-item): (uniquify-rationalize-file-buffer-names, uniquify-rationalize, uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): Remove uniquify-trailing-separator-p handling. (uniquify--create-file-buffer-advice): Take new basename argument and use it, instead of recalculating the basename from the filename. --- lisp/dired.el | 2 +- lisp/files.el | 25 ++++--- lisp/uniquify.el | 39 ++++------- test/lisp/uniquify-tests.el | 129 ++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 test/lisp/uniquify-tests.el diff --git a/lisp/dired.el b/lisp/dired.el index d14cf47ffd5..3c9e6e40f9b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..f1b3b6be4f4 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,29 @@ find-alternate-file (kill-buffer obuf)))))) ;; 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) "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." - (let* ((lastname (file-name-nondirectory filename)) - (lastname (if (string= lastname "") - filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + (let* ((lastname (file-name-nondirectory (directory-file-name filename))) + (lastname (cond + ((not (and uniquify-trailing-separator-p (directory-name-p filename))) + lastname) + ((eq uniquify-buffer-name-style 'forward) + (file-name-as-directory lastname)) + ((eq uniquify-buffer-name-style 'reverse) + (concat (or uniquify-separator "\\") lastname)) + (t lastname))) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..d1ca455b673 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname item))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string= old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,15 +478,14 @@ uniquify--rename-buffer-advice ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style - (let ((filename (expand-file-name (directory-file-name filename)))) - (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) - (file-name-directory filename) - buf)))) + (uniquify-rationalize-file-buffer-names + basename + (file-name-directory (expand-file-name (directory-file-name filename))) + buf))) (defun uniquify-unload-function () "Unload the uniquify library." diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..abd61fa3504 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,129 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniquify + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buffer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-ignored () + "If uniquify-buffer-name-style isn't forward or reverse, +uniquify-trailing-separator-p is ignored" + (let ((uniquify-buffer-name-style 'post-forward-angle-brackets) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-space-prefix () + "If a buffer starts with a space, | is added at the start" + (save-excursion + (find-file " foo") + (should (equal (buffer-name) "| foo")) + (kill-buffer))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 12:01:58 2023 Received: (at 62732) by debbugs.gnu.org; 13 Jul 2023 16:01:58 +0000 Received: from localhost ([127.0.0.1]:40641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJylS-0001kN-52 for submit@debbugs.gnu.org; Thu, 13 Jul 2023 12:01:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJylO-0001k8-1C for 62732@debbugs.gnu.org; Thu, 13 Jul 2023 12:01:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJylH-0005Si-2z; Thu, 13 Jul 2023 12:01:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=TfLXbheJJqhe3d7wT6vJ03O9KhWR+3V2P8AOlWZMqaY=; b=bJP/eABggj7R Yb6wldkee4XoJAJabPs+RlxqJEMm6D8u6R7NHpDwjLPtGVsnoQAyuErHxbWOc95GsE31iefZWoByY m98WYA/WMdxqkHf/U4m3XtuAv8YjBqN4tEFjwMEuKtHAxSKVvAn88YAVzgg+80XsOmPqVkyEJ/Fd2 ajjbqUK+tw4Ky42mI8iPm2xPyBnM5asCFCkHciGFoHaBZQuxu+kJOIpQBU9//85m/nkKZIAztsGsy UdMHTfCW/D9QNrcF6/Rtth42OTI1wS2U+JjdWjQLGbmUWQiWKYfG+7NAOggqZfTKvCWMz/UtVG5+l asgh2rCO1OXGlPkJwbdHIQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJylG-0004sP-J0; Thu, 13 Jul 2023 12:01:46 -0400 Date: Thu, 13 Jul 2023 19:02:01 +0300 Message-Id: <83pm4v4x6u.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <87mszzkduy.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@janestreet.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Thu, 13 Jul 2023 15:52:54 +0000 (UTC) > Cc: monnier@iro.umontreal.ca, sbaugh@janestreet.com, 62732@debbugs.gnu.org > > Eli Zaretskii writes: > > > So how about compromising on a variant of (2): we add an optional > > DIRECTORY-P argument, and if FILENAME doesn't end in a slash, but > > DIRECTORY-P is non-nil, create-file-buffer will append a slash? > > Okay, so like this? Looks like you sent an incorrect patch or something? > BTW, would you be okay with moving uniquify-trailing-separator-p into > dired, as I described in my other recent email? Then create-file-buffer > wouldn't need to check it, which would simplify its docstring slightly; > instead dired would just decide whether to pass a directory name or file > name based on uniquify-trailing-separator-p. Since I'm changing this > area anyway, now would be the time to make that change, as a nice > cleanup which Stefan also likes. I don't quite understand how can uniquify-trailing-separator-p be in dired.el when the code which supports it is in uniquify.el. What am I missing? From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 12:22:01 2023 Received: (at 62732) by debbugs.gnu.org; 13 Jul 2023 16:22:01 +0000 Received: from localhost ([127.0.0.1]:40682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJz4q-0004sS-K0 for submit@debbugs.gnu.org; Thu, 13 Jul 2023 12:22:01 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:55680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJz4n-0004s5-65 for 62732@debbugs.gnu.org; Thu, 13 Jul 2023 12:21:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=c0jLBiTtGDjnBNvP5F4uAn+jpPNbXlLWmslOjxFO42g=; b=lnDq4Jxsd1Pquj/lBzDVqE8HHzV6TBIJrEHS21m1t/cKGXfsFvI8qPYxwn4x3wMk1nEB fV2NOcFI5uziNAx+jsdgo4bCugaEqRXW7xYbJL+YrvRaHgLAItSjnycTp6Z9W7heewjAMo bsCa01z30pzATH5EImITo2LYqnUcgA5/klowhp1XeTJ8RRvfziqCPowdowhrG5MxqruoUI ZnktKYlLVEZAr2h/tuSPPzeJnmPyW7O3VVLStri7Cdn8FEXLETE/mvUZqOmjrYF0RlG4JF 6qAXB34kVPWE7ak2QjQUDhbKmxskoMyVUP9sk6Ta+TAAIG5VjLVsSUj5zmyhNN4w== Received: by filterdrecv-d7bbbc8bf-wj7z8 with SMTP id filterdrecv-d7bbbc8bf-wj7z8-1-64B0249F-1D 2023-07-13 16:21:51.365080165 +0000 UTC m=+5503333.418200191 Received: from earth.catern.com (unknown) by geopod-ismtpd-38 (SG) with ESMTP id XZ3FVBuRTrS4d-z-9PXSiQ Thu, 13 Jul 2023 16:21:51.242 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id C446260077; Thu, 13 Jul 2023 12:21:50 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83pm4v4x6u.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 13 Jul 2023 19:02:01 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> <83pm4v4x6u.fsf@gnu.org> Date: Thu, 13 Jul 2023 16:21:51 +0000 (UTC) Message-ID: <87h6q7kcip.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbJOKrYDiXIfLfyhzR3j35?= =?us-ascii?Q?BN=2FRx0rYcUKjXquSu8xa5eCxDUHIzsw0D6yb1a=2F?= =?us-ascii?Q?56UbsW7qwczA5ZttkJWR8Ddb97Gq9M1c69dcGgt?= =?us-ascii?Q?bIqM81pzexh4nIKVfq1wq7s5iQ=2FUjdqZ4fSynEh?= =?us-ascii?Q?KR9=2Fh5MbgGF6xAQraf8MGC+LP0=2FUQfklOuw=3D=3D?= To: Eli Zaretskii X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii writes: >> From: sbaugh@catern.com >> Date: Thu, 13 Jul 2023 15:52:54 +0000 (UTC) >> Cc: monnier@iro.umontreal.ca, sbaugh@janestreet.com, 62732@debbugs.gnu.org >> >> Eli Z [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [149.72.126.143 listed in wl.mailspike.net] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 62732 Cc: sbaugh@janestreet.com, monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> From: sbaugh@catern.com >> Date: Thu, 13 Jul 2023 15:52:54 +0000 (UTC) >> Cc: monnier@iro.umontreal.ca, sbaugh@janestreet.com, 62732@debbugs.gnu.org >> >> Eli Zaretskii writes: >> >> > So how about compromising on a variant of (2): we add an optional >> > DIRECTORY-P argument, and if FILENAME doesn't end in a slash, but >> > DIRECTORY-P is non-nil, create-file-buffer will append a slash? >> >> Okay, so like this? > > Looks like you sent an incorrect patch or something? Oops again, here's the correct patch. >> BTW, would you be okay with moving uniquify-trailing-separator-p into >> dired, as I described in my other recent email? Then create-file-buffer >> wouldn't need to check it, which would simplify its docstring slightly; >> instead dired would just decide whether to pass a directory name or file >> name based on uniquify-trailing-separator-p. Since I'm changing this >> area anyway, now would be the time to make that change, as a nice >> cleanup which Stefan also likes. > > I don't quite understand how can uniquify-trailing-separator-p be in > dired.el when the code which supports it is in uniquify.el. What am I > missing? After this patch the only reference to uniquify-trailing-separator-p in uniquify.el is its defcustom. (As I mentioned in the other email, it doesn't really have anything to do with uniquify) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-recalculate-the-buffer-basename-inside-uniquif.patch >From ac884054ec824a04c87313cb0c57616d6082c36a Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 9 Jul 2023 10:24:33 -0400 Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Previously, uniquify--create-file-buffer-advice would use the filename of the buffer to calculate what the buffer's basename should be. Now that gets passed in from create-file-buffer, which lets us fix several bugs: 1. before this patch, if a buffer happened to be named the same thing as directory in its default-directory, the buffer would get renamed with a directory separator according to uniquify-trailing-separator-p. 2. buffers with a leading space should get a leading |, as described by create-file-buffer's docstring; before this patch, uniquify would remove that leading |. * lisp/dired.el (dired-internal-noselect): Pass a directory name to create-file-buffer. * lisp/files.el (create-file-buffer): Do uniquify-trailing-separator-p handling if passed a directory filename. (bug#62732) * lisp/uniquify.el (uniquify-item): (uniquify-rationalize-file-buffer-names, uniquify-rationalize, uniquify-get-proposed-name, uniquify-rationalize-conflicting-sublist): Remove uniquify-trailing-separator-p handling. (uniquify--create-file-buffer-advice): Take new basename argument and use it, instead of recalculating the basename from the filename. --- lisp/dired.el | 2 +- lisp/files.el | 48 +++++++++----- lisp/uniquify.el | 39 ++++------- test/lisp/uniquify-tests.el | 129 ++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 43 deletions(-) create mode 100644 test/lisp/uniquify-tests.el diff --git a/lisp/dired.el b/lisp/dired.el index d14cf47ffd5..3c9e6e40f9b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1306,7 +1306,7 @@ dired-internal-noselect ;; Note that buffer already is in dired-mode, if found. (new-buffer-p (null buffer))) (or buffer - (setq buffer (create-file-buffer (directory-file-name dirname)))) + (setq buffer (create-file-buffer dirname))) (set-buffer buffer) (if (not new-buffer-p) ; existing buffer ... (cond (switches ; ... but new switches diff --git a/lisp/files.el b/lisp/files.el index d325729bf4d..c87a9bc8d22 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2062,22 +2062,40 @@ find-alternate-file (kill-buffer obuf)))))) ;; 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-p) "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. - -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." - (let* ((lastname (file-name-nondirectory filename)) - (lastname (if (string= lastname "") - filename lastname)) - (buf (generate-new-buffer (if (string-prefix-p " " lastname) - (concat "|" lastname) - lastname)))) - (uniquify--create-file-buffer-advice buf filename) + +Either a file name or a directory name can be passed as FILENAME. +In either case, the last non-empty component of FILENAME is used +as the buffer name. + +If `uniquify-trailing-separator-p' is non-nil, then if FILENAME +is a directory name, a file name separator is included in the +buffer name. If DIRECTORY-P is non-nil, this will happen even if +FILENAME is a file 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 buffer +name if necessary. + +If the buffer name is already in use, the buffer will be renamed +according to `uniquify-buffer-name-style' to get an unused name." + (let* ((lastname (file-name-nondirectory (directory-file-name filename))) + (lastname (cond + ((not (and uniquify-trailing-separator-p + (or (directory-name-p filename) directory-p))) + lastname) + ((eq uniquify-buffer-name-style 'forward) + (file-name-as-directory lastname)) + ((eq uniquify-buffer-name-style 'reverse) + (concat (or uniquify-separator "\\") lastname)) + (t lastname))) + (basename (if (string-prefix-p " " lastname) + (concat "|" lastname) + lastname)) + (buf (generate-new-buffer basename))) + (uniquify--create-file-buffer-advice buf filename basename) buf)) (defvar abbreviated-home-dir nil diff --git a/lisp/uniquify.el b/lisp/uniquify.el index dee9ecba2ea..d1ca455b673 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -174,8 +174,8 @@ uniquify-list-buffers-directory-modes (cl-defstruct (uniquify-item (:constructor nil) (:copier nil) (:constructor uniquify-make-item - (base dirname buffer &optional proposed original-dirname))) - base dirname buffer proposed original-dirname) + (base dirname buffer &optional proposed))) + base dirname buffer proposed) ;; Internal variables used free (defvar uniquify-possibly-resolvable nil) @@ -211,7 +211,7 @@ uniquify-rationalize-file-buffer-names (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf - nil dirname))) + nil))) items) (dolist (buffer (buffer-list)) (when (and (not (and uniquify-ignore-buffers-re @@ -292,8 +292,7 @@ uniquify-rationalize (setf (uniquify-item-proposed item) (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - nil - (uniquify-item-original-dirname item))) + nil)) (setq uniquify-managed fix-list))) ;; Strip any shared last directory names of the dirname. (when (and (cdr fix-list) uniquify-strip-common-suffix) @@ -316,8 +315,7 @@ uniquify-rationalize (uniquify-item-dirname item)))) (and f (directory-file-name f))) (uniquify-item-buffer item) - (uniquify-item-proposed item) - (uniquify-item-original-dirname item)) + (uniquify-item-proposed item)) fix-list))))) ;; If uniquify-min-dir-content is 0, this will end up just ;; passing fix-list to uniquify-rationalize-conflicting-sublist. @@ -345,21 +343,10 @@ uniquify-rationalize-a-list (uniquify-rationalize-conflicting-sublist conflicting-sublist old-proposed depth))) -(defun uniquify-get-proposed-name (base dirname &optional depth - original-dirname) +(defun uniquify-get-proposed-name (base dirname &optional depth) (unless depth (setq depth uniquify-min-dir-content)) (cl-assert (equal (directory-file-name dirname) dirname)) ;No trailing slash. - ;; Distinguish directories by adding extra separator. - (if (and uniquify-trailing-separator-p - (file-directory-p (expand-file-name base original-dirname)) - (not (string-equal base ""))) - (cond ((eq uniquify-buffer-name-style 'forward) - (setq base (file-name-as-directory base))) - ;; (setq base (concat base "/"))) - ((eq uniquify-buffer-name-style 'reverse) - (setq base (concat (or uniquify-separator "\\") base))))) - (let ((extra-string nil) (n depth)) (while (and (> n 0) dirname) @@ -421,8 +408,7 @@ uniquify-rationalize-conflicting-sublist (uniquify-get-proposed-name (uniquify-item-base item) (uniquify-item-dirname item) - depth - (uniquify-item-original-dirname item)))) + depth))) (uniquify-rationalize-a-list conf-list depth)) (unless (string= old-name "") (uniquify-rename-buffer (car conf-list) old-name))))) @@ -492,15 +478,14 @@ uniquify--rename-buffer-advice ;; (advice-add 'create-file-buffer :around #'uniquify--create-file-buffer-advice) -(defun uniquify--create-file-buffer-advice (buf filename) +(defun uniquify--create-file-buffer-advice (buf filename basename) ;; BEWARE: This is called directly from `files.el'! "Uniquify buffer names with parts of directory name." (when uniquify-buffer-name-style - (let ((filename (expand-file-name (directory-file-name filename)))) - (uniquify-rationalize-file-buffer-names - (file-name-nondirectory filename) - (file-name-directory filename) - buf)))) + (uniquify-rationalize-file-buffer-names + basename + (file-name-directory (expand-file-name (directory-file-name filename))) + buf))) (defun uniquify-unload-function () "Unload the uniquify library." diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el new file mode 100644 index 00000000000..abd61fa3504 --- /dev/null +++ b/test/lisp/uniquify-tests.el @@ -0,0 +1,129 @@ +;;; uniquify-tests.el --- Tests for uniquify -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) + +(ert-deftest uniquify-basic () + (let (bufs old-names) + (cl-flet ((names-are (current-names &optional nosave) + (should (equal (mapcar #'buffer-name bufs) current-names)) + (unless nosave (push current-names old-names)))) + (should (eq (get-buffer "z") nil)) + (push (find-file-noselect "a/b/z") bufs) + (names-are '("z")) + (push (find-file-noselect "a/b/c/z") bufs) + (names-are '("z" "z")) + (push (find-file-noselect "a/b/d/z") bufs) + (names-are '("z" "z" "z")) + (push (find-file-noselect "e/b/z") bufs) + (names-are '("z" "z" "z" "z")) + ;; buffers without a buffer-file-name don't get uniquified by uniquify + (push (generate-new-buffer "z") bufs) + (names-are '("z" "z" "z" "z" "z")) + ;; but they do get uniquified by the C code which uses + (push (generate-new-buffer "z") bufs) + (names-are '("z<2>" "z" "z" "z" "z" "z")) + (save-excursion + ;; uniquify will happily work with file-visiting buffers whose names don't match buffer-file-name + (find-file "f/y") + (push (current-buffer) bufs) + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave) + ;; somewhat confusing behavior results if a buffer is renamed to match an already-uniquified buffer + (rename-buffer "z" t) + (names-are '("z" "z<2>" "z" "z" "z" "z" "z") 'nosave)) + (while bufs + (kill-buffer (pop bufs)) + (names-are (pop old-names) 'nosave))))) + +(ert-deftest uniquify-dirs () + "Check strip-common-suffix and trailing-separator-p work together; bug#47132" + (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) + (a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs))))) + +(ert-deftest uniquify-rename-to-dir () + "Giving a buffer a name which matches a directory doesn't rename the buffer" + (let ((uniquify-buffer-name-style 'forward) + (uniquify-trailing-separator-p t)) + (save-excursion + (find-file "../README") + (rename-buffer "lisp" t) + (should (equal (buffer-name) "lisp")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-style-reverse () + (let ((uniquify-buffer-name-style 'reverse) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "\\lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-separator-ignored () + "If uniquify-buffer-name-style isn't forward or reverse, +uniquify-trailing-separator-p is ignored" + (let ((uniquify-buffer-name-style 'post-forward-angle-brackets) + (uniquify-trailing-separator-p t)) + (save-excursion + (should (file-directory-p "../lib-src")) + (find-file "../lib-src") + (should (equal (buffer-name) "lib-src")) + (kill-buffer)))) + +(ert-deftest uniquify-space-prefix () + "If a buffer starts with a space, | is added at the start" + (save-excursion + (find-file " foo") + (should (equal (buffer-name) "| foo")) + (kill-buffer))) + +(provide 'uniquify-tests) +;;; uniquify-tests.el ends here -- 2.41.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 17:51:38 2023 Received: (at 62732-done) by debbugs.gnu.org; 13 Jul 2023 21:51:38 +0000 Received: from localhost ([127.0.0.1]:40958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK4Dp-00087l-Ov for submit@debbugs.gnu.org; Thu, 13 Jul 2023 17:51:38 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK4Do-00087S-A5 for 62732-done@debbugs.gnu.org; Thu, 13 Jul 2023 17:51:36 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5FB6E1000C3; Thu, 13 Jul 2023 17:51:30 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 352B310009E; Thu, 13 Jul 2023 17:51:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1689285089; bh=hdSMH83G7FlERTuIDZXzytqAJhZvqikXa5/h/9HujIc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=c6NAPz+rmBsiaofLFC+fDiS5i/4XB8MLJ4MYmgghSWztQBg8EE4dY/krbwm0zlOC2 duYrWxkQLLTQWklJrxGu72VYD6h9oBKlxIm1WRVrAfCv23ols8PiRP3ki+p7ydz5NX oVaeWivtb+22EEj56XDFchVsGcYXXMgFWiYHCrs+ZiI4gYyGneYzU3pnfBbgWVv0JA 9H5avCv9pdXxJuJP+eVCjYuxo3qGchFWRfWc2Zg6P5lvimuLzL3vMx0neGFwCVk9VB +WdaxHIvllkXRwXqnp8PMtTZAYxjCOMevxACsdItk0Wg4JT27Y2XV82EcBhNkQsW6w BZ0m5NPWqow8A== Received: from pastel (unknown [104.247.239.133]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 084E51202AD; Thu, 13 Jul 2023 17:51:29 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <83y1jl5jrq.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 12 Jul 2023 16:42:01 +0300") Message-ID: References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> Date: Thu, 13 Jul 2023 17:51:28 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.113 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732-done Cc: sbaugh@janestreet.com, sbaugh@catern.com, 62732-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I prefer (1), because it avoids requesting the callers to remember to > ensure that every directory ends in a slash. OK, pushed. It is admittedly closer to the current semantics, so in a sense it's a step in the right direction and we could still change it later if/when needed. Thank you very much, Spencer, Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 17 01:03:53 2023 Received: (at 62732) by debbugs.gnu.org; 17 Jul 2023 05:03:53 +0000 Received: from localhost ([127.0.0.1]:48858 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLGOm-0008MP-Kr for submit@debbugs.gnu.org; Mon, 17 Jul 2023 01:03:52 -0400 Received: from mout.web.de ([212.227.15.14]:54101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLGOk-0008MC-DR for 62732@debbugs.gnu.org; Mon, 17 Jul 2023 01:03:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1689570210; x=1690175010; i=michael_heerdegen@web.de; bh=q12NTRuaes2M5pxKwnqTK+F2zwUlHDBz/govY1ie+z8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=S1GnQYNl5OnQP3ao0y94fa/kV1gPKDJDjYw8nSLeAxECZt5wfvrxubJ3YQqgx/B8cNaw3Q9 zMqOehhOGHL3Mw3nSWulyDJYPeSeLlybuxl4p3Cf6x+efclbWiSBmd8+Oce/ofdf9rfDVpOkU PKeefr1SAmJhKLEdNZQnN/uGQu9iEKvmrdfic6yUWY9kEnzU4wgMfqpg2QgXpKwRzRAHKQbbA MgGraRXKPUaIJWMprAlKpIJ30OPxXTli7pI9nZo9vOeW01anatYbAiQcCZ7Tv62lTM2QX8RVM 8dCUtTzaABPDI4zIgVRVhB4Mb1RvabbYATsd9eqBVLsk99gAk0bQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.36]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M4sbr-1qKzPZ1dxf-001lXe; Mon, 17 Jul 2023 07:03:30 +0200 From: Michael Heerdegen To: sbaugh@catern.com Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <87h6q7kcip.fsf@catern.com> (sbaugh@catern.com's message of "Thu, 13 Jul 2023 16:21:51 +0000 (UTC)") References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> <83pm4v4x6u.fsf@gnu.org> <87h6q7kcip.fsf@catern.com> Date: Mon, 17 Jul 2023 07:03:28 +0200 Message-ID: <87mszvuo2n.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:qC0kFrHHPTj4dR/ELQy76B14VHz+e6CE+cuL7gH4VY85GMl0Mk1 m5DsMrwQSQBzyH+MFdh0rKyUXhty2w2jC/UBssaeJTuTtNdOc3NKaqxMZCmX5T2/hIOu7CI JAfIDYUQlCMBuvwk1Yl9c7RgdlqCeN0iZmoCe/gZ+fgoMaCdjIlZ3bBVMc1i/VVwW7msFo3 nWSK7XkzWpH2NNgu/kubg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:/8N14BV3ejQ=;s7TnfBDcNoAU7SArbOxLx6SszZ9 6wHZ2perPHyCzP5z1/8C45zh+ARzgIyc1Vmg9dWnP+bqB3VbgYE6waJuiuBG8Wnq9r2a9/dBL nsXtGGUZkJl0T3nwcjjhxoQwHTESlpfOLF69igNAo2r/W1CsJHjksTyUDKFq+jiA7yVXs0ZOg nOuDVY3F0IC08SpERb8b7CJmJE+aONkJ56ja3Q8HRL2NzsjnJBP1jaAzgI0V262oMKFH4sK1u +QQPQqJhx8MQWtJPtxk11OtAdE3IVqlYlNsN6JcbptQZ8IeQP79ROaze2L0dzBUGZNJfVTT1b be1PiHEHKzMXq8qo3FLmgWDq5uceijTE9ion0ArXWo0spIVAGIGmX+IA7Keo77H1S/YmKxJ7o cXqtsAiCrm4JjcJU79d2OlH5jE4v0EPDujNSpR9Ser8MQkUbYyPZxTH+IO9kVvNJHoBam082O bjFtlpxt72PjYo/46MsjrLzpdKIy3f2URV3vSUfj32sAqfKmJ+Hd0/wbNLLCaXWlUZV8uSo5i qE1GGx4S0EXRnI0cvFquskCvnwVAlwi11inmYnKaf4+d/7b7ZEdkKJ/u1dSqSlTYNAzEc8aeV CGC5Str3KJ34+lBa0vz/Rr9TAs6ZqtzkaEkjGRsRm2gTYUBC7K5aSPkYgpyDvb+JZNqbS3Js6 vonDCQznvP1KN0vW6483z9wll8NToBlkcY93a5eqYY0W2so8TJ3pvjlGymlK/viYw5cwyMKq8 hyKJlEJ75Hb2gEGFafnVKPgUh+SbEA0jhMxdvQErOL2g1dRDG68K3NaLUTEi5nET9090IRexn duiTgnFjA7gww0pbUBuMctXrdfUb1+ks9oIwMXlfM2zM1UTUU+Rqvnzvgy0RXU1HuZ7FHh9ja aZdeFnE8grb5u033fu1MmB5pPBRAjSFqYXbkp+tnACbKojMhdiED/ztoIMYfk8FX0ThB68wDD 1lOLHw== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@janestreet.com, Eli Zaretskii , monnier@iro.umontreal.ca, 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) sbaugh@catern.com writes: > Subject: [PATCH] Don't recalculate the buffer basename inside uniquify Sorry but: Is it this patch's fault that it is not possible to visit the root directory "/" any more? | Debugger entered--Lisp error: (error "Empty string for buffer name is not allowed") | get-buffer-create("" nil) | generate-new-buffer("") | create-file-buffer("/") | dired-internal-noselect("/" nil) | dired-noselect("/" nil) | dired("/" nil) TIA, Michael. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 17 07:35:10 2023 Received: (at 62732) by debbugs.gnu.org; 17 Jul 2023 11:35:10 +0000 Received: from localhost ([127.0.0.1]:49153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLMVS-00080K-BQ for submit@debbugs.gnu.org; Mon, 17 Jul 2023 07:35:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLMVN-0007zf-1s for 62732@debbugs.gnu.org; Mon, 17 Jul 2023 07:35:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLMVH-0007ZK-6o; Mon, 17 Jul 2023 07:34:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ml0GgJAyC02d34QzLAuwZknh3ZVBT7iTEwPI6WOlZJ8=; b=KW2JxXaCNd9R W3J0GAxLyqcpOwpJ/zcWOnRh0Epr6OadRlkGGTtYtBRMbHjjljwim+DuGkcArdYiFKpLAUBvJLlvj +i+W/1dkKwscDSY/4ti/y+MNGCADe0EKLC8n7hsnY2RrLYHmFQ3gXDMoLxAXjuyJ71kaTGKHvx4lM /MPaCaJenIxUm3madhFzaPHX800G36NPT7QZy2V2/1v7vnCMj/FBw6op43SpkkTZ8XpDBOKufuWMy BpEFfTpDDYsy9awSHDMf2dMpWNFV3UxmeIu4tn2RwbXoGaio+Dzn5HIV45MhcNDmhZ2HwD4EWRVjc Q2Yfk+1Awo3ruPOi0NXL/g==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLMVD-0000zv-HM; Mon, 17 Jul 2023 07:34:57 -0400 Date: Mon, 17 Jul 2023 14:35:20 +0300 Message-Id: <837cqy93ev.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87mszvuo2n.fsf@web.de> (message from Michael Heerdegen on Mon, 17 Jul 2023 07:03:28 +0200) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edotn7sx.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> <83pm4v4x6u.fsf@gnu.org> <87h6q7kcip.fsf@catern.com> <87mszvuo2n.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: sbaugh@catern.com, 62732@debbugs.gnu.org, monnier@iro.umontreal.ca, sbaugh@janestreet.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: Eli Zaretskii , sbaugh@janestreet.com, > monnier@iro.umontreal.ca, 62732@debbugs.gnu.org > Date: Mon, 17 Jul 2023 07:03:28 +0200 > > sbaugh@catern.com writes: > > > Subject: [PATCH] Don't recalculate the buffer basename inside uniquify > > Sorry but: Is it this patch's fault that it is not possible to visit the root > directory "/" any more? > > | Debugger entered--Lisp error: (error "Empty string for buffer name is not allowed") > | get-buffer-create("" nil) > | generate-new-buffer("") > | create-file-buffer("/") > | dired-internal-noselect("/" nil) > | dired-noselect("/" nil) > | dired("/" nil) Yes. Should be fixed now. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 18 00:13:31 2023 Received: (at 62732) by debbugs.gnu.org; 18 Jul 2023 04:13:31 +0000 Received: from localhost ([127.0.0.1]:51312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLc5b-0002nk-9Q for submit@debbugs.gnu.org; Tue, 18 Jul 2023 00:13:31 -0400 Received: from mout.web.de ([212.227.17.12]:33701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLc5V-0002nT-BJ for 62732@debbugs.gnu.org; Tue, 18 Jul 2023 00:13:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1689653598; x=1690258398; i=michael_heerdegen@web.de; bh=WteC5gks5thWXmBA/WzvnwJ7kU/7Helpgn0qWmW+lQY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=qQRwN7D9La0c0GeS421miLPcQQPCosoGi1BuRQqYpcWm/cwuhVtflIa1oLHxCvHe9iN/Qwd oayniLeveTxxCssBP1FV2ZFtSPGPPGciClH5QkZfQXvTMGgq2UesR5MiBb4j5PgfZ7KyJl1AV GjpO0Ef67sNweOfAUZGfmvonglcl/hNPWoA0n/TEB4cbiwGTdjng86bauDaWKK3ayMAEEHaha 1inRgmF84djBYPybLpCIncqzCncXdRBwxJbUQsvsxKhYnV6VPO2guCfSjwUI0lUFoZBqNggrs ESG2ddiXn6lCd76URaWsnRoFCEo3UelSXewyukfNMgrHMJArSGlw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([84.59.210.36]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N8Elm-1pr2Tu2i9Y-014KkM; Tue, 18 Jul 2023 06:13:18 +0200 From: Michael Heerdegen To: Eli Zaretskii Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD In-Reply-To: <837cqy93ev.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 17 Jul 2023 14:35:20 +0300") References: <87h6tpn8d5.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> <83pm4v4x6u.fsf@gnu.org> <87h6q7kcip.fsf@catern.com> <87mszvuo2n.fsf@web.de> <837cqy93ev.fsf@gnu.org> Date: Tue, 18 Jul 2023 06:13:17 +0200 Message-ID: <87h6q1c0wy.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:ho6kdd0XLaOk3ZKKWCBlCg8AgE67WeoWOtSff2npUJAXBEAlkSp zzH8H7lm6FNBysZJs6A4qJ3oadJ0l+ZjH6gtoU7fS4l1m/uX5FRnKKapGpPu+hW/vZQRxX5 +a2BFvzmUsDjfpiPJz3ATjRTj2ShZt71Hwv/eRRwPV7UhGWIBfulhNjosJss5UR0xmZAr0Q bY9WQ6XFzh9RTRQGiI7Zg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:GsExfQ9M3yQ=;VcyqhzCJAg7fuuOHSFXUyvA791/ HuekHPg/+HL3N0fQoHEymNGDbOc8+zyQ0tn5KCMCVhqc1odBtdwBxSw/jz5mRPewYn7QDL/X5 bawZNBLKSHA54yVNLEa4tIkXrKuTbf2zUOYX3/bfV86SCgC8I7pXnwI7UQF7yAHK0DwbpNAbb oRSPTHsl51XxbMs4qJPVNvtFGes/wzhvGs3LcuwXLnCfel5eKw62hKRG+29iYRNo4mSmQQgXs f/H79/HoImi7O92WV5skaCdXGSfPr8TprPaBEYctG/jxKPyg4rvD0i07EsS8Cb6sajsGDphSm NcZf6VhNOCNB0gJ0TPkYo8BJWTCAj0MojVFIHKG8zHZ/Nsv03tZf8q1mAEByQEs9DlHFymyMB wcOj5knLvsPpTE5zBv+p8Gw1vw6HbasxF4MCftFCr+4kuPSFGk8BtQbaMoY/lvMNRtbMkBmO2 zprfQEFmw2dFgwUIUMcEolH0cJSTiRuvxBfGcZNaM79T1QlF8uvWhafU4QWoAbPCgARO24xRE VheMU4pnGcykHiDnbS//Cpiv2NXgSnZD1GPzhKoCwJtRcD0+90u0Hf8Vmtlz/cPKiXv+vdMIj qmF20W/9Xu7TSRiyZzTQjb/j9VeBVxA4CSjCH5rVoclx3+NDLZ2M9A30cVvE/dVVmMTJU02cd mDPJGSa4aRLdU+PK751rXw+9XddNpFy2rujpm2D9eBuClFTEjt0bYG0XLd1Aene096gPgBl6S 1hxLcbwRGB2i9yCoQo4M9ree3RnX06tGA2XpBY5yPpGvj6mZU+uhfL2GU4C0ndyqDDO+4KIqT uWDI+hvuYyaB0qXNSnzkkBG0Bkbf+P9pp2eSDGsZW0Jjc/g3Lr2zdCOj9MHQ6ejKEv5CUg10O CnuWDiEqG1xKOz9yA8rhBwB/CYCcLRkfOzpn1uCV+dvt65mWaQMs1EcQTKZnv3ZHgvMspcOzc 7jpXv7R8fOJ3VpTiL2lflgbwR8w= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > > | get-buffer-create("" nil) > > | generate-new-buffer("") > > | create-file-buffer("/") > > | dired-internal-noselect("/" nil) > > | dired-noselect("/" nil) > > | dired("/" nil) > > Yes. Should be fixed now. Indeed. Thank you. Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 18 07:12:09 2023 Received: (at 62732) by debbugs.gnu.org; 18 Jul 2023 11:12:09 +0000 Received: from localhost ([127.0.0.1]:51689 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLici-0006Ai-Ts for submit@debbugs.gnu.org; Tue, 18 Jul 2023 07:12:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLicg-0006AI-UR for 62732@debbugs.gnu.org; Tue, 18 Jul 2023 07:12:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLicb-0002ns-LZ; Tue, 18 Jul 2023 07:12:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=NyYjN62yd7YUFNcJCXYex6oc+o6FWMDViMjLiI5oQ8E=; b=Er8Wkm7YTN7L qQF3bOUMIOCb7aXrfFjD50jOGlmjJ/PKRgO9YaPTYqnxkTzb3IjLGTeUDdSJtOqP3bCAXteCbmuKH 0InqWTEGJe2gsM+nu8l4EVR27eex0mky+R3qWy1NkMUI3AqJzKV3piQBCN6mdjsbEKUeefH0s2Lzi f5N+YJPORGaSqT/H2tG0jPBmlnZUDay9AC3BFe9uA6KCz6dh0vhm+L1UoAjmq8OeaO9p07ZdDDY25 tpQEa+2gOW51gEWqslSs+GxEsGki5l1gIf9fr3iMqVgMd3umd7TWJdvPJ0N2zGi/saDvYzczPzHse vC0x8oEy0g1UI175F9Q3ew==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLica-00066Y-Fl; Tue, 18 Jul 2023 07:12:01 -0400 Date: Tue, 18 Jul 2023 14:12:29 +0300 Message-Id: <83jzux79sy.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87h6q1c0wy.fsf@web.de> (message from Michael Heerdegen on Tue, 18 Jul 2023 06:13:17 +0200) Subject: Re: bug#62732: 29.0.60; uniquify-trailing-separator-p affects any buffer whose name matches a dir in CWD References: <87h6tpn8d5.fsf@catern.com> <87edlhm6wq.fsf@catern.com> <87o7kklf9c.fsf@catern.com> <83r0pf9b7d.fsf@gnu.org> <83fs5v8tsw.fsf@gnu.org> <83edlf89qp.fsf@gnu.org> <83v8eq7j3i.fsf@gnu.org> <83pm4y79dw.fsf@gnu.org> <83y1jl5jrq.fsf@gnu.org> <83o7kg5s9o.fsf@gnu.org> <87mszzkduy.fsf@catern.com> <83pm4v4x6u.fsf@gnu.org> <87h6q7kcip.fsf@catern.com> <87mszvuo2n.fsf@web.de> <837cqy93ev.fsf@gnu.org> <87h6q1c0wy.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62732 Cc: 62732@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: 62732@debbugs.gnu.org > Date: Tue, 18 Jul 2023 06:13:17 +0200 > > Eli Zaretskii writes: > > > > | get-buffer-create("" nil) > > > | generate-new-buffer("") > > > | create-file-buffer("/") > > > | dired-internal-noselect("/" nil) > > > | dired-noselect("/" nil) > > > | dired("/" nil) > > > > Yes. Should be fixed now. > > Indeed. Thank you. Thanks for testing. From unknown Sun Jun 22 22:42:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 15 Aug 2023 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator