all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16548: 24.3; remove "buffer has clients" prompt
@ 2014-01-25 12:34 Jarek Czekalski
  2014-01-25 20:34 ` Glenn Morris
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Jarek Czekalski @ 2014-01-25 12:34 UTC (permalink / raw)
  To: 16548

When we try to kill a buffer, that was opened through
emacsclient, Emacs warns us: "buffer still has clients".
If we want to really kill it, we must answer "yes" (3 letters plus return).
If we modified the buffer, then in total we have 2 prompts to answer.
That seems too much and in help-gnu-emacs [1] no one could
provide a justification for that, other users seemed to
agree is is redundant. Eli had had some doubts, but
probably he got rid of them.

I suggest to remove the "buffer has clients" prompt completely.
If the buffer was not modified, it would close at once.

I want to prepare a patch, but may it be applied for 24.4,
despite feature freeze?

Jarek

[1] http://lists.gnu.org/archive/html/help-gnu-emacs/2013-11/msg00382.html






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
@ 2014-01-25 20:34 ` Glenn Morris
  2014-04-18 19:21 ` bug#16548: [PATCH] " Jarek Czekalski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2014-01-25 20:34 UTC (permalink / raw)
  To: Jarek Czekalski; +Cc: 16548

Jarek Czekalski wrote:

> I suggest to remove the "buffer has clients" prompt completely.
> If the buffer was not modified, it would close at once.
>
> I want to prepare a patch, but may it be applied for 24.4,
> despite feature freeze?

IMO such a change is not appropriate at this time.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: [PATCH] 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
  2014-01-25 20:34 ` Glenn Morris
@ 2014-04-18 19:21 ` Jarek Czekalski
  2014-04-27 13:31 ` bug#16548: [PATCH} " Jarek Czekalski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Jarek Czekalski @ 2014-04-18 19:21 UTC (permalink / raw)
  To: 16548

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

This patch simply removes the code for "buffer still has clients" query.

Tested on trunk from today.
The ChangeLog entry must be moved to the right place before commit.

Jarek


