unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* calc-undo keybinding
@ 2011-01-19 15:58 joakim
  2011-01-19 20:58 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: joakim @ 2011-01-19 15:58 UTC (permalink / raw)
  To: Emacs developers

I like to bind the undo command to c-z.
calc-ext.el rebinds all standard undo keys to calc-undo.

Now, I can of course create my prefered binding in the mode hook, but is
that really the best way? None of the keymap remap commands seemed
suitable, but I'm happily corrected.

-- 
Joakim Verona



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

* Re: calc-undo keybinding
  2011-01-19 15:58 calc-undo keybinding joakim
@ 2011-01-19 20:58 ` Stefan Monnier
  2011-01-19 21:48   ` joakim
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-01-19 20:58 UTC (permalink / raw)
  To: joakim; +Cc: Emacs developers

> I like to bind the undo command to c-z.

OK.

> calc-ext.el rebinds all standard undo keys to calc-undo.

OK.

> Now, I can of course create my prefered binding in the mode hook, but is
> that really the best way? None of the keymap remap commands seemed
> suitable, but I'm happily corrected.

I missed the part where you describe the problem.  Is it that
calc-ext.el rebinds all standard undo keys to calc-undo but doesn't
rebind your C-z binding?


        Stefan



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

* Re: calc-undo keybinding
  2011-01-19 20:58 ` Stefan Monnier
@ 2011-01-19 21:48   ` joakim
  2011-01-19 23:13     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: joakim @ 2011-01-19 21:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

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

>> I like to bind the undo command to c-z.
>
> OK.
>
>> calc-ext.el rebinds all standard undo keys to calc-undo.
>
> OK.
>
>> Now, I can of course create my prefered binding in the mode hook, but is
>> that really the best way? None of the keymap remap commands seemed
>> suitable, but I'm happily corrected.
>
> I missed the part where you describe the problem.  Is it that
> calc-ext.el rebinds all standard undo keys to calc-undo but doesn't
> rebind your C-z binding?

Yes. I can fix it in the mode hook, but is this really the way it should
work? It just feels like calc should hook into the existing undo
function.

>
>         Stefan

-- 
Joakim Verona



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

* Re: calc-undo keybinding
  2011-01-19 21:48   ` joakim
@ 2011-01-19 23:13     ` Stefan Monnier
  2011-01-20 10:06       ` Štěpán Němec
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-01-19 23:13 UTC (permalink / raw)
  To: joakim; +Cc: Emacs developers

>> I missed the part where you describe the problem.  Is it that
>> calc-ext.el rebinds all standard undo keys to calc-undo but doesn't
>> rebind your C-z binding?

> Yes. I can fix it in the mode hook, but is this really the way it should
> work? It just feels like calc should hook into the existing undo
> function.

I don't know enough about calc-undo's behavior to know whether it could
work by hooking into Emacs's undo.  Clearly, it was written long before
Emacs's undo provided hooks.

But I guess a change like the patch below would be in order and should
fix the problem for you.


        Stefan


=== modified file 'lisp/calc/calc-ext.el'
--- lisp/calc/calc-ext.el	2011-01-16 02:21:30 +0000
+++ lisp/calc/calc-ext.el	2011-01-19 23:12:20 +0000
@@ -136,8 +136,7 @@
   (define-key calc-mode-map "\C-w" 'calc-kill-region)
   (define-key calc-mode-map "\M-w" 'calc-copy-region-as-kill)
   (define-key calc-mode-map "\M-\C-w" 'kill-ring-save)
-  (define-key calc-mode-map "\C-_" 'calc-undo)
-  (define-key calc-mode-map "\C-xu" 'calc-undo)
+  (substitute-key-definition 'undo 'calc-undo calc-mode-map global-map)
   (define-key calc-mode-map "\M-\C-m" 'calc-last-args)
 
   (define-key calc-mode-map "a" nil)




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

* Re: calc-undo keybinding
  2011-01-19 23:13     ` Stefan Monnier
