From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Devlin Newsgroups: gmane.emacs.bugs Subject: bug#58784: 28.2; project-buffers incorrect under let-bound default-directory Date: Tue, 25 Oct 2022 20:13:36 -0400 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.51\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10335"; mail-complaints-to="usenet@ciao.gmane.io" To: 58784@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 26 02:17:13 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1onU6a-0002Q1-Mk for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 26 Oct 2022 02:17:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onU3X-0000Qx-UW; Tue, 25 Oct 2022 20:14:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onU3W-0000PZ-Ol for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onU3W-0006PX-AS for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1onU3V-0002m4-P8 for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Devlin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Oct 2022 00:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58784 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166674323610644 (code B ref -1); Wed, 26 Oct 2022 00:14:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Oct 2022 00:13:56 +0000 Original-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 Original-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 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onU3N-0000BW-Sr for bug-gnu-emacs@gnu.org; Tue, 25 Oct 2022 20:13:53 -0400 Original-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 Original-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) Original-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) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246181 Archived-At: 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))