From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores) Date: Mon, 20 Jul 2020 02:10:53 +0300 Message-ID: <89ff9cf6-e85b-4c36-4fb7-763c41e41b02@yandex.ru> References: <878sfjkh8o.fsf@warpmail.net> <87mu3xdm50.fsf@warpmail.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21961"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 42386@debbugs.gnu.org To: "Philip K." Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 20 01:12:11 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 1jxITa-0005bV-SK for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Jul 2020 01:12:10 +0200 Original-Received: from localhost ([::1]:38180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jxITZ-0001bE-Cg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Jul 2020 19:12:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jxITS-0001as-IG for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 19:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49916) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jxITS-0007jI-8T for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 19:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jxITS-0004Fw-3Y for bug-gnu-emacs@gnu.org; Sun, 19 Jul 2020 19:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Jul 2020 23:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42386-submit@debbugs.gnu.org id=B42386.159520026316285 (code B ref 42386); Sun, 19 Jul 2020 23:12:02 +0000 Original-Received: (at 42386) by debbugs.gnu.org; 19 Jul 2020 23:11:03 +0000 Original-Received: from localhost ([127.0.0.1]:33226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jxISU-0004Eb-T4 for submit@debbugs.gnu.org; Sun, 19 Jul 2020 19:11:03 -0400 Original-Received: from mail-ej1-f47.google.com ([209.85.218.47]:34196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jxIST-0004E7-Na for 42386@debbugs.gnu.org; Sun, 19 Jul 2020 19:11:02 -0400 Original-Received: by mail-ej1-f47.google.com with SMTP id y10so16230354eje.1 for <42386@debbugs.gnu.org>; Sun, 19 Jul 2020 16:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=eP/wU93/SziEyoe/ya2TgJhNENaPhtjVnp+22w1pNKo=; b=FSKx/6QJxnEWZNZtDX6/8GTPOE8NHinhqaLc9/+uGRmCvWUzcJTUULftUGr34GdPjF +c6776NqPC0M86tHiNPncfmDX5NolZMBeE8f6qnZ1BDCRuOe4G2BnGK9LRqiopE0rspS swLOpQSDvyD5H0kFGLjV8y/cg1qczk3xJaNIaSWvQ9tPUQcnJV0gyd+GIjHWx9X1iviE LQotaX6Ek/DQSez61uzdyxdYob+irosaEqHt+QSqBQBM/k6vxwGRykkSnwDojGoGy3Hp 72qMZvAkc3VCyH4WfbsegQVvFP41MEFc0EXg0NNLwCkKUd1D10HDoqKfyTXSIokE4N+t 8gfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eP/wU93/SziEyoe/ya2TgJhNENaPhtjVnp+22w1pNKo=; b=XWsk9xH01RAv9dVln9OXicfu33e5lBf0lhUAYyJuBzANWJE2GufeZxWRrSGxwKS2YR KBBzU/r3kFaG3ZlHJnYRJK4P2E+oQCloxFKq5IkLAG9vJDwVTPP7wqz9S+adNNWgrpw9 6SARYMe5phfdQeGOkj3x7RpN9IZO+/voroG+3i784IJqUjWs6zXYVcIZ6GRai9WvBZXZ V/E8yaZefsslmE85zDDVRRd+jmGqrm+Obot4gpVBFcX1DqnMW5wrBnSPF9/6osVsjv/x BNp09vk6kxoyb13hB3jDp8RSKdt2JWR+BZMt6m5ClNP+TeOsbo+KWbsDyvhvRlrHd3Zu +rDw== X-Gm-Message-State: AOAM532axOR9fohXr+bw40DkVxlfErtSde/UAQKndT6aO3Y4dabYo6v2 sZgO9IVYmHDzJqe2iOjJIEiVaMJW X-Google-Smtp-Source: ABdhPJyomYklPUjV/9sMYu+e4UNz9sJr1/y7RWsUohEMefCHiNI2X75TANWMd/HM0N1BVGd1mikCiw== X-Received: by 2002:a17:906:240d:: with SMTP id z13mr17919777eja.346.1595200255634; Sun, 19 Jul 2020 16:10:55 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id y22sm13465068ejj.67.2020.07.19.16.10.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Jul 2020 16:10:55 -0700 (PDT) In-Reply-To: <87mu3xdm50.fsf@warpmail.net> Content-Language: en-US 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:183273 Archived-At: On 18.07.2020 15:48, Philip K. wrote: > I like this idea a lot, the patch below should implement this + > backwards compatibility code. Thought this might be getting too > complicated, I also went ahead and added "and" and "or". All right. That's a bit further than I expected, but the result is still fast in the default scenario, so why not. ;-) I take it this approach behaved well enough in your testing? Should we replace (derived-mode . special-mode) with (and (derived-mode . special-mode) (not (major-mode . help-mode))) ? Some other minor comments below. > 0001-Replace-project-kill-buffers-ignores-with-.-kill-buf.patch > > From 6a9c268a340025bca428b5ec7c35229a29b4a95f Mon Sep 17 00:00:00 2001 > From: Philip K > Date: Thu, 16 Jul 2020 10:03:35 +0200 > Subject: [PATCH] Replace project-kill-buffers-ignores with > ...-kill-buffer-conditions Full commit message, if you can. > +- a symbol, denoting a buffer local variable, where the buffer > + is killed if it's value is non-nil. If the symbol also has a > + function slot, it will be interpreted as a function first. This also introduces an ambiguity which I'd like to avoid. Let's just make it if a symbol is there, it must be a function (and we should silence its errors). > +Buffers that match any of the conditions will not be killed." Will be. I think. > +(defcustom project-kill-buffers-ignores nil > + "Conditions for buffers `project-kill-buffers' should not kill." > + :type '(repeat choice regexp function) > + :set (lambda (var val) > + (add-to-list 'project-kill-buffer-conditions > + (cons 'not val)) > + (custom-set-default var val)) > + :version "28.1" > + :group 'project > + :package-version '(project . "0.6.0"))) Nice thought, but I think we're allowed to simply do away with this variable. At least I have been informed that as long as the package version haven't been in a "proper" Emacs release, its contents don't have the same backward compatibility promise. > +(defun project--kill-buffer-check (buf &optional conds) > + "Throw" Just so you don't forget to update or delete this docstring. > + (unless conds > + (setq conds project-kill-buffer-conditions)) I think we can make the CONDS argument required and pass in this value from project-kill-buffers. > + (catch (if (eq project-kill-buffer-conditions conds) > + 'kill 'other) Do we really need this condition? > + (dolist (c conds) > + (when (cond > + ((stringp c) > + (string-match-p c (buffer-name buf))) > + ((and (functionp c) Let's just make this (symbolp c). > + (ignore-errors (funcall c buf)))) and remove the 'ignore-errors' form. It's better to inform the user right away that their predicate is broken. > + ((and (symbolp c) (boundp c)) > + (buffer-local-value c buf)) And remove this case. > + ((eq (car-safe c) 'major-mode) > + (eq (buffer-local-value 'major-mode buf) > + (cdr c))) > + ((eq (car-safe c) 'derived-mode) > + (provided-mode-derived-p > + (buffer-local-value 'major-mode buf) > + (cdr c))) > + ((eq (car-safe c) 'not) > + (not (project--kill-buffer-check buf (cdr c)))) > + ((eq (car-safe c) 'and) > + (seq-every-p > + (apply-partially #'project--kill-buffer-check > + buf) > + (cdr c))) > + ((eq (car-safe c) 'or) > + (seq-some > + (apply-partially #'project--kill-buffer-check > + buf) I think we can simply recurse in this case. Thanks!