From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andrii Kolomoiets Newsgroups: gmane.emacs.bugs Subject: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in project.el Date: Thu, 18 Jun 2020 21:03:13 +0300 Message-ID: References: <87bllk2pfc.fsf@thornhill.no> <87wo44mzrb.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="47048"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: 41879@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 18 20:04:15 2020 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 1jlytb-000CCU-2R for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 20:04:15 +0200 Original-Received: from localhost ([::1]:39196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlytZ-0003yB-RW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jun 2020 14:04:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlytO-0003q9-2d for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlytN-000440-Od for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:04:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jlytN-0006jj-L8 for bug-gnu-emacs@gnu.org; Thu, 18 Jun 2020 14:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrii Kolomoiets Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jun 2020 18:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41879 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41879-submit@debbugs.gnu.org id=B41879.159250340625851 (code B ref 41879); Thu, 18 Jun 2020 18:04:01 +0000 Original-Received: (at 41879) by debbugs.gnu.org; 18 Jun 2020 18:03:26 +0000 Original-Received: from localhost ([127.0.0.1]:54361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlysn-0006it-Vy for submit@debbugs.gnu.org; Thu, 18 Jun 2020 14:03:26 -0400 Original-Received: from mail-lf1-f68.google.com ([209.85.167.68]:38722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlysk-0006ie-Je for 41879@debbugs.gnu.org; Thu, 18 Jun 2020 14:03:24 -0400 Original-Received: by mail-lf1-f68.google.com with SMTP id d27so4020146lfq.5 for <41879@debbugs.gnu.org>; Thu, 18 Jun 2020 11:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Ge5zUtB3lwm/U4GqiIJx1nmjlj7p1tZnyds+Ulf6+To=; b=EzXNsWa9AoaozF4DYcb9+s1d5Ut2l0jz4f/fCvxaFylQoV8cLZUvM4oG0e0zcPdGIO bMAcAlWnfG+HLvBKpFCDZyar6xAWBlrXPIv38+EtO/RikKN7Chh2buqzAmOIFKRc3RZd TrWzpbqdj0m3qxQHyNQzi3eFpT80pXd9kv7ff7vw4pE1TUY9ZRzi1+/7XdpSLRhJeic7 N9VCIyNU65sO8bYscBx/N51ce8UACToEmhiqMvddcTUlHt+LDgZn9Gjm0vwh2ZiYGazF zilEqsY6AdbzT8v/C5FEs1WDkg6EF38SpvLzNtG7VigzI9xIjn+M534vvRqHEprIfLYv IZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=Ge5zUtB3lwm/U4GqiIJx1nmjlj7p1tZnyds+Ulf6+To=; b=LRWtGeKus+F/sMC7rZXfE2LUJGUCYV/AEnu1IPDwATmAZk1Emc0GWV9KgjAOrZyvz/ D3P8JI1BE0Hw248OP+2QxcAtPtyzFv9/oK72Zlsj1xunNoUQreaTQn8KyF6SdR9OEDKs SYIcZz74+M85xu0gAXILEP2h79ITPDak14682E8+Mx9nxUr4KI6ho+WPFCwBznQn9VBS JEbfVW/T+A0WPQeNkOmpTOhST/lZqXmEorKonYIRoQXVvxtNSQ1eA0Kt10er9NPDLoE8 uEGiJFNT0JWgpsc4KfIOy7cogGfCPUVccFOIbTHCSwcC2oU5OSlZpACmXWCOpDSmDX8j 8aIg== X-Gm-Message-State: AOAM530hp/cccZh2tzvWAwMG7PpRAECfgIJe5pZGhnEjuExbl+YiwMbM 5irpAAVGs8Flx1nDx6lEPNhKqm9x X-Google-Smtp-Source: ABdhPJy85J6SUBjYARODHAFQia2OQJwv/7XFnxFGNAWcs2QMiYMUP9M0Bk2pjHyd5VuLvV0Vmwz5oQ== X-Received: by 2002:ac2:5c09:: with SMTP id r9mr3028354lfp.176.1592503395980; Thu, 18 Jun 2020 11:03:15 -0700 (PDT) Original-Received: from muffinmac.local ([91.206.110.148]) by smtp.gmail.com with ESMTPSA id x30sm534330lfn.3.2020.06.18.11.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 11:03:14 -0700 (PDT) In-Reply-To: (Andrii Kolomoiets's message of "Thu, 18 Jun 2020 13:48:12 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182133 Archived-At: --=-=-= Content-Type: text/plain Hi Theodor, Please take a look at the attached patch. It's based on your patch and resolves this: > - Check if other-buffer is passes the predicate function. The buffer > from another project must not be the default. > - Exclude the current buffer from the buffers list to switch to. Thanks! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=project-switch-to-buffer.patch diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 7a41df614b..b8d5731a71 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -777,14 +777,23 @@ project-compile (defun project-switch-to-buffer () "Switch to a buffer in the current project." (interactive) - (let ((root (project-root (project-current t)))) + (let* ((root (project-root (project-current t))) + (current-buffer (current-buffer)) + (other-buffer (other-buffer current-buffer)) + (other-name (buffer-name other-buffer)) + (predicate + (lambda (buffer) + ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist. + (and (not (eq (cdr buffer) current-buffer)) + (when-let ((file (buffer-local-value 'default-directory (cdr buffer)))) + (file-in-directory-p file root)))))) (switch-to-buffer (read-buffer - "Switch to buffer: " nil t - (lambda (buffer) - ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist. - (when-let ((file (buffer-file-name (cdr buffer)))) - (file-in-directory-p file root))))))) + "Switch to buffer: " + (when (funcall predicate (cons other-name other-buffer)) + other-name) + t + predicate)))) (defcustom project-kill-buffers-skip-conditions '("\\*Help\\*") --=-=-=--