From unknown Wed Jun 18 00:24:44 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#58784 <58784@debbugs.gnu.org> To: bug#58784 <58784@debbugs.gnu.org> Subject: Status: 28.2; project-buffers incorrect under let-bound default-directory Reply-To: bug#58784 <58784@debbugs.gnu.org> Date: Wed, 18 Jun 2025 07:24:44 +0000 retitle 58784 28.2; project-buffers incorrect under let-bound default-direc= tory reassign 58784 emacs submitter 58784 Sean Devlin severity 58784 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 25 20:13:56 2022 Received: (at submit) by debbugs.gnu.org; 26 Oct 2022 00:13:56 +0000 Received: from localhost ([127.0.0.1]:52627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1onU3P-0002lb-Kf for submit@debbugs.gnu.org; Tue, 25 Oct 2022 20:13:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:36898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1onU3O-0002lU-2B for submit@debbugs.gnu.org; Tue, 25 Oct 2022 20:13:54 -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 1onU3N-0000BW-Sr for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:13:53 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onU3L-0006Os-OH for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:13:53 -0400 Received: by mail-qv1-xf34.google.com with SMTP id mi9so949225qvb.8 for ; Tue, 25 Oct 2022 17:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toadstyle-org.20210112.gappssmtp.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=K6cdujQFCDFOIdR//FpArhhdrnRHViXudKnF5lvl96c=; b=zpuGOLe4lqidGSoxrpkqcBidkdn23FhwhvNH6ponwbKkTe01aiu+SyCEV9KiSddUtJ LtxwGQD0JZDg7p39l3rAzPegvKvdDlOwKn4XXkfhyrZIX5m0oxd5XhWD6QUsOL970CEz tOH0OnGeY9cCF2K9xetdobc37A18gzh24xV6sDpwRPm9y4UTJLhRlS5lAI0vXJ2lAIxa vkvrNElK8Z/S+iCz0EY6a9uYhfNXXWnVBSYSMUinPfnwyqgJXpsEAndLPSV8JnaeceRM +ClTLoiGvjSCvDPuNJwtUa3sQXoS5CHUi70ziZRKY1ufQ0VcBhACQUBIZoTe8bFoRJZO 4AiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K6cdujQFCDFOIdR//FpArhhdrnRHViXudKnF5lvl96c=; b=nNhdGndurKvU7VHerE+Ao3ljmIATA+znF2kMfWIiJTrJHrPdHr8mmeGhOgJgE8x6wQ Rmz5FH9X5MNlUoqge4uhqQapBtwOMWSsjCOZCsXzLi13TVQB+nD0JF4rqCXaUb4ralz3 81X0ViNuHRERpWR3O+VeYUgVn2oKxQYbJIeq21RVonb3RQU+4y0LiAP0BMwixDZbuZ+R 8pCgxE+I32ZeHwvjC17cyOu949FNuaW181lDfWwV1ZnxrKwoKP0u9iC/0b+ir7ItTwsi ySyYiRXTlu9Z74LIrZyvS1H1NLrCR1lyGFOkgpk3E0g2FhsJ3azBO2edPNK+NEEGfKTv x8ow== X-Gm-Message-State: ACrzQf0Dv3e31hxk9aQY8uZIDiQhIWkX+nf+MKfAzEGERkNNWr3HXWmO fQeRWOlTBNAoJxeOtT0UVKOiknES+Avz0inW X-Google-Smtp-Source: AMsMyM5rX65EZaX5p60JKiGGOmtF/TbZZ75EMXVbffzM0mai8WsyvnS9IfPp8o4ew67Cfv0lBdrvaA== X-Received: by 2002:a05:6214:2245:b0:4b7:b2a1:7aff with SMTP id c5-20020a056214224500b004b7b2a17affmr26767064qvc.114.1666743229917; Tue, 25 Oct 2022 17:13:49 -0700 (PDT) Received: from smtpclient.apple (pool-173-56-106-162.nycmny.ftas.verizon.net. [173.56.106.162]) by smtp.gmail.com with ESMTPSA id r11-20020a05620a298b00b006bba46e5eeasm3146189qkp.37.2022.10.25.17.13.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2022 17:13:49 -0700 (PDT) From: Sean Devlin Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.51\)) Subject: 28.2; project-buffers incorrect under let-bound default-directory Message-Id: Date: Tue, 25 Oct 2022 20:13:36 -0400 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3731.300.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=spd@toadstyle.org; helo=mail-qv1-xf34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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 (--) Hi folks, The project.el function project-buffers can return incorrect results when invoked while a let-binding for default-directory is in effect. This is because project-buffers (both the default and vc-based implementations) does its work by inspecting the local value of default-directory in each buffer, and the let-binding temporarily affects this value. To see this in action, start emacs with -Q and evaluate the following forms in order: (require 'project) (find-file-noselect "/tmp/tmpfile") (setq my-project '(transient . "/tmp/")) ;; just the tmpfile (project-buffers my-project) ;; both tmpfile and scratch (let ((default-directory "/tmp/")) (project-buffers my-project)) In the last form, project-buffers includes the current buffer (i.e. the scratch buffer in our example) with the results. (This is true even if the current buffer is visiting a file in some unrelated directory.) This matters because the command project-switch-project let-binds default-directory before calling project-switch-commands. This means that if you set project-switch-commands to some function that calls project-buffers, you will get incorrect results. For example, evaluate the following forms in order: (defun my-list-project-buffers () "List the current project's buffers." (interactive) (let ((buffer-list (project-buffers (project-current t))) (buffer-name (project-prefixed-buffer-name "my-project-buffer-list"))) (with-current-buffer (get-buffer-create buffer-name) (erase-buffer) (save-excursion (dolist (buffer buffer-list) (insert (buffer-name buffer)) (insert ?\n)))) (switch-to-buffer buffer-name))) (setq project-switch-commands #'my-list-project-buffers) ;; list tmpfile but also scratch (project-switch-project "/tmp/") In GNU Emacs 28.2 System Description: macOS Configured using: 'configure --disable-silent-rules --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp --infodir=/opt/homebrew/Cellar/emacs/28.2/share/info/emacs --prefix=/opt/homebrew/Cellar/emacs/28.2 --with-gnutls --without-x --with-xml2 --without-dbus --with-modules --without-ns --without-imagemagick --without-selinux' Configured features: ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER THREADS ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/d Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow regexp-opt sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-print edebug backtrace help-mode tool-bar find-func vc-mtn vc-hg vc-git diff-mode easy-mmode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc cl-loaddefs cl-lib vc-dispatcher image project seq term/xterm xterm byte-opt gv bytecomp byte-compile cconv iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic 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 simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads kqueue multi-tty make-network-process emacs) Memory information: ((conses 16 72031 7674) (symbols 48 8797 1) (strings 32 26201 1172) (string-bytes 1 817049) (vectors 16 14915) (vector-slots 8 168301 9701) (floats 8 42 454) (intervals 56 324 3) (buffers 992 14)) From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 20:49:20 2022 Received: (at 58784) by debbugs.gnu.org; 29 Oct 2022 00:49:20 +0000 Received: from localhost ([127.0.0.1]:34557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooa2J-0008OM-MQ for submit@debbugs.gnu.org; Fri, 28 Oct 2022 20:49:20 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:36768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooa2H-0008O8-Kk for 58784@debbugs.gnu.org; Fri, 28 Oct 2022 20:49:18 -0400 Received: by mail-wr1-f52.google.com with SMTP id j15so8589936wrq.3 for <58784@debbugs.gnu.org>; Fri, 28 Oct 2022 17:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:sender:from:to:cc:subject:date :message-id:reply-to; bh=CgzQDahNmrZMBZq29AiHbgDZ50cWLeTrfWV3vBVU1bE=; b=jfSH0SNaeSH3gdJ76T9BKfnbkkHokTAhxUuUSZugZWjVhyxIrGYGQJxks3d3QzaM9I A9Tu//Y97/ms71e9vCscZP5ShuYLLG2SPRjHVjnCAe12PPLIpwXRSN5ryspbGHZLT1TO 3UXy46j7tihkFqK71eJG7MfyFngPz1JAYoErcICUX0pYGHCxpCMM7013giUsgHYj46SY ggCWFS5Qn0P+n3PRjPzFi/wSfXZ03gf3bq+s3FZm5pLoHo+spb6Gl2UmePOe2o9fAsdp 3YpfR6AAFbv4Cw9chb1tZJzUVrZBG6g51CzzDNn5kgyx3V4u1wE/9+F38vqxeUZYi7Kh csKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CgzQDahNmrZMBZq29AiHbgDZ50cWLeTrfWV3vBVU1bE=; b=It8ixJ5z+bq4xnVtky2ZcgnNiu53h2GhPhh9mHouHMuuEsNHtb0apY+n4DGO/ctf3a IRT2f7KcDjZ2PqXZPTFXFWH70uYK/BVr7PaoAwqusQKDxhgAsjDVlzQv7ibLmMEhMYdo pjflc4h+yP46hLvAxuHfGjf/p4UbdUUGfMS+CtNFkdH9mC1yUPqVeBsaYcpeKaG8du0z 4PDLCXMxgjCwyUD2Y3XIJh7oXfzbpz//deNzqR4omIFk8w6ocd4kzcKQ2p/sEeEMyfi+ KAZ2fT/GAKAKGOUem7zOqAFmLL8umTg+JCSzgWMXBiDGhOgMT5lNw3jtMO+SgZZs4hDd rmYw== X-Gm-Message-State: ACrzQf1tmaGQOewXqfGpGdqSRWZAbGY99X8oeG4F+iaK8SkGJaIIT4JO uSQ3MwfyzxoWMsuTkWAezoc= X-Google-Smtp-Source: AMsMyM581HOS0CUee0FvEw8fQ51pBfB35Wdc8SL3Wl71yF53KAKbhIL1z0g8YY02obgVBjT2UpohEg== X-Received: by 2002:a05:6000:100c:b0:235:6980:aa24 with SMTP id a12-20020a056000100c00b002356980aa24mr1016335wrx.238.1667004551519; Fri, 28 Oct 2022 17:49:11 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j17-20020a05600c191100b003b47b913901sm17686166wmq.1.2022.10.28.17.49.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 17:49:10 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------y5TN2bwgzuY6fIbzdxrLFfrk" Message-ID: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> Date: Sat, 29 Oct 2022 03:49:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Content-Language: en-US To: Sean Devlin , 58784@debbugs.gnu.org References: From: Dmitry Gutov In-Reply-To: X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 58784 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 (--) This is a multi-part message in MIME format. --------------y5TN2bwgzuY6fIbzdxrLFfrk Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi! On 26.10.2022 03:13, Sean Devlin wrote: > The project.el function project-buffers can return incorrect results > when invoked while a let-binding for default-directory is in > effect. This is because project-buffers (both the default and vc-based > implementations) does its work by inspecting the local value of > default-directory in each buffer, and the let-binding temporarily > affects this value. > > To see this in action, start emacs with -Q and evaluate the following > forms in order: > > (require 'project) > > (find-file-noselect "/tmp/tmpfile") > (setq my-project '(transient . "/tmp/")) > > ;; just the tmpfile > (project-buffers my-project) > > ;; both tmpfile and scratch > (let ((default-directory "/tmp/")) > (project-buffers my-project)) Thanks for the report, I can see the problem. > In the last form, project-buffers includes the current buffer (i.e. the > scratch buffer in our example) with the results. (This is true even if > the current buffer is visiting a file in some unrelated directory.) > > This matters because the command project-switch-project let-binds > default-directory before calling project-switch-commands. This means > that if you set project-switch-commands to some function that calls > project-buffers, you will get incorrect results. > > For example, evaluate the following forms in order: > > (defun my-list-project-buffers () > "List the current project's buffers." > (interactive) > (let ((buffer-list (project-buffers (project-current t))) > (buffer-name (project-prefixed-buffer-name "my-project-buffer-list"))) > (with-current-buffer (get-buffer-create buffer-name) > (erase-buffer) > (save-excursion > (dolist (buffer buffer-list) > (insert (buffer-name buffer)) > (insert ?\n)))) > (switch-to-buffer buffer-name))) > > (setq project-switch-commands #'my-list-project-buffers) Looks like a reimplementation of projectile-ibuffer, seems useful. > ;; list tmpfile but also scratch > (project-switch-project "/tmp/") Not sure how to fix this, though. In bug#53626 we discussed a somewhat similar problem, and a let-binding seems impossible to "escape". What else can we do? One option is to change the signature of every compatible command to take the project object as its first argument. Might have been more realistic when the package was first written, too much breakage now, probably. Another would be to add a new var to help override the project choice without touch default-directory. Something like the attached. Please try it out. --------------y5TN2bwgzuY6fIbzdxrLFfrk Content-Type: text/x-patch; charset=UTF-8; name="project-current-directory-override.diff" Content-Disposition: attachment; filename="project-current-directory-override.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL3Byb2plY3QuZWwgYi9saXNwL3Byb2dtb2Rl cy9wcm9qZWN0LmVsCmluZGV4IGFjMjc4ZWRkNDAuLjQ4ZWQwMzNmYTEgMTAwNjQ0Ci0tLSBh L2xpc3AvcHJvZ21vZGVzL3Byb2plY3QuZWwKKysrIGIvbGlzcC9wcm9nbW9kZXMvcHJvamVj dC5lbApAQCAtMTc1LDggKzE3NSwxNCBAQCBwcm9qZWN0LWZpbmQtZnVuY3Rpb25zCiBgY2wt ZGVmbWV0aG9kJyBjYW4gZGlzcGF0Y2ggb24sIGxpa2UgYSBjb25zIGNlbGwsIG9yIGEgbGlz dCwgb3IgYQogQ0wgc3RydWN0LiIpCiAKLShkZWZ2YXIgcHJvamVjdC1jdXJyZW50LWluaGli aXQtcHJvbXB0IG5pbAotICAiTm9uLW5pbCB0byBza2lwIHByb21wdGluZyB0aGUgdXNlciBp biBgcHJvamVjdC1jdXJyZW50Jy4iKQorKGRlZmluZS1vYnNvbGV0ZS12YXJpYWJsZS1hbGlh cworICAncHJvamVjdC1jdXJyZW50LWluaGliaXQtcHJvbXB0CisgICdwcm9qZWN0LWN1cnJl bnQtZGlyZWN0b3J5LW92ZXJyaWRlCisgICIyOS4xIikKKworKGRlZnZhciBwcm9qZWN0LWN1 cnJlbnQtZGlyZWN0b3J5LW92ZXJyaWRlIG5pbAorICAiVmFsdWUgdG8gdXNlIGluc3RlYWQg b2YgYGRlZmF1bHQtZGlyZWN0b3J5JyB3aGVuIGRldGVjdGluZyB0aGUgcHJvamVjdC4KK1do ZW4gaXQgaXMgbm9uLW5pbCwgYHByb2plY3QtY3VycmVudCcgd2lsbCBza2lwIGFsd2F5cyBz a2lwIHByb21wdGluZy4iKQogCiA7OzsjIyNhdXRvbG9hZAogKGRlZnVuIHByb2plY3QtY3Vy cmVudCAoJm9wdGlvbmFsIG1heWJlLXByb21wdCBkaXJlY3RvcnkpCkBAIC0xOTUsMTEgKzIw MSwxMiBAQCBwcm9qZWN0LWN1cnJlbnQKIAogU2VlIHRoZSBkb2Mgc3RyaW5nIG9mIGBwcm9q ZWN0LWZpbmQtZnVuY3Rpb25zJyBmb3IgdGhlIGdlbmVyYWwgZm9ybQogb2YgdGhlIHByb2pl Y3QgaW5zdGFuY2Ugb2JqZWN0LiIKLSAgKHVubGVzcyBkaXJlY3RvcnkgKHNldHEgZGlyZWN0 b3J5IGRlZmF1bHQtZGlyZWN0b3J5KSkKKyAgKHVubGVzcyBkaXJlY3RvcnkgKHNldHEgZGly ZWN0b3J5IChvciBwcm9qZWN0LWN1cnJlbnQtZGlyZWN0b3J5LW92ZXJyaWRlCisgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdC1kaXJlY3RvcnkpKSkK ICAgKGxldCAoKHByIChwcm9qZWN0LS1maW5kLWluLWRpcmVjdG9yeSBkaXJlY3RvcnkpKSkK ICAgICAoY29uZAogICAgICAocHIpCi0gICAgICgodW5sZXNzIHByb2plY3QtY3VycmVudC1p bmhpYml0LXByb21wdAorICAgICAoKHVubGVzcyBwcm9qZWN0LWN1cnJlbnQtZGlyZWN0b3J5 LW92ZXJyaWRlCiAgICAgICAgIG1heWJlLXByb21wdCkKICAgICAgIChzZXRxIGRpcmVjdG9y eSAocHJvamVjdC1wcm9tcHQtcHJvamVjdC1kaXIpCiAgICAgICAgICAgICBwciAocHJvamVj dC0tZmluZC1pbi1kaXJlY3RvcnkgZGlyZWN0b3J5KSkpKQpAQCAtMTY2Nyw4ICsxNjc0LDcg QEAgcHJvamVjdC1zd2l0Y2gtcHJvamVjdAogICAobGV0ICgoY29tbWFuZCAoaWYgKHN5bWJv bHAgcHJvamVjdC1zd2l0Y2gtY29tbWFuZHMpCiAgICAgICAgICAgICAgICAgICAgICBwcm9q ZWN0LXN3aXRjaC1jb21tYW5kcwogICAgICAgICAgICAgICAgICAgIChwcm9qZWN0LS1zd2l0 Y2gtcHJvamVjdC1jb21tYW5kKSkpKQotICAgIChsZXQgKChkZWZhdWx0LWRpcmVjdG9yeSBk aXIpCi0gICAgICAgICAgKHByb2plY3QtY3VycmVudC1pbmhpYml0LXByb21wdCB0KSkKKyAg ICAobGV0ICgocHJvamVjdC1jdXJyZW50LWRpcmVjdG9yeS1vdmVycmlkZSBkaXIpKQogICAg ICAgKGNhbGwtaW50ZXJhY3RpdmVseSBjb21tYW5kKSkpKQogCiAocHJvdmlkZSAncHJvamVj dCkK --------------y5TN2bwgzuY6fIbzdxrLFfrk-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 13:47:40 2022 Received: (at 58784) by debbugs.gnu.org; 31 Oct 2022 17:47:40 +0000 Received: from localhost ([127.0.0.1]:41706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opYsu-0004ep-9Z for submit@debbugs.gnu.org; Mon, 31 Oct 2022 13:47:40 -0400 Received: from mail-qk1-f169.google.com ([209.85.222.169]:39533) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opYsr-0004eY-V8 for 58784@debbugs.gnu.org; Mon, 31 Oct 2022 13:47:38 -0400 Received: by mail-qk1-f169.google.com with SMTP id g10so1518373qkl.6 for <58784@debbugs.gnu.org>; Mon, 31 Oct 2022 10:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toadstyle-org.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=u78KM0W0+iPsv8KnoW4GcIzZB5i7nqwezj41eCQ8qag=; b=2RSBYcFjCH/Qi5Ta2jEjrOmTAKBVyJrMJ4YirlV8aSaC1giX/iGakrAaUS3uFnkSi6 AK1PbZ2/PHIgA7biaFrNerbKIbRZpj4MVGrAO0+FUyyvyCGW3CK04j/bVHlPz3Ht77oc uZjiYf7VaOZ3IEVJyPphgHk1xj8Na8XQ60gxiZ5BMzNdvEIGeIWkK1JxrpGYaYf8V+Ya BlxTvhnuFXm+PhGJgMwAedLGhtwrrcR+0Pe52OEDqyXmVYZA6t0I4HkgY3O86BEUCw7r bAOTMu21rJzAApqBn4is8Z+2sUG2Qis7poY209z0m+qqF92xaVKYFEfChqqKpeK9qazB to1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u78KM0W0+iPsv8KnoW4GcIzZB5i7nqwezj41eCQ8qag=; b=UDzc8Z4CsyuNTy76yy4nL+fUCMcLNJcfgl/i15TAR3Nt1yI3nyQt6GFiVTgwxBRzm0 jDvyCieeYREZVBF35l271M/E+5G706cREAMtxX7Fcz6IL9M3/VH2HbOoUbXvXXI4n982 4EmMbUUG1qcwHFpp7tDNJ6UUZTjN537+WI6C1CKsG+6qsiFQFzVu2sdWgP2xxhVFbpEk GAFhYAKi2MtVt1gFpJTxo3GyqYdH2jOxzE1O7b/DJs2ROjr31md7BmGomxosnT5esZHQ MHBcFU5xmfPxLyLT1g2e/1mDKLwBW9qg8pKF8EfOgxucCHePsN24umFTnqF458tdDHDu Qedg== X-Gm-Message-State: ACrzQf1CizOSBwePWj1Tx0YYUd1sMsA7J4aDi1ps8X7r+E6LOE0/1dLV kfld71HFn50djjDVWZ50TFWZsHegDLsAmkZG X-Google-Smtp-Source: AMsMyM4S4c/GvGiG83YpVqe7JNExyeAtJSWk659l6X2sXZo1YtymNR5ZgGddeWrcRHb/8n+o3Ks1vQ== X-Received: by 2002:a05:620a:1667:b0:6fa:1b5e:b9b4 with SMTP id d7-20020a05620a166700b006fa1b5eb9b4mr7957466qko.141.1667238452344; Mon, 31 Oct 2022 10:47:32 -0700 (PDT) Received: from smtpclient.apple (pool-173-56-106-162.nycmny.ftas.verizon.net. [173.56.106.162]) by smtp.gmail.com with ESMTPSA id l10-20020a37f90a000000b006b9c9b7db8bsm5076262qkj.82.2022.10.31.10.47.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2022 10:47:31 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.51\)) Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory From: Sean Devlin In-Reply-To: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> Date: Mon, 31 Oct 2022 13:47:20 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> To: Dmitry Gutov X-Mailer: Apple Mail (2.3731.300.51) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 58784 Cc: 58784@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 (-) Hi Dmitry, > On Oct 28, 2022, at 8:49 PM, Dmitry Gutov wrote: >=20 > Hi! >=20 > On 26.10.2022 03:13, Sean Devlin wrote: >> The project.el function project-buffers can return incorrect results >> when invoked while a let-binding for default-directory is in >> effect. This is because project-buffers (both the default and = vc-based >> implementations) does its work by inspecting the local value of >> default-directory in each buffer, and the let-binding temporarily >> affects this value. >> To see this in action, start emacs with -Q and evaluate the following >> forms in order: >> (require 'project) >> (find-file-noselect "/tmp/tmpfile") >> (setq my-project '(transient . "/tmp/")) >> ;; just the tmpfile >> (project-buffers my-project) >> ;; both tmpfile and scratch >> (let ((default-directory "/tmp/")) >> (project-buffers my-project)) >=20 > Thanks for the report, I can see the problem. >=20 >> In the last form, project-buffers includes the current buffer (i.e. = the >> scratch buffer in our example) with the results. (This is true even = if >> the current buffer is visiting a file in some unrelated directory.) >> This matters because the command project-switch-project let-binds >> default-directory before calling project-switch-commands. This means >> that if you set project-switch-commands to some function that calls >> project-buffers, you will get incorrect results. >> For example, evaluate the following forms in order: >> (defun my-list-project-buffers () >> "List the current project's buffers." >> (interactive) >> (let ((buffer-list (project-buffers (project-current t))) >> (buffer-name (project-prefixed-buffer-name = "my-project-buffer-list"))) >> (with-current-buffer (get-buffer-create buffer-name) >> (erase-buffer) >> (save-excursion >> (dolist (buffer buffer-list) >> (insert (buffer-name buffer)) >> (insert ?\n)))) >> (switch-to-buffer buffer-name))) >> (setq project-switch-commands #'my-list-project-buffers) >=20 > Looks like a reimplementation of projectile-ibuffer, seems useful. Yeah, in my real configuration, I defined this as an ibuffer filter, but = I thought a simpler example would be better for the bug report. >=20 >> ;; list tmpfile but also scratch >> (project-switch-project "/tmp/") >=20 > Not sure how to fix this, though. In bug#53626 we discussed a somewhat = similar problem, and a let-binding seems impossible to "escape". >=20 > What else can we do? One option is to change the signature of every = compatible command to take the project object as its first argument. = Might have been more realistic when the package was first written, too = much breakage now, probably. >=20 > Another would be to add a new var to help override the project choice = without touch default-directory. >=20 > Something like the attached. Please try it = out. I agree, the fix is not obvious. A workaround I used in my configuration is to add an advice to = project-switch-project to wrap it in a with-temp-buffer form. This way, = it=E2=80=99s only the default-directory of the temp buffer that gets = corrupted. Not a very clean solution, but it seems to work. = Unfortunately, you need to remember to do this in many places; for = example, I had to do the same thing in my project-ibuffer command. Your solution looks cleaner. I gave it a try (along with disabling my = advice), and it seems to work pretty well. Thanks for the fix! There might be some more places where it needs to be applied. For = example, project-prefixed-buffer-name still inspects the = default-directory. (Maybe project-prefixed-buffer-name should just call = project-root or similar?) I think there=E2=80=99s still some fragility in the project-buffers = function, since any callers need to be careful not to bind = default-directory. It might be useful to call this out in the doc string = or in the manual. Thanks for your help!= From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 01 19:36:11 2022 Received: (at 58784) by debbugs.gnu.org; 1 Nov 2022 23:36:11 +0000 Received: from localhost ([127.0.0.1]:44440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oq0nj-0007Nm-5w for submit@debbugs.gnu.org; Tue, 01 Nov 2022 19:36:11 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:40501) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oq0ne-0007NF-NY for 58784@debbugs.gnu.org; Tue, 01 Nov 2022 19:36:09 -0400 Received: by mail-wm1-f47.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso260817wme.5 for <58784@debbugs.gnu.org>; Tue, 01 Nov 2022 16:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=sxd6XPXbqjGlwm0Uq3+TuwmU7RWEszKQgcwb1zdvGBc=; b=hn8AneWRpC4Db53Ogu7yS91S68FKYtHWfxspd6eV207KLIt/Icihf+ObR5VZIi1hSh YBcaPOcPpMSXVx4aezFCLKnaN6bsNIZbKu6wGetVqpaJDQGzXL/iEk+8bjCQJmyFPQcT 2ikbGYHySrzqwvGd7j3SGzJW3rwUSpvkjmBfmawd+snsraz0cdzzLLH44siUKmjJeJXm AVo8znqVc/5/GECDJ/gk2Q98o9paOgLXqcGuEV84e6Qu4Ea7bM/Cl4uAewe6GiPoX6Kq 1Y4cPb7WL54zvBbeopu0nUpxUQSHg5YMxt7poeov/AiKgyHQiWLJAgLDgJHJqlvaLkSC 47Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sxd6XPXbqjGlwm0Uq3+TuwmU7RWEszKQgcwb1zdvGBc=; b=lymzdE00OaBTU1KSoa+fy+6/QrweYVIvfKm/bbpOz3u9pkoxsR59YX5NRJ+O0+XvSO v7W2Zxd3cvbhQR3yPMiZ2WEpg6MPIon3bZxXF9BunmyStYPG2zisolymytCcqilgPVWx H7mFfov9f4co1NfGQP64mI6w39pyq7fiQt0f9/0jO+mOc6Vj9d8Tasv8yqFkrrzxBSIK Ctx+iVcThskYNtzMA+erFguqG7631jW8jG/iPPzcSpMuLZl/fZaX5VZgBZgFZmbdhEUR fHanU84awjuIi2ki46PV24jVXl5roeN765xm1Ihxr1jv95DdBiI45GT9SnMVG577v6Oz qEaA== X-Gm-Message-State: ACrzQf2b+q0KDDP8gMeXw98N3ggko0/zFi3+VlXDPjRuIGvFPyGKyInL 3NmTKqcGyKWENbEWIjTrjfE= X-Google-Smtp-Source: AMsMyM7ABmhAeWZDsODZAyPPxF3l8R+basxNnWeYQDzgRkVuHG+ol2xWhgPNyQlJH6l24fTSQb+HYA== X-Received: by 2002:a1c:4c16:0:b0:3cf:6f1a:9038 with SMTP id z22-20020a1c4c16000000b003cf6f1a9038mr9944265wmf.151.1667345760751; Tue, 01 Nov 2022 16:36:00 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id q5-20020a5d6585000000b00228cd9f6349sm11272805wru.106.2022.11.01.16.35.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 16:36:00 -0700 (PDT) Message-ID: <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> Date: Wed, 2 Nov 2022 01:35:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Content-Language: en-US To: Sean Devlin References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> From: Dmitry Gutov In-Reply-To: <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 58784 Cc: 58784@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: -2.3 (--) Hi Sean, On 31.10.2022 19:47, Sean Devlin wrote: >>> In the last form, project-buffers includes the current buffer (i.e. the >>> scratch buffer in our example) with the results. (This is true even if >>> the current buffer is visiting a file in some unrelated directory.) >>> This matters because the command project-switch-project let-binds >>> default-directory before calling project-switch-commands. This means >>> that if you set project-switch-commands to some function that calls >>> project-buffers, you will get incorrect results. >>> For example, evaluate the following forms in order: >>> (defun my-list-project-buffers () >>> "List the current project's buffers." >>> (interactive) >>> (let ((buffer-list (project-buffers (project-current t))) >>> (buffer-name (project-prefixed-buffer-name "my-project-buffer-list"))) >>> (with-current-buffer (get-buffer-create buffer-name) >>> (erase-buffer) >>> (save-excursion >>> (dolist (buffer buffer-list) >>> (insert (buffer-name buffer)) >>> (insert ?\n)))) >>> (switch-to-buffer buffer-name))) >>> (setq project-switch-commands #'my-list-project-buffers) >> >> Looks like a reimplementation of projectile-ibuffer, seems useful. > > Yeah, in my real configuration, I defined this as an ibuffer filter, but I thought a simpler example would be better for the bug report. Right, thanks. >>> ;; list tmpfile but also scratch >>> (project-switch-project "/tmp/") >> >> Not sure how to fix this, though. In bug#53626 we discussed a somewhat similar problem, and a let-binding seems impossible to "escape". >> >> What else can we do? One option is to change the signature of every compatible command to take the project object as its first argument. Might have been more realistic when the package was first written, too much breakage now, probably. >> >> Another would be to add a new var to help override the project choice without touch default-directory. >> >> Something like the attached. Please try it out. > > I agree, the fix is not obvious. > > A workaround I used in my configuration is to add an advice to project-switch-project to wrap it in a with-temp-buffer form. This way, it’s only the default-directory of the temp buffer that gets corrupted. Not a very clean solution, but it seems to work. Unfortunately, you need to remember to do this in many places; for example, I had to do the same thing in my project-ibuffer command. > > Your solution looks cleaner. I gave it a try (along with disabling my advice), and it seems to work pretty well. Thanks for the fix! Actually I like your solution better. It might be less obvious when reading, but it's shorter and fully backward compatible. So I just pushed that fix to master. > There might be some more places where it needs to be applied. For example, project-prefixed-buffer-name still inspects the default-directory. (Maybe project-prefixed-buffer-name should just call project-root or similar?) In both places where project-prefixed-buffer-name is currently invoked, default-directory is set a specific binding just before that. So I think it would have been fine even with the other fix. Or on a higher level, it acts on the current buffer, so referencing default-directory seems okay. > I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual. I suppose it could use improvement, but I'm not sure what phrasing would stop someone from making such a mistake. After all, I knew its implementation and made it anyway. Perhaps the docstring should simply say that the buffers are matched on the basis of their default-directory value. In the default implementation, that is (custom backends could choose their own strategy). Would that help? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 02 11:19:08 2022 Received: (at 58784) by debbugs.gnu.org; 2 Nov 2022 15:19:08 +0000 Received: from localhost ([127.0.0.1]:46985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqFWG-0007fF-Db for submit@debbugs.gnu.org; Wed, 02 Nov 2022 11:19:08 -0400 Received: from mail-qk1-f172.google.com ([209.85.222.172]:34482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqFWE-0007el-Fw for 58784@debbugs.gnu.org; Wed, 02 Nov 2022 11:19:07 -0400 Received: by mail-qk1-f172.google.com with SMTP id 8so11927850qka.1 for <58784@debbugs.gnu.org>; Wed, 02 Nov 2022 08:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toadstyle-org.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0BNBbS6vEzwBHC7nM7TgexaHUCSBemxzgxwqikTSfRs=; b=Rg0gVvPYWQI/btpNuNt+S5UPSDoLJgNv8yhuw06i3gsdVh/P2DT9udU6p9yvl5915s q9PNffKhvou6r7KRs9K+yIJAGEriawPPhJhO/+/BnvTabylox7fDY+FCZnZBebwcb4sA lnXbucuyK0c1HPZhmuKwCR1wfSSMY2UEjjyDOPn1z0/HMLeX1fa4cwLcIaa+ZCGfMTI6 tegw4oY4Ylj09rgdLwnXCOSE5feYbjc5rVrtRqTKp/PNomtHp5sooKUzMgePzun+gwVa r/iAI49rc2ffR3BHw8qbfKDDODQNFgk4F1ZlXnkgJJjsmWszp5eBEuMeXlN6vK7+yB53 i/0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0BNBbS6vEzwBHC7nM7TgexaHUCSBemxzgxwqikTSfRs=; b=Rt/9pw1f0JlvkR+4dmXX0/Z2G3C/cBUGyLC94MLKW+M+gtMFGoLS697Qj+ORck5CEb 0WW9eaWCcn1Uxct7tn7DDdDNBPTcerKENxGWF7+0yQEh5GFP81+F0R/mf92yZuA7iNkP +OV0SOpxOkMFDYCD96Y0EMi92NJWpAo87/yn6uTG0DisVcDo7WGTtPYfJPhjX1jWnzpP DhDtC3bRNlnFcaLLoFKJAY0GAidkMbCUIVvd6gsLQaiwRKxbs8q8p7Q7STsqaoKdcbe/ LppVrkP9XJacJM78ZZye0pkYM1VQdtGm6zbvDa51zDDSpZFoSxkBiUF0j6pmUl663tW9 R+Ww== X-Gm-Message-State: ACrzQf17qvkpOuKaL+uSVt39megtHmG9U9NCBq4uBFta3uGxZLkSCphX j3RwoQV2143uEfM+WYLzQHlhzQ== X-Google-Smtp-Source: AMsMyM598mfbMUEowl5pBgH48coJ7FSTbUFbzIHIWAuIOFzQ5A12MPqqsOKESLlte6jkjpLvYmXdng== X-Received: by 2002:a05:620a:1a99:b0:6ee:c795:46a6 with SMTP id bl25-20020a05620a1a9900b006eec79546a6mr17774939qkb.286.1667402340863; Wed, 02 Nov 2022 08:19:00 -0700 (PDT) Received: from smtpclient.apple (pool-173-56-106-162.nycmny.ftas.verizon.net. [173.56.106.162]) by smtp.gmail.com with ESMTPSA id az42-20020a05620a172a00b006bb87c4833asm8669277qkb.109.2022.11.02.08.19.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2022 08:19:00 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.51\)) Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory From: Sean Devlin In-Reply-To: <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> Date: Wed, 2 Nov 2022 11:18:49 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <35907670-3546-45B8-8E3C-2C482B8E3464@toadstyle.org> References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> To: Dmitry Gutov X-Mailer: Apple Mail (2.3731.300.51) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 58784 Cc: 58784@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 (-) Hi Dmitry, > On Nov 1, 2022, at 7:35 PM, Dmitry Gutov wrote: >=20 > Hi Sean, >=20 > On 31.10.2022 19:47, Sean Devlin wrote: >=20 >>>> In the last form, project-buffers includes the current buffer (i.e. = the >>>> scratch buffer in our example) with the results. (This is true even = if >>>> the current buffer is visiting a file in some unrelated directory.) >>>> This matters because the command project-switch-project let-binds >>>> default-directory before calling project-switch-commands. This = means >>>> that if you set project-switch-commands to some function that calls >>>> project-buffers, you will get incorrect results. >>>> For example, evaluate the following forms in order: >>>> (defun my-list-project-buffers () >>>> "List the current project's buffers." >>>> (interactive) >>>> (let ((buffer-list (project-buffers (project-current t))) >>>> (buffer-name (project-prefixed-buffer-name = "my-project-buffer-list"))) >>>> (with-current-buffer (get-buffer-create buffer-name) >>>> (erase-buffer) >>>> (save-excursion >>>> (dolist (buffer buffer-list) >>>> (insert (buffer-name buffer)) >>>> (insert ?\n)))) >>>> (switch-to-buffer buffer-name))) >>>> (setq project-switch-commands #'my-list-project-buffers) >>>=20 >>> Looks like a reimplementation of projectile-ibuffer, seems useful. >> Yeah, in my real configuration, I defined this as an ibuffer filter, = but I thought a simpler example would be better for the bug report. >=20 > Right, thanks. >=20 >>>> ;; list tmpfile but also scratch >>>> (project-switch-project "/tmp/") >>>=20 >>> Not sure how to fix this, though. In bug#53626 we discussed a = somewhat similar problem, and a let-binding seems impossible to = "escape". >>>=20 >>> What else can we do? One option is to change the signature of every = compatible command to take the project object as its first argument. = Might have been more realistic when the package was first written, too = much breakage now, probably. >>>=20 >>> Another would be to add a new var to help override the project = choice without touch default-directory. >>>=20 >>> Something like the attached. Please try it = out. >> I agree, the fix is not obvious. >> A workaround I used in my configuration is to add an advice to = project-switch-project to wrap it in a with-temp-buffer form. This way, = it=E2=80=99s only the default-directory of the temp buffer that gets = corrupted. Not a very clean solution, but it seems to work. = Unfortunately, you need to remember to do this in many places; for = example, I had to do the same thing in my project-ibuffer command. >> Your solution looks cleaner. I gave it a try (along with disabling my = advice), and it seems to work pretty well. Thanks for the fix! >=20 > Actually I like your solution better. It might be less obvious when = reading, but it's shorter and fully backward compatible. >=20 > So I just pushed that fix to master. Great, thanks! >=20 >> There might be some more places where it needs to be applied. For = example, project-prefixed-buffer-name still inspects the = default-directory. (Maybe project-prefixed-buffer-name should just call = project-root or similar?) >=20 > In both places where project-prefixed-buffer-name is currently = invoked, default-directory is set a specific binding just before that. = So I think it would have been fine even with the other fix. >=20 > Or on a higher level, it acts on the current buffer, so referencing = default-directory seems okay. Sounds good. >=20 >> I think there=E2=80=99s still some fragility in the project-buffers = function, since any callers need to be careful not to bind = default-directory. It might be useful to call this out in the doc string = or in the manual. >=20 > I suppose it could use improvement, but I'm not sure what phrasing = would stop someone from making such a mistake. After all, I knew its = implementation and made it anyway. >=20 > Perhaps the docstring should simply say that the buffers are matched = on the basis of their default-directory value. In the default = implementation, that is (custom backends could choose their own = strategy). Would that help? Yeah, I think a high-level description of the default strategy would be = useful. Thanks again for your help! From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 03 21:18:52 2022 Received: (at 58784-done) by debbugs.gnu.org; 4 Nov 2022 01:18:52 +0000 Received: from localhost ([127.0.0.1]:51069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlMB-0005aK-Vy for submit@debbugs.gnu.org; Thu, 03 Nov 2022 21:18:52 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]:43565) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlM8-0005a5-GF for 58784-done@debbugs.gnu.org; Thu, 03 Nov 2022 21:18:50 -0400 Received: by mail-wr1-f46.google.com with SMTP id g12so5059543wrs.10 for <58784-done@debbugs.gnu.org>; Thu, 03 Nov 2022 18:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=uXZl74W8rzLeBghfR0Lpqe+wPkEKCq2G376YLGCoNjk=; b=ZoSfKFZ2GbmNtE7660qIzFIphlBcIcu4+Xbdl2hZOa9TRmx+XZxlxyvjjOxvV8RRZ2 MEAcrqy8JG1zMW5O+NuNb207/Qzr91Qwor33hM/pqdKkR6JF3YsHKp3QjxbDuwk0/NgD skJ7AG5TLlrR2nvLbfxN9nRzCpaYmFRqtyDDEs5azQU8TqoWZEbRo+0PfQZBfwIlkAhm +PWC0DsfphbDOfKdeSmz8s0kYKm7fCgO4SwJ8YoNMheF0LE+02WEyTsECd0HWOqCjJWG XKnspr3YsyXNaNGOAWOgpWu+HE9i7ylOgNMP03ZFvolqVem48OA+tLFRhpigv9HlPMqg QboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uXZl74W8rzLeBghfR0Lpqe+wPkEKCq2G376YLGCoNjk=; b=PEpbhSlYsdBIXaUvso2pOam3CiJrkYdMqSkP6mlZGxLbUuMJMBxreFpVeB9Nzhqogh XFgtutTmkwKTL3Tl960peSgTtuTA9b5kTW6HHx2L7i4jGNDqZYo3W+r9PRFMi0tcaFCg Wvpeyltj0Qm9qZ+hnMvF8o1e8TTwZmX4RlIBW0Xjhzz13Ie9yAxt3Qs2iT5s2rLjqkAy oagrRssaBWYJbjWwSB/PKI7fXROKbc7+QjJWGlZH9RENrn8pbDnaebZQV5xrQrKGTls4 AG134HMho4+VXOMBVOka98ms8A4jIlOpuo5Ls3huqauIpczjnn/ZuRwggFqWJvVzc5Wm Zx8w== X-Gm-Message-State: ACrzQf3m7xbLR4rlLsA8AWpCRZM6nHNyae4ixLEVIv9aUo4RBfkVV1Ak 6vMJuiFF5y2AjQlnVoWTz+w= X-Google-Smtp-Source: AMsMyM65fWchlO5vyFM/oZldhNIAF0GcUfrTJIIXKyR3nc06Bc2LXr4ksfZWWJD7weEexOCXhOOQuA== X-Received: by 2002:a05:6000:245:b0:236:a471:81c3 with SMTP id m5-20020a056000024500b00236a47181c3mr162496wrz.392.1667524722741; Thu, 03 Nov 2022 18:18:42 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id p25-20020a05600c1d9900b003cf77e6091bsm1349949wms.11.2022.11.03.18.18.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 18:18:42 -0700 (PDT) Message-ID: <873fe4fa-4139-671b-0990-18833a6947a5@yandex.ru> Date: Fri, 4 Nov 2022 03:18:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Content-Language: en-US To: Sean Devlin References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> <35907670-3546-45B8-8E3C-2C482B8E3464@toadstyle.org> From: Dmitry Gutov In-Reply-To: <35907670-3546-45B8-8E3C-2C482B8E3464@toadstyle.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 58784-done Cc: 58784-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: -2.3 (--) On 02.11.2022 17:18, Sean Devlin wrote: >>> I think there’s still some fragility in the project-buffers function, since any callers need to be careful not to bind default-directory. It might be useful to call this out in the doc string or in the manual. >> >> I suppose it could use improvement, but I'm not sure what phrasing would stop someone from making such a mistake. After all, I knew its implementation and made it anyway. >> >> Perhaps the docstring should simply say that the buffers are matched on the basis of their default-directory value. In the default implementation, that is (custom backends could choose their own strategy). Would that help? > > Yeah, I think a high-level description of the default strategy would be useful. > > Thanks again for your help! I've added some clarification in 7d47651d01. Hopefully it makes things better, if not -- suggestions welcome. I'm going to close this in the meantime. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 12:39:37 2022 Received: (at 58784-done) by debbugs.gnu.org; 4 Nov 2022 16:39:37 +0000 Received: from localhost ([127.0.0.1]:54679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqzjE-0003vT-NH for submit@debbugs.gnu.org; Fri, 04 Nov 2022 12:39:36 -0400 Received: from mail-qt1-f177.google.com ([209.85.160.177]:35535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqzjC-0003vC-OC for 58784-done@debbugs.gnu.org; Fri, 04 Nov 2022 12:39:35 -0400 Received: by mail-qt1-f177.google.com with SMTP id h21so3364806qtu.2 for <58784-done@debbugs.gnu.org>; Fri, 04 Nov 2022 09:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toadstyle-org.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UfsXQ74qDGq+CdzWSL9lHfFAIWKKc5lOli/0XlknS7I=; b=s7GQ8AwqbekXKmM/HrlzQgIdV3XFs0xD3o4oet39sCPJyUBslxRPzMJiU4jnxU67Ap zh9SImsmOYyc3pB/9+cpbXXS70DxqApnZE6R2Xb1zSR9EQNBv0LZ6Iz2KJTf2qvGDIZN 9IYAHzoUenEf9toPf+Y7B9QFTLg1HtDw74zRC725UHCImgmWMFmJlXuaHbkQ7Cj2vRmU l5Ju34ef9zn/zqjx8H2S2K1UYskqK1/iz+0Nku/mngkG91GyAM1eNb1Ob5Qy/gOVy5cI 2s4APGB0VMAcx7Sn+JY7BkjqOYwcpl7fDptSdAH81KE/EA7yBjF1p0pRDvPkrFMkKMJ1 Nufw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UfsXQ74qDGq+CdzWSL9lHfFAIWKKc5lOli/0XlknS7I=; b=HUe+lSN0K3l6BL/Djm0Yyo0sVui2Ginnu86h4SdrQrCbZ3bo948pwAvqhwNwaWfa8A APANuwmYVHzoubuRqlCQ/tUyroBKzOMIw4KG9HMIHuDx3zw1HIUNZQVYMyIvz101FSUW otwOSQcyLhpVMPSRrZgNPFV7Sw+uAtT7Dp/0T0nqqT0oFFx+6ISjaZ3uMHWJYYCWE9Lq +CmGDMF3AtMNxmlQUi5cFwqBdjZLUI8uckXkYShGqpZf/b8hD5QL3BISjnZxRDWT7onI bKwr7YNlqChle5nXFjKo/nGovho+5dCurfgYPUPX1DQMMHirhYBAQ9HwDEfhgRsq1bo1 QT7g== X-Gm-Message-State: ACrzQf3pEmDrBJSX41SggwITzjYlZpu9WrXZZOCvTMH9+0nPKFaptkWP 9Ni6UVaILnINP25unCRezgPxhTVB/Q/q+EZJ X-Google-Smtp-Source: AMsMyM5Vc5OSbjYuJEoJdQWtQKz8Szapco8ayAoSm87NHtCLTMDLsyMfxYXfJjqs2fSPy2As3ruQ2w== X-Received: by 2002:a05:622a:59c6:b0:3a5:3bfc:3faa with SMTP id gc6-20020a05622a59c600b003a53bfc3faamr17128539qtb.184.1667579969210; Fri, 04 Nov 2022 09:39:29 -0700 (PDT) Received: from smtpclient.apple (pool-173-56-106-162.nycmny.ftas.verizon.net. [173.56.106.162]) by smtp.gmail.com with ESMTPSA id s9-20020a05620a29c900b006cec8001bf4sm3232440qkp.26.2022.11.04.09.39.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Nov 2022 09:39:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.51\)) Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory From: Sean Devlin In-Reply-To: <873fe4fa-4139-671b-0990-18833a6947a5@yandex.ru> Date: Fri, 4 Nov 2022 12:39:18 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> <35907670-3546-45B8-8E3C-2C482B8E3464@toadstyle.org> <873fe4fa-4139-671b-0990-18833a6947a5@yandex.ru> To: Dmitry Gutov X-Mailer: Apple Mail (2.3731.300.51) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58784-done Cc: 58784-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: -1.0 (-) Hi Dmitry, > On Nov 3, 2022, at 9:18 PM, Dmitry Gutov wrote: >=20 > On 02.11.2022 17:18, Sean Devlin wrote: >=20 >>>> I think there=E2=80=99s still some fragility in the project-buffers = function, since any callers need to be careful not to bind = default-directory. It might be useful to call this out in the doc string = or in the manual. >>>=20 >>> I suppose it could use improvement, but I'm not sure what phrasing = would stop someone from making such a mistake. After all, I knew its = implementation and made it anyway. >>>=20 >>> Perhaps the docstring should simply say that the buffers are matched = on the basis of their default-directory value. In the default = implementation, that is (custom backends could choose their own = strategy). Would that help? >> Yeah, I think a high-level description of the default strategy would = be useful. >> Thanks again for your help! >=20 > I've added some clarification in 7d47651d01. >=20 > Hopefully it makes things better, if not -- suggestions welcome. >=20 > I'm going to close this in the meantime. Thanks, and I saw the corresponding discussion on emacs-devel. Any = version of the proposed changes looks good to me. Feel free to close, = and thanks again for your help!= From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 21 13:25:06 2022 Received: (at 58784) by debbugs.gnu.org; 21 Nov 2022 18:25:06 +0000 Received: from localhost ([127.0.0.1]:48798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxBTe-0008IP-BY for submit@debbugs.gnu.org; Mon, 21 Nov 2022 13:25:06 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:49075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxBTc-0008Hn-1a for 58784@debbugs.gnu.org; Mon, 21 Nov 2022 13:25:04 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 203F2C0006; Mon, 21 Nov 2022 18:24:54 +0000 (UTC) From: Juri Linkov To: Dmitry Gutov Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory In-Reply-To: <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> (Dmitry Gutov's message of "Wed, 2 Nov 2022 01:35:58 +0200") Organization: LINKOV.NET References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> Date: Mon, 21 Nov 2022 20:24:31 +0200 Message-ID: <86wn7ojqm8.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 58784 Cc: Sean Devlin , 58784@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 (-) > So I just pushed that fix to master. Unfortunately, this change broke 'C-x p p g': @@ -1667,9 +1667,10 @@ project-switch-project - (let ((default-directory dir) - (project-current-inhibit-prompt t)) - (call-interactively command)))) + (with-temp-buffer + (let ((default-directory dir) + (project-current-inhibit-prompt t)) + (call-interactively command))))) Because 'C-x p p' switches to a temporary buffer, then 'g' calls 'project-find-regexp' and 'project--read-regexp'. But (thing-at-point 'symbol t) can't get a symbol at point in the empty temporary buffer. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 22:48:20 2022 Received: (at 58784) by debbugs.gnu.org; 23 Nov 2022 03:48:20 +0000 Received: from localhost ([127.0.0.1]:53133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxgkG-0000N0-EM for submit@debbugs.gnu.org; Tue, 22 Nov 2022 22:48:20 -0500 Received: from mail-wr1-f44.google.com ([209.85.221.44]:43532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxgkB-0000Mf-Jg for 58784@debbugs.gnu.org; Tue, 22 Nov 2022 22:48:19 -0500 Received: by mail-wr1-f44.google.com with SMTP id g12so27570973wrs.10 for <58784@debbugs.gnu.org>; Tue, 22 Nov 2022 19:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=lccdK50biP6rmBeow+rVwBl+Gp+GrlZ0nWSNE7pyDqk=; b=UwA8JSwZyX4sIr4J/59GwR4b0CauIKCpJUvPeelfDbqT8a9V/7aNJsgS52foXCyV3Z NBNOY+tvyQ8ZdAK14EPoVpuhQKjHFqQEnt5Bx7f09OwKbG1DjpMGwmeNuBubkzp+ebCo Bq93IqUlz15pT0L8WwnyDXQs1tk/lZRoJiiqDmYyhLbSn4o0PXbrvVztSNsf+SxP3Yl+ OnewXkn7SngQvVytQqUQmxCp5AwkfaC+1Ota3pEWI3e5rXGdnjRVm6wkLHeBs5stkhBH ioquFSGUEvBS2j8X1JZPhdGuT5MHd0u69dFwmk90EMIfx55jqQRDZF223TEEmhMCEzP1 1FVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lccdK50biP6rmBeow+rVwBl+Gp+GrlZ0nWSNE7pyDqk=; b=LoW8LQRKjVaCQ1cu52WBiEv+yvos2YwA9Ya0DPVpSfWFUFBCrhNFy2dPpUxqRVfB6q +ZRMXXop93DmJMFpoPMBp6gAqphhV2p9nR69lWoDnIHebnkvP0MGvGEsONfEhrpXIPku 1m76N7b2cEUsN/OHagwf5Jo28V13r4ZTdkVesobOrdD3iLH9eAli7E7Fvdn/di7Feip6 kau1LuN3+AZmaKd81YUjropyjSRzMR8d4Yv2delUNmEA/5ZZPhUuQDuKLDHd8k5IGFpK gdEr0DNbidHHCasNcS8BzixLSftFefTeGoYELsnk423vrC114y5r9TPcenaTaEf3GtmO J6mw== X-Gm-Message-State: ANoB5pnXDEoXR5qdIULICVvn65Iitt4DBazKMPsiSuTFCQ4EaSXCpY89 R3Hs5SVCvurPCpho+ZpO6Ik= X-Google-Smtp-Source: AA0mqf6gns0GbsQWxv00pAGX2WmNcQJoXdeI7HIO8CmuHkaKIRWytShNzp3Vu8BiROCZeIEXFv7IOA== X-Received: by 2002:adf:ea0b:0:b0:236:695b:6275 with SMTP id q11-20020adfea0b000000b00236695b6275mr16355737wrm.116.1669175289297; Tue, 22 Nov 2022 19:48:09 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id f13-20020a05600c4e8d00b003c6c182bef9sm816624wmq.36.2022.11.22.19.48.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 19:48:08 -0800 (PST) Message-ID: <4d9dbe41-af65-ecde-1f92-d90d8f981d79@yandex.ru> Date: Wed, 23 Nov 2022 05:48:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Content-Language: en-US To: Juri Linkov References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> <86wn7ojqm8.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86wn7ojqm8.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 58784 Cc: Sean Devlin , 58784@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.8 (/) On 21/11/22 20:24, Juri Linkov wrote: >> So I just pushed that fix to master. > Unfortunately, this change broke 'C-x p p g': > > @@ -1667,9 +1667,10 @@ project-switch-project > - (let ((default-directory dir) > - (project-current-inhibit-prompt t)) > - (call-interactively command)))) > + (with-temp-buffer > + (let ((default-directory dir) > + (project-current-inhibit-prompt t)) > + (call-interactively command))))) > > Because 'C-x p p' switches to a temporary buffer, then > 'g' calls 'project-find-regexp' and 'project--read-regexp'. > But (thing-at-point 'symbol t) can't get a symbol at point > in the empty temporary buffer. Damn it. :-) Thanks for noticing. I'll need a little time to think about the options, but we'll probably go with the previous proposed fix. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 21:37:44 2022 Received: (at 58784) by debbugs.gnu.org; 24 Nov 2022 02:37:44 +0000 Received: from localhost ([127.0.0.1]:56743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oy27U-00020V-94 for submit@debbugs.gnu.org; Wed, 23 Nov 2022 21:37:44 -0500 Received: from mail-wr1-f47.google.com ([209.85.221.47]:34446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oy27P-00020F-RF for 58784@debbugs.gnu.org; Wed, 23 Nov 2022 21:37:42 -0500 Received: by mail-wr1-f47.google.com with SMTP id s5so539086wru.1 for <58784@debbugs.gnu.org>; Wed, 23 Nov 2022 18:37:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=y0G5L4dTgkunTI0DWQEiKtribTPrq2snwH0mlq8Jezk=; b=q7DC87teFAvccm+ERpykU32EeuztQB1BxUCJLnMQuBuhR+EMCaa8dh7fj7sT4o1QnI LJ4jdTjFsgy0OCiEzUunyRXf7NbYtEvu2iI/132flgpVJJdam9/nDjr0nW34lLUYJDHn MeqUSl8I9eX0dQ9dBnxytUvIxLZKSoUuFmibsYiWFOARUIYXFuQIw0x7piR9yz4yPubn mSEZU/dCv5jkiUCUxoj96Xa9S4sFDOqzGdp0LJuRQhz32iC1Fyze0Gvm4F+QrweqFEOQ UpDPtqqzIFElGLpbFRj3p42zwYdQ51qjRMF+2Qp1s+40BCThDGeqyFL0O8AZ0CsT1ELR Aw8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y0G5L4dTgkunTI0DWQEiKtribTPrq2snwH0mlq8Jezk=; b=31Kn3iFStlbHpeKo04uce9w65QPhZXAe1NinH+r6OqN+8jCrsOzkWPDN/3zHOVYzUi hTiHWwMg9ai2+vnf9tlsDNrV6a8uHX0qxnsADBk5WDKilYbjDJMcgwwtxtt0kVZnymF1 9rtIiFCjmn94nzti3TGAR6UwsIY04/H1m6081LjEg/cwOaFzbRDCAaLe8DTKX1nzmrz5 Tp5SbAyHPXYgMligD9MrjcKxDlatqv2quiGc697FLqO4S/DkgrIPgTrTJXRJZDvW3GGD IMV8xYFsUSkZTIvGZhPtzR8Sa7oP4+9QJJxtZSxhmvYtAs3ItdpJOMVNL2JciKEftxlb lu4w== X-Gm-Message-State: ANoB5pkLR3vAa1mLu04RxOIQFWqWUBOGcNVTB4N+dCYMbHdfUGA+M1nw 0lvuUc5fYypKf0VarOLieGU= X-Google-Smtp-Source: AA0mqf6Xm17r13TRJg1srEaLyi5nPhfVCW+YMvWPZca7s6yB5WehLVzKlfZyIYJy83IJt5Wf0Za83A== X-Received: by 2002:a5d:544f:0:b0:241:d7b1:470f with SMTP id w15-20020a5d544f000000b00241d7b1470fmr8585216wrv.500.1669257453759; Wed, 23 Nov 2022 18:37:33 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id o5-20020a05600c510500b003b4ff30e566sm8913389wms.3.2022.11.23.18.37.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Nov 2022 18:37:33 -0800 (PST) Message-ID: <6d267562-a7fd-32d1-d179-c380d8f9c38c@yandex.ru> Date: Thu, 24 Nov 2022 04:37:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Content-Language: en-US From: Dmitry Gutov To: Juri Linkov References: <0b56cc0a-b8d4-86dc-4b67-217387aeb1b2@yandex.ru> <938BB7EA-3902-4025-98B5-914D514B4A63@toadstyle.org> <208cd0a0-8244-9cac-ff16-9ef23b56ca9b@yandex.ru> <86wn7ojqm8.fsf@mail.linkov.net> <4d9dbe41-af65-ecde-1f92-d90d8f981d79@yandex.ru> In-Reply-To: <4d9dbe41-af65-ecde-1f92-d90d8f981d79@yandex.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 58784 Cc: Sean Devlin , 58784@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.8 (/) On 23/11/22 05:48, Dmitry Gutov wrote: > we'll probably go with the previous proposed fix And now done, master b37604c263. From unknown Wed Jun 18 00:24:44 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 22 Dec 2022 12:24:12 +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