From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: C-x C-v considered harmful Date: Thu, 09 Jul 2009 02:28:48 +0300 Organization: JURTA Message-ID: <87ws6ipxy7.fsf@mail.jurta.org> References: <19020.2798.523236.406366@rgr.rgrjr.com> <72597301DECF498C8943373F597732A6@us.oracle.com> <19021.23100.86775.844823@rgr.rgrjr.com> <19022.27409.779079.636945@rgr.rgrjr.com> <87vdm5xqpv.fsf@mail.jurta.org> <2F7C63D7187F4B44A095A4D99C86AF6F@us.oracle.com> <8763e42dhl.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1247095776 600 80.91.229.12 (8 Jul 2009 23:29:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jul 2009 23:29:36 +0000 (UTC) Cc: rogers-emacs@rgrjr.dyndns.org, rms@gnu.org, emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 09 01:29:28 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MOgZr-0002aN-UQ for ged-emacs-devel@m.gmane.org; Thu, 09 Jul 2009 01:29:28 +0200 Original-Received: from localhost ([127.0.0.1]:54238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOgZr-0005Db-C8 for ged-emacs-devel@m.gmane.org; Wed, 08 Jul 2009 19:29:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOgZl-0005Bo-2u for emacs-devel@gnu.org; Wed, 08 Jul 2009 19:29:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOgZe-00058d-Pa for emacs-devel@gnu.org; Wed, 08 Jul 2009 19:29:19 -0400 Original-Received: from [199.232.76.173] (port=49327 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOgZe-00058X-Jo for emacs-devel@gnu.org; Wed, 08 Jul 2009 19:29:14 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:35497 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOgZc-0005wg-4g; Wed, 08 Jul 2009 19:29:12 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.68.68.cable.starman.ee [82.131.68.68]) by mx1.starman.ee (Postfix) with ESMTP id 432E63F413B; Thu, 9 Jul 2009 02:29:05 +0300 (EEST) In-Reply-To: <8763e42dhl.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 08 Jul 2009 03:32:46 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:112210 Archived-At: > I brought these examples to help deciding what a default list of buffers > should require a confirmation. As Johan pointed out it is just a matter > of setting `kill-buffer-query-functions', e.g. in *shell* buffers. > But note that this can be annoying for users who like creating a lot > of shell buffers, so exiting from Emacs will ask a separate confirmation > for each of them. (BTW, `C-x C-c' already asks a confirmation about > shell buffers.) This can be handled by the following code: (add-hook 'kill-buffer-query-functions 'process-kill-buffer-query-function) (defun process-kill-buffer-query-function () "Ask before killing a buffer that has an active process." (let ((process (get-buffer-process (current-buffer)))) (or (not process) (not (memq (process-status process) '(run stop open listen))) (not (process-query-on-exit-flag process)) (yes-or-no-p "Buffer has an active process; kill it? ")))) It fixes both cases: killing a shell buffer as reported by OP, and killing a *Async Shell Command* buffer as I reported. The reason for doing this is the same as why exiting Emacs with `C-x C-c' asks a question about killing active processes. Active processes has the same worth to be asked a confirmation regardless whether they are killed with `C-x k', `C-x C-v' or `C-x C-c'. The variable `kill-buffer-query-functions' is nil by default, so maybe it's better to implement this confirmation in Fkill_buffer instead of the hook `kill-buffer-query-functions'? -- Juri Linkov http://www.jurta.org/emacs/