@ 2011-01-20 10:06       ` Štěpán Němec
  2011-01-20 15:53         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Štěpán Němec @ 2011-01-20 10:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: joakim, Emacs developers

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

>>> I missed the part where you describe the problem.  Is it that
>>> calc-ext.el rebinds all standard undo keys to calc-undo but doesn't
>>> rebind your C-z binding?
>
>> Yes. I can fix it in the mode hook, but is this really the way it should
>> work? It just feels like calc should hook into the existing undo
>> function.
>
> I don't know enough about calc-undo's behavior to know whether it could
> work by hooking into Emacs's undo.  Clearly, it was written long before
> Emacs's undo provided hooks.
>
> But I guess a change like the patch below would be in order and should
> fix the problem for you.
>
>
>         Stefan
>
>
> === modified file 'lisp/calc/calc-ext.el'
> --- lisp/calc/calc-ext.el	2011-01-16 02:21:30 +0000
> +++ lisp/calc/calc-ext.el	2011-01-19 23:12:20 +0000
> @@ -136,8 +136,7 @@
>    (define-key calc-mode-map "\C-w" 'calc-kill-region)
>    (define-key calc-mode-map "\M-w" 'calc-copy-region-as-kill)
>    (define-key calc-mode-map "\M-\C-w" 'kill-ring-save)
> -  (define-key calc-mode-map "\C-_" 'calc-undo)
> -  (define-key calc-mode-map "\C-xu" 'calc-undo)
> +  (substitute-key-definition 'undo 'calc-undo calc-mode-map global-map)
>    (define-key calc-mode-map "\M-\C-m" 'calc-last-args)
>  
>    (define-key calc-mode-map "a" nil)

Why not just use command remapping, i.e.

  (define-key calc-mode-map [remap undo] 'calc-undo)

? (It won't work on XEmacs AFAIK, but that's not a problem for you I'm
guessing.)

  Štěpán



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

* Re: calc-undo keybinding
  2011-01-20 10:06       ` Štěpán Němec
@ 2011-01-20 15:53         ` Stefan Monnier
  2011-01-20 18:57           ` Jay Belanger
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-01-20 15:53 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: joakim, Emacs developers

>> --- lisp/calc/calc-ext.el	2011-01-16 02:21:30 +0000
>> +++ lisp/calc/calc-ext.el	2011-01-19 23:12:20 +0000
>> @@ -136,8 +136,7 @@
>> (define-key calc-mode-map "\C-w" 'calc-kill-region)
>> (define-key calc-mode-map "\M-w" 'calc-copy-region-as-kill)
>> (define-key calc-mode-map "\M-\C-w" 'kill-ring-save)
>> -  (define-key calc-mode-map "\C-_" 'calc-undo)
>> -  (define-key calc-mode-map "\C-xu" 'calc-undo)
>> +  (substitute-key-definition 'undo 'calc-undo calc-mode-map global-map)
>> (define-key calc-mode-map "\M-\C-m" 'calc-last-args)
>> 
>> (define-key calc-mode-map "a" nil)

> Why not just use command remapping, i.e.

>   (define-key calc-mode-map [remap undo] 'calc-undo)

> ? (It won't work on XEmacs AFAIK, but that's not a problem for you I'm
> guessing.)

That's an alternative, yes.  Not knowing enough about how what calc-undo
does, I can't judge whether that's preferable (which mostly depends on
whether it's OK to render the real `undo' completely unreachable (other
than via M-x undo) in those buffers).  I'll let the Calc maintainer
figure that one out.


        Stefan



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

* Re: calc-undo keybinding
  2011-01-20 15:53         ` Stefan Monnier
@ 2011-01-20 18:57           ` Jay Belanger
  0 siblings, 0 replies; 7+ messages in thread
From: Jay Belanger @ 2011-01-20 18:57 UTC (permalink / raw)
  To: Emacs developers; +Cc: jay.p.belanger


Stefan Monnier <monnier@iro.umontreal.ca> writes:
...
>>> +  (substitute-key-definition 'undo 'calc-undo calc-mode-map global-map)
...
>> Why not just use command remapping, i.e.
>
>>   (define-key calc-mode-map [remap undo] 'calc-undo)
...
> That's an alternative, yes.  Not knowing enough about how what calc-undo
> does, I can't judge whether that's preferable (which mostly depends on
> whether it's OK to render the real `undo' completely unreachable (other
> than via M-x undo) in those buffers).

The real `undo' is pretty useless in a Calc buffer; making it
unreachable isn't a problem.  I'm not sure what different effects the
above two remapping commands have, but it sounds like the second one
will work fine.  I'll make the change when I get home.

Jay



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

end of thread, other threads:[~2011-01-20 18:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-19 15:58 calc-undo keybinding joakim
2011-01-19 20:58 ` Stefan Monnier
2011-01-19 21:48   ` joakim
2011-01-19 23:13     ` Stefan Monnier
2011-01-20 10:06       ` Štěpán Němec
2011-01-20 15:53         ` Stefan Monnier
2011-01-20 18:57           ` Jay Belanger

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).