From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.devel Subject: [PATCHv2] files.el: avoid asking whether to kill Emacs multiple times Date: Fri, 30 Jan 2015 02:39:17 +0100 Organization: http://mina86.com/ Message-ID: References: <1422540409-4134-1-git-send-email-mpn@google.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1422581978 11463 80.91.229.3 (30 Jan 2015 01:39:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Jan 2015 01:39:38 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier , Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 30 02:39:33 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YH0YW-0003ft-9N for ged-emacs-devel@m.gmane.org; Fri, 30 Jan 2015 02:39:32 +0100 Original-Received: from localhost ([::1]:34316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH0YV-0000q3-C3 for ged-emacs-devel@m.gmane.org; Thu, 29 Jan 2015 20:39:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH0YQ-0000po-R2 for emacs-devel@gnu.org; Thu, 29 Jan 2015 20:39:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH0YM-0002Rm-MT for emacs-devel@gnu.org; Thu, 29 Jan 2015 20:39:26 -0500 Original-Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:52480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH0YM-0002RP-Ct for emacs-devel@gnu.org; Thu, 29 Jan 2015 20:39:22 -0500 Original-Received: by mail-we0-f174.google.com with SMTP id w55so19208281wes.5 for ; Thu, 29 Jan 2015 17:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type :content-transfer-encoding; bh=gCaVSf6qXeRINMJ9BijJSstPDfny+aIqlnWbBYYCR1E=; b=OwGWVMVDv/hvta+fuk1v3GWtkeVUJzGKJGfFyo9R0SqEC4b/gN+yyExLYzTmb87aRx urRpD4VnwzHd08xEBUVLrUEaspvfFl/BXo+tp+sy8q7uZ9AjVcbjBq8UPMCNmgh41hMO GKcKdZQqtyDQ6I4I4V7bcJA7ZEW6QxnR71tzzuNLIBKauldtFBT8qKGGJJNvStAG9JqJ O2+DQ6Xx3nQWgArSUwMpBgV9b6fHesXNHxNRN9JNy9Q6ybRKHvK593tB/YFNqDRBtqHO j/MeKhYwKYyB5JjgdE5IJnwj0RLMyA7/vRX3pGkz6dS7/vFuuSwrqFUxq+xVfHCdjG9C krJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-type:content-transfer-encoding; bh=gCaVSf6qXeRINMJ9BijJSstPDfny+aIqlnWbBYYCR1E=; b=MKth+AUYn6t7zQQejTiznyE/YQ/+Cr+ezVwYLicV0Z4NilfJwVM27nUDvRXDfXXmky wTb+IxWSugfxNw4MiTtXtXWhJn4JSurfy9sKVh1sdrxkRqgmCc1ZIVMs6ihX7y4g2Awo A78gYvje/36FMXG1SurVmkSU6xqSvu5TlpO460dJWtHZxwIWq9Eh5XhlLB/gMwLYX29V USGYGY9yC+MpqUMAOxQFsc/H4zg93vYasPagQ3o9tA0lCxB1s8FU4t0FWx+5RQIy/J0G 6530zCZaEIs3i3AW/uDWiIs2fOZtBojpt7OvX35Lrri81i0vjmORMy/dcWkzMdh6Mw6z HMdg== X-Gm-Message-State: ALoCoQlxeXDKx0q0YkJ2E9XCEgnWD40+z6iosH9fnSx6/4dISbo/hD4j6Xi2OaHAI8Lee3izzcT5 X-Received: by 10.194.250.5 with SMTP id yy5mr6441121wjc.133.1422581961464; Thu, 29 Jan 2015 17:39:21 -0800 (PST) Original-Received: from mpn-glaptop ([109.132.136.10]) by mx.google.com with ESMTPSA id l6sm12709046wjx.33.2015.01.29.17.39.19 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 17:39:20 -0800 (PST) In-Reply-To: User-Agent: Notmuch/0.19~rc1+1~g03aea4f (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR 4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:150130:emacs-devel@gnu.org::iUfrNP9AZY4i1O+T:0000000000000000000000000000000000000000000qA5 X-Hashcash: 1:20:150130:monnier@iro.umontreal.ca::D85Rp3+cN/ekDtV2:00000000000000000000000000000000000002n2q X-Hashcash: 1:20:150130:drew.adams@oracle.com::rlTF+Q+Evfqp3/Mj:00000000000000000000000000000000000000005tTM X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182014 Archived-At: * lisp/files.el (save-buffers-kill-emacs): If `confirm-kill-emacs' is set, but user has just been asked whether they really want to kill Emacs (for example with a =E2=80=98Modified buffers exist; exit anyway?=E2=80=99 = prompt) , do not ask them for another confirmation. --- lisp/files.el | 63 ++++++++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 34 insertions(+), 29 deletions(-) On Thu, Jan 29 2015, Stefan Monnier wrote: >>> If `confirm-kill-emacs' is set, but user has just been asked whether >>> they really want to kill Emacs (for example with a =E2=80=98Modified bu= ffers >>> exist; exit anyway?=E2=80=99 prompt), do not ask them for another confi= rmation. > > I agree that skipping the second confirmation would be desirable. > >>> However, apply this exception only if `confirm-kill-emacs' is >>> 'yes-or-no-p or 'y-or-n-p, otherwise this change might errenously >>> prevent some user defined function from being run. > Is it really worth the trouble? Comparing functions is just a bad > idea in general, so if we can avoid it, it's preferable. I=E2=80=99m happy to remove that comparison. I just wanted to avoid situat= ions where we break things for someone doing something weird like: (setq confirm-kill-emacs (lambda (_) =E2=80=A6something that really should be=20 a kill-emacs-query-functions=E2=80=A6)) Not having this special case makes code easier though so I can live with a conclusion that breaking such code is worth it. diff --git a/lisp/files.el b/lisp/files.el index 40a4289..5e80cb7 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6590,35 +6590,40 @@ (defun save-buffers-kill-emacs (&optional arg) if any returns nil. If `confirm-kill-emacs' is non-nil, calls it." (interactive "P") (save-some-buffers arg t) - (and (or (not (memq t (mapcar (function - (lambda (buf) (and (buffer-file-name buf) - (buffer-modified-p buf)))) - (buffer-list)))) - (yes-or-no-p "Modified buffers exist; exit anyway? ")) - (or (not (fboundp 'process-list)) - ;; process-list is not defined on MSDOS. - (let ((processes (process-list)) - active) - (while processes - (and (memq (process-status (car processes)) '(run stop open listen= )) - (process-query-on-exit-flag (car processes)) - (setq active t)) - (setq processes (cdr processes))) - (or (not active) - (with-current-buffer-window - (get-buffer-create "*Process List*") nil - #'(lambda (window _value) - (with-selected-window window - (unwind-protect - (yes-or-no-p "Active processes exist; kill them and exit anyway? ") - (when (window-live-p window) - (quit-restore-window window 'kill))))) - (list-processes t))))) - ;; Query the user for other things, perhaps. - (run-hook-with-args-until-failure 'kill-emacs-query-functions) - (or (null confirm-kill-emacs) - (funcall confirm-kill-emacs "Really exit Emacs? ")) - (kill-emacs))) + (let ((confirm confirm-kill-emacs)) + (and + (or (not (memq t (mapcar (function + (lambda (buf) (and (buffer-file-name buf) + (buffer-modified-p buf))= )) + (buffer-list)))) + (progn (setq confirm nil) + (yes-or-no-p "Modified buffers exist; exit anyway? "))) + (or (not (fboundp 'process-list)) + ;; process-list is not defined on MSDOS. + (let ((processes (process-list)) + active) + (while processes + (and (memq (process-status (car processes)) '(run stop open l= isten)) + (process-query-on-exit-flag (car processes)) + (setq active t)) + (setq processes (cdr processes))) + (or (not active) + (with-current-buffer-window + (get-buffer-create "*Process List*") nil + #'(lambda (window _value) + (with-selected-window window + (unwind-protect + (progn + (setq confirm nil) + (yes-or-no-p "Active processes exist; kill the= m and exit anyway? ")) + (when (window-live-p window) + (quit-restore-window window 'kill))))) + (list-processes t))))) + ;; Query the user for other things, perhaps. + (run-hook-with-args-until-failure 'kill-emacs-query-functions) + (or (null confirm) + (funcall confirm "Really exit Emacs? ")) + (kill-emacs)))) =20 (defun save-buffers-kill-terminal (&optional arg) "Offer to save each buffer, then kill the current connection. --=20 2.2.0.rc0.207.ga3a616c