[-- Attachment #2: hasclients_1_0.patch --]
[-- Type: text/x-diff, Size: 2185 bytes --]

# HG changeset patch
# Parent 1cc4f193d0c14f255fb79a3a360d364f962d1514

diff -r 1cc4f193d0c1 lisp/ChangeLog
--- a/lisp/ChangeLog	Sat Apr 05 08:48:37 2014 +0200
+++ b/lisp/ChangeLog	Fri Apr 18 21:19:14 2014 +0200
@@ -16,6 +16,12 @@
 	* files.el (lock-buffer, unlock-buffer, file-locked-p):
 	Remove fallback aliases, since they are always defined now.
 
+2014-04-18  Jarek Czekalski  <jarekczek@poczta.onet.pl>
+
+	Remove unneeded prompt when closing a buffer with active emacsclient.
+	* server.el (server-start): Remove the only call to:
+	* server.el (server-kill-buffer-query-function): Remove.
+
 2014-03-24  Daniel Colascione  <dancol@dancol.org>
 
 	* emacs-lisp/cl-macs.el (cl--do-arglist): Use `plist-member'
diff -r 1cc4f193d0c1 lisp/server.el
--- a/lisp/server.el	Sat Apr 05 08:48:37 2014 +0200
+++ b/lisp/server.el	Fri Apr 18 21:19:14 2014 +0200
@@ -642,8 +642,6 @@
 	(cl-letf (((default-file-modes) ?\700))
 	  (add-hook 'suspend-tty-functions 'server-handle-suspend-tty)
 	  (add-hook 'delete-frame-functions 'server-handle-delete-frame)
-	  (add-hook 'kill-buffer-query-functions
-                    'server-kill-buffer-query-function)
 	  (add-hook 'kill-emacs-query-functions
                     'server-kill-emacs-query-function)
 	  (add-hook 'kill-emacs-hook 'server-force-stop) ;Cleanup upon exit.
@@ -1472,22 +1470,6 @@
 	(save-buffer)))
     (server-buffer-done (current-buffer))))
 
-;; Ask before killing a server buffer.
-;; It was suggested to release its client instead,
-;; but I think that is dangerous--the client would proceed
-;; using whatever is on disk in that file. -- rms.
-(defun server-kill-buffer-query-function ()
-  "Ask before killing a server buffer."
-  (or (not server-buffer-clients)
-      (let ((res t))
-	(dolist (proc server-buffer-clients)
-          (when (and (memq proc server-clients)
-                     (eq (process-status proc) 'open))
-            (setq res nil)))
-         res)
-      (yes-or-no-p (format "Buffer `%s' still has clients; kill it? "
-			   (buffer-name (current-buffer))))))
-
 (defun server-kill-emacs-query-function ()
   "Ask before exiting Emacs if it has live clients."
   (or (not server-clients)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: [PATCH} 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
  2014-01-25 20:34 ` Glenn Morris
  2014-04-18 19:21 ` bug#16548: [PATCH] " Jarek Czekalski
@ 2014-04-27 13:31 ` Jarek Czekalski
  2014-05-05  7:43 ` bug#16548: " Jarek Czekalski
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Jarek Czekalski @ 2014-04-27 13:31 UTC (permalink / raw)
  To: 16548

If no one objects, I'll commit this in a week.

Best
Jarek






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
                   ` (2 preceding siblings ...)
  2014-04-27 13:31 ` bug#16548: [PATCH} " Jarek Czekalski
@ 2014-05-05  7:43 ` Jarek Czekalski
  2015-04-30  6:53 ` Tim Howes
  2015-05-11  9:39 ` Andreas Amann
  5 siblings, 0 replies; 8+ messages in thread
From: Jarek Czekalski @ 2014-05-05  7:43 UTC (permalink / raw)
  To: 16548-done

Applied as r117062 [1]. Will be included in the next version after 24.4.

http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/117062






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
                   ` (3 preceding siblings ...)
  2014-05-05  7:43 ` bug#16548: " Jarek Czekalski
@ 2015-04-30  6:53 ` Tim Howes
  2015-05-11  9:39 ` Andreas Amann
  5 siblings, 0 replies; 8+ messages in thread
From: Tim Howes @ 2015-04-30  6:53 UTC (permalink / raw)
  To: 16548

I think this prompt should be kept. If I'm interpreting RMS's comment
correctly, he's worried about what happens when emacsclient is started from
some script or program, where the program is opening an editor window (most
likely using the EDITOR shell variable) and then waiting for the editor to
be done so that it can proceed and make use of the contents of the file. 

If a user has, say, forgotten why that particular buffer was opened, the
prompt reminds them that there is a client waiting on it, and the program
that started that client is possibly going to take some action using the
file contents. Killing the buffer will not cancel that action. Instead, the
program will proceed using whatever is currently saved in the file. 

This could lead to a mistake. Here's a scenario: I'm testing some
experimental program that runs into an error. The program wants me to send a
bug report to the developers, so it opens up an editor with a template email
(emacsclient -c template.txt), which I'm supposed to fill out, and it will
then send the email for me. I start writing a message, but don't save it. I
get distracted or start working on other things. I open another emacs client
frame and work on some other files. I finish with those other files, and
kill the buffers. Then I'm presented with the unsaved email from earlier. I
decide I don't care about sending the bug report, so I kill the buffer. I
expect that the email will not be sent, but the program is actually going to
proceed and send the uncompleted template. 

The prompt reminds me that the buffer is being used as an "editor" by some
other process. If I kill it carelessly, that process may end up doing
something unwanted. If I'm well aware of the circumstances and want to skip
the prompt, I should use C-x # ("done editing"). If I'm not worried about
such mistakes ever occurring, then I can remove the hook or change key
bindings in my emacs config. But it's probably best to have the prompt
appear by default, to help unaware users avoid mistakes.



--
View this message in context: http://emacs.1067599.n5.nabble.com/bug-16548-24-3-remove-buffer-has-clients-prompt-tp311633p357150.html
Sent from the Emacs - Bugs mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: 24.3; remove "buffer has clients" prompt
  2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
                   ` (4 preceding siblings ...)
  2015-04-30  6:53 ` Tim Howes
@ 2015-05-11  9:39 ` Andreas Amann
  2015-05-17  4:07   ` Tim Howes
  5 siblings, 1 reply; 8+ messages in thread
From: Andreas Amann @ 2015-05-11  9:39 UTC (permalink / raw)
  To: 16548; +Cc: howestim

Maybe the right thing to do is to exit emacsclient with an error code if
the buffer is killed through another client? This should then be caught
by the script, which in the above example should not send an email if
emacsclient returns with error exit status. 





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#16548: 24.3; remove "buffer has clients" prompt
  2015-05-11  9:39 ` Andreas Amann
@ 2015-05-17  4:07   ` Tim Howes
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Howes @ 2015-05-17  4:07 UTC (permalink / raw)
  To: 16548

Well, I think the same concern still applies even if only one client frame is
open. Some users might have all their "editor" buffers started by other
applications opening in the same existing frame. And the script or
application that opens the editor may not be set up to handle the error
codes correctly.

I was going to say, if the prompt bothers you, why not just add (remove-hook
'kill-buffer-query-functions 'server-kill-buffer-query-function) to your
emacs config. But it appears that doesn't work. I guess the server-specific
hooks get loaded after the init files.

Someone on StackOverflow suggested the following:
  (defun server-remove-kill-buffer-hook () 
      (remove-hook 'kill-buffer-query-functions
'server-kill-buffer-query-function))
  (add-hook 'server-visit-hook 'server-remove-kill-buffer-hook)

http://stackoverflow.com/questions/268088/how-to-remove-the-prompt-for-killing-emacsclient-buffers

I guess it would be easier if there was simply a variable, with a name such
as server-query-before-kill-buffer, that could be set to t or nil.



--
View this message in context: http://emacs.1067599.n5.nabble.com/bug-16548-24-3-remove-buffer-has-clients-prompt-tp311633p358682.html
Sent from the Emacs - Bugs mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-17  4:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25 12:34 bug#16548: 24.3; remove "buffer has clients" prompt Jarek Czekalski
2014-01-25 20:34 ` Glenn Morris
2014-04-18 19:21 ` bug#16548: [PATCH] " Jarek Czekalski
2014-04-27 13:31 ` bug#16548: [PATCH} " Jarek Czekalski
2014-05-05  7:43 ` bug#16548: " Jarek Czekalski
2015-04-30  6:53 ` Tim Howes
2015-05-11  9:39 ` Andreas Amann
2015-05-17  4:07   ` Tim Howes

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.