unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "C-c C-c" binding for "submission" in server edit buffers
@ 2009-04-14  8:00 Miles Bader
  2009-04-14 12:52 ` Stefan Monnier
  2009-04-14 13:11 ` Jason Rumney
  0 siblings, 2 replies; 11+ messages in thread
From: Miles Bader @ 2009-04-14  8:00 UTC (permalink / raw)
  To: emacs-devel

I'm so used to using "C-c C-c" to mean "submit" in many emacs modes,
that I find myself getting a bit flummoxed when it doesn't do that in
buffers created by emacsclient.

The following patch seems to make things work more or less as my fingers
expect them too (maybe it should automatically save the buffer first, as
most uses of C-c C-c seem to do that); what do people think (of the
idea anyway ... maybe the implementation has some problem)?

-Miles


diff --git a/lisp/server.el b/lisp/server.el
index 10b08ad..e977dfe 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -194,6 +194,16 @@ in this way."
 (or (assq 'server-buffer-clients minor-mode-alist)
     (push '(server-buffer-clients " Server") minor-mode-alist))
 
+(defvar server-buffer-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-c" 'server-done)
+    map)
+  "Local keymap for emacs-server created buffers")
+
+(or (assq 'server-buffer-clients minor-mode-map-alist)
+    (push (cons 'server-buffer-clients server-buffer-map)
+	  minor-mode-map-alist))
+
 (defvar server-existing-buffer nil
   "Non-nil means the buffer existed before the server was asked to visit it.
 This means that the server should not kill the buffer when you say you
@@ -1228,6 +1238,7 @@ of the form (NEXT-BUFFER KILLED).  NEXT-BUFFER is another server buffer,
 as a suggestion for what to select next, or nil.
 KILLED is t if we killed BUFFER, which happens if it was created
 specifically for the clients and did not exist before their request for it."
+  (interactive)
   (when server-buffer-clients
     (if (server-temp-file-p)
 	;; For a temp file, save, and do make a non-numeric backup



-- 
My books focus on timeless truths.  -- Donald Knuth




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14  8:00 "C-c C-c" binding for "submission" in server edit buffers Miles Bader
@ 2009-04-14 12:52 ` Stefan Monnier
  2009-04-14 13:52   ` Miles Bader
  2009-04-14 13:11 ` Jason Rumney
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2009-04-14 12:52 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

> I'm so used to using "C-c C-c" to mean "submit" in many emacs modes,
> that I find myself getting a bit flummoxed when it doesn't do that in
> buffers created by emacsclient.

> The following patch seems to make things work more or less as my fingers
> expect them too (maybe it should automatically save the buffer first, as
> most uses of C-c C-c seem to do that); what do people think (of the
> idea anyway ... maybe the implementation has some problem)?

I see the logic of it, but I personally would hate it (I often use
emacsclient for files where C-c C-c submits elsewhere than "back to the
caller of emacsclient").  I use C-x C-c for "end of edit" instead.


        Stefan




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14  8:00 "C-c C-c" binding for "submission" in server edit buffers Miles Bader
  2009-04-14 12:52 ` Stefan Monnier
@ 2009-04-14 13:11 ` Jason Rumney
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Rumney @ 2009-04-14 13:11 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

Miles Bader wrote:
> I'm so used to using "C-c C-c" to mean "submit" in many emacs modes,
> that I find myself getting a bit flummoxed when it doesn't do that in
> buffers created by emacsclient.
>
> The following patch seems to make things work more or less as my fingers
> expect them too

Doesn't this binding conflict with many mode specific bindings of C-c C-c?





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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 12:52 ` Stefan Monnier
@ 2009-04-14 13:52   ` Miles Bader
  2009-04-14 17:00     ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Miles Bader @ 2009-04-14 13:52 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The following patch seems to make things work more or less as my fingers
>> expect them too (maybe it should automatically save the buffer first, as
>> most uses of C-c C-c seem to do that); what do people think (of the
>> idea anyway ... maybe the implementation has some problem)?
>
> I see the logic of it, but I personally would hate it (I often use
> emacsclient for files where C-c C-c submits elsewhere than "back to the
> caller of emacsclient").  I use C-x C-c for "end of edit" instead.

I agree that it's might be a tiny bit too specialized to be turned on by
default -- after all, some people do use emacclient simply to start new
editing sessions.

Perhaps what would be best would be to have it off by deafult, but
provide a very easy way to turn it on from emacsclient, via a command
line option, an environment variable, or something.  I think when I want
this behavior, it's usually when invoking from specific contexts via
VISUAL/EDITOR (mutt/git/etc), but in those contexts, I pretty much
always want it.

Maybe just --eval ...? (but that can be a little annoying because it
might flummox invokers that don't use sh -c and do simplistic whitespace
splitting or something...)

-Miles

-- 
Back, n. That part of your friend which it is your privilege to contemplate in
your adversity.





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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 13:52   ` Miles Bader
@ 2009-04-14 17:00     ` Stefan Monnier
  2009-04-14 18:26       ` Chong Yidong
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2009-04-14 17:00 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

>>> The following patch seems to make things work more or less as my fingers
>>> expect them too (maybe it should automatically save the buffer first, as
>>> most uses of C-c C-c seem to do that); what do people think (of the
>>> idea anyway ... maybe the implementation has some problem)?
>> I see the logic of it, but I personally would hate it (I often use
>> emacsclient for files where C-c C-c submits elsewhere than "back to the
>> caller of emacsclient").  I use C-x C-c for "end of edit" instead.
> I agree that it's might be a tiny bit too specialized to be turned on by
> default -- after all, some people do use emacclient simply to start new
> editing sessions.

After thinking some more about it, I see that this patch probably
wouldn't affect me much because it doesn't seem to affect
"emacsclient --no-wait", which is what I use 99% of the time.

> Perhaps what would be best would be to have it off by deafult, but
> provide a very easy way to turn it on from emacsclient, via a command
> line option, an environment variable, or something.  I think when I want
> this behavior, it's usually when invoking from specific contexts via
> VISUAL/EDITOR (mutt/git/etc), but in those contexts, I pretty much
> always want it.

Maybe a global binding rather than a minor-mode binding would be less
problematic (since minor-mode bindings take precedence over major-mode
bindings).


        Stefan




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 17:00     ` Stefan Monnier
@ 2009-04-14 18:26       ` Chong Yidong
  2009-04-14 18:32         ` Lennart Borgman
  0 siblings, 1 reply; 11+ messages in thread
From: Chong Yidong @ 2009-04-14 18:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Miles Bader

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Maybe a global binding rather than a minor-mode binding would be less
> problematic (since minor-mode bindings take precedence over major-mode
> bindings).

I think it would be very confusing to bind C-c C-c to server-edit
globally.  That keybinding is used in so many places that adapting it
for server-edit is simply impractical, because then it may not be clear
to the user what C-c C-c does in a given context.

For instance, suppose you use emacsclient to edit a ChangeLog file.  In
change-log-mode, C-c C-c is bound to change-log-goto-source.  That
conflicts with using C-c C-c to finish the edit.




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 18:26       ` Chong Yidong
@ 2009-04-14 18:32         ` Lennart Borgman
  2009-04-14 22:17           ` Miles Bader
  0 siblings, 1 reply; 11+ messages in thread
From: Lennart Borgman @ 2009-04-14 18:32 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Miles Bader, Stefan Monnier, emacs-devel

On Tue, Apr 14, 2009 at 8:26 PM, Chong Yidong <cyd@stupidchicken.com> wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> Maybe a global binding rather than a minor-mode binding would be less
>> problematic (since minor-mode bindings take precedence over major-mode
>> bindings).
>
> I think it would be very confusing to bind C-c C-c to server-edit
> globally.  That keybinding is used in so many places that adapting it
> for server-edit is simply impractical, because then it may not be clear
> to the user what C-c C-c does in a given context.

What is the reason for not using

  C-x k

which normally kills the buffer?




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 18:32         ` Lennart Borgman
@ 2009-04-14 22:17           ` Miles Bader
  2009-04-14 22:41             ` Lennart Borgman
  2009-04-15  3:49             ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: Miles Bader @ 2009-04-14 22:17 UTC (permalink / raw)
  To: emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:
> What is the reason for not using
>   C-x k
> which normally kills the buffer?

There are keybindings already (C-x #, C-x C-c for emacsclient -t);
mainly my point is that for certain circumstances, C-c C-c is far more
natural.

So my desire is to make it simple to use C-c C-c in those circumstances.

-Miles

-- 
Kilt, n. A costume sometimes worn by Scotchmen [sic] in America and Americans
in Scotland.





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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 22:17           ` Miles Bader
@ 2009-04-14 22:41             ` Lennart Borgman
  2009-04-15  0:25               ` Miles Bader
  2009-04-15  3:49             ` Stefan Monnier
  1 sibling, 1 reply; 11+ messages in thread
From: Lennart Borgman @ 2009-04-14 22:41 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

On Wed, Apr 15, 2009 at 12:17 AM, Miles Bader <miles@gnu.org> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> writes:
>> What is the reason for not using
>>   C-x k
>> which normally kills the buffer?
>
> There are keybindings already (C-x #, C-x C-c for emacsclient -t);
> mainly my point is that for certain circumstances, C-c C-c is far more
> natural.
>
> So my desire is to make it simple to use C-c C-c in those circumstances.

Thanks Miles, yes I understand what you want, but to me "C-x k" would
be much more natural.




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 22:41             ` Lennart Borgman
@ 2009-04-15  0:25               ` Miles Bader
  0 siblings, 0 replies; 11+ messages in thread
From: Miles Bader @ 2009-04-15  0:25 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:
>> There are keybindings already (C-x #, C-x C-c for emacsclient -t);
>> mainly my point is that for certain circumstances, C-c C-c is far more
>> natural.
>>
>> So my desire is to make it simple to use C-c C-c in those circumstances.
>
> Thanks Miles, yes I understand what you want, but to me "C-x k" would
> be much more natural.

Hmm, I'd think "C-x k" might be a natural binding for a "negative" exit
... but AFAIK, there's no way of communicating such a thing back to
emacsclient (so it could, for instance, exit with a non-zero status).

Actually the default binding of "C-x k" already does more or less the
right thing for what you want, though it prompts for confirmation first.

-Miles

-- 
P.S.  All information contained in the above letter is false,
      for reasons of military security.




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

* Re: "C-c C-c" binding for "submission" in server edit buffers
  2009-04-14 22:17           ` Miles Bader
  2009-04-14 22:41             ` Lennart Borgman
@ 2009-04-15  3:49             ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2009-04-15  3:49 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

>> What is the reason for not using
>> C-x k
>> which normally kills the buffer?

> There are keybindings already (C-x #, C-x C-c for emacsclient -t);
> mainly my point is that for certain circumstances, C-c C-c is far more
> natural.

I guess it might make sense to have the C-c C-c enabled via
a command line switch in emacsclient.


        Stefan




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

end of thread, other threads:[~2009-04-15  3:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-14  8:00 "C-c C-c" binding for "submission" in server edit buffers Miles Bader
2009-04-14 12:52 ` Stefan Monnier
2009-04-14 13:52   ` Miles Bader
2009-04-14 17:00     ` Stefan Monnier
2009-04-14 18:26       ` Chong Yidong
2009-04-14 18:32         ` Lennart Borgman
2009-04-14 22:17           ` Miles Bader
2009-04-14 22:41             ` Lennart Borgman
2009-04-15  0:25               ` Miles Bader
2009-04-15  3:49             ` Stefan Monnier
2009-04-14 13:11 ` Jason Rumney

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).