emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to bind keys in orgtbl-mode
@ 2011-12-09 21:36 Uwe Brauer
  2011-12-09 21:44 ` Nick Dokos
  2011-12-09 22:24 ` Carsten Dominik
  0 siblings, 2 replies; 6+ messages in thread
From: Uwe Brauer @ 2011-12-09 21:36 UTC (permalink / raw)
  To: emacs-orgmode



Hello 


how can I bind keys in Orgtbl minor mode?

I would like to have the same binding as in org-mode

  (local-set-key [(control c) (control w)] 'org-table-wrap-region)
  (local-set-key [(control c) (control h)] 'org-table-insert-hline)

But I don't find a orgtbl-mode-hook.
Thanks

Uwe Brauer 

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

* Re: how to bind keys in orgtbl-mode
  2011-12-09 21:36 how to bind keys in orgtbl-mode Uwe Brauer
@ 2011-12-09 21:44 ` Nick Dokos
  2011-12-09 22:24 ` Carsten Dominik
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2011-12-09 21:44 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: nicholas.dokos, emacs-orgmode

Uwe Brauer <oub@mat.ucm.es> wrote:

> 
> 
> Hello 
> 
> 
> how can I bind keys in Orgtbl minor mode?
> 
> I would like to have the same binding as in org-mode
> 
>   (local-set-key [(control c) (control w)] 'org-table-wrap-region)
>   (local-set-key [(control c) (control h)] 'org-table-insert-hline)
> 
> But I don't find a orgtbl-mode-hook.

Probably bind them in orgtbl-mode-map (untested).

Nick

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

* Re: how to bind keys in orgtbl-mode
  2011-12-09 21:36 how to bind keys in orgtbl-mode Uwe Brauer
  2011-12-09 21:44 ` Nick Dokos
@ 2011-12-09 22:24 ` Carsten Dominik
  2011-12-09 22:49   ` Uwe Brauer
  2011-12-15  7:50   ` Sebastien Vauban
  1 sibling, 2 replies; 6+ messages in thread
From: Carsten Dominik @ 2011-12-09 22:24 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode


On 9.12.2011, at 22:36, Uwe Brauer wrote:

> 
> 
> Hello 
> 
> 
> how can I bind keys in Orgtbl minor mode?
> 
> I would like to have the same binding as in org-mode
> 
>  (local-set-key [(control c) (control w)] 'org-table-wrap-region)

We could just add this to the standard orgtbl bindings - don't know why
this is not the case.  OK, I just did that.

>  (local-set-key [(control c) (control h)] 'org-table-insert-hline)

This one on the other hand violates Emacs conventions, so
we cannot do this by default.

> But I don't find a orgtbl-mode-hook.

Like Nick says, you need to set keys in orgtbl-mode-map.
You can use orgtbl-mode-hook to do this.  define-minor-mode
makes sure that a hook is run.

However, if you want to use them in a major mode that also
needs these keys (outside of tables), then you need to do
extra work to create magic commands that work inside
and outside tables, calling different commands in each
location.  This should do it:

(add-hook
 'orgtbl-mode-hook
 (lambda ()
   (org-defkey orgtbl-mode-map "\C-c\C-w"
	       (orgtbl-make-binding 'org-table-wrap-region 1000 "\C-c\C-w"))
   (org-defkey orgtbl-mode-map "\C-c\C-h"
	       (orgtbl-make-binding 'org-table-wrap-region 1001 "\C-c\C-h"))))

The 1000 and 1001 must be unique numbers not already used for this purpose
by orgtbl-mode, anything above 200 should be safe.


HTH

- Carsten

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

* Re: how to bind keys in orgtbl-mode
  2011-12-09 22:24 ` Carsten Dominik
@ 2011-12-09 22:49   ` Uwe Brauer
  2011-12-15  7:50   ` Sebastien Vauban
  1 sibling, 0 replies; 6+ messages in thread
From: Uwe Brauer @ 2011-12-09 22:49 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Uwe Brauer

Carsten Dominik wrote:
> (add-hook
>   'orgtbl-mode-hook
>   (lambda ()
>     (org-defkey orgtbl-mode-map "\C-c\C-w"
> 	       (orgtbl-make-binding 'org-table-wrap-region 1000 "\C-c\C-w"))
>     (org-defkey orgtbl-mode-map "\C-c\C-h"
> 	       (orgtbl-make-binding 'org-table-wrap-region 1001 "\C-c\C-h"))))
>
cool that works nicely, thanks

Uwe

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

* Re: how to bind keys in orgtbl-mode
  2011-12-09 22:24 ` Carsten Dominik
  2011-12-09 22:49   ` Uwe Brauer
@ 2011-12-15  7:50   ` Sebastien Vauban
  2011-12-15  8:11     ` Carsten Dominik
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-12-15  7:50 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Carsten,

Carsten Dominik wrote:
> On 9.12.2011, at 22:36, Uwe Brauer wrote:
>> I would like to have the same binding as in org-mode
>> 
>>  (local-set-key [(control c) (control w)] 'org-table-wrap-region)
>
> We could just add this to the standard orgtbl bindings - don't know why
> this is not the case.  OK, I just did that.
>
>>  (local-set-key [(control c) (control h)] 'org-table-insert-hline)
>
> This one on the other hand violates Emacs conventions, so
> we cannot do this by default.

FMI, why is the second violating Emacs conventions?  I don't really grap a
difference between both, and I'm not aware of the convention which would
become broken there.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: how to bind keys in orgtbl-mode
  2011-12-15  7:50   ` Sebastien Vauban
@ 2011-12-15  8:11     ` Carsten Dominik
  0 siblings, 0 replies; 6+ messages in thread
From: Carsten Dominik @ 2011-12-15  8:11 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode


On 15.12.2011, at 08:50, Sebastien Vauban wrote:

> Hi Carsten,
> 
> Carsten Dominik wrote:
>> On 9.12.2011, at 22:36, Uwe Brauer wrote:
>>> I would like to have the same binding as in org-mode
>>> 
>>> (local-set-key [(control c) (control w)] 'org-table-wrap-region)
>> 
>> We could just add this to the standard orgtbl bindings - don't know why
>> this is not the case.  OK, I just did that.
>> 
>>> (local-set-key [(control c) (control h)] 'org-table-insert-hline)
>> 
>> This one on the other hand violates Emacs conventions, so
>> we cannot do this by default.
> 
> FMI, why is the second violating Emacs conventions?  I don't really grap a
> difference between both, and I'm not aware of the convention which would
> become broken there.

C-c is a prefix key.  As with all prefix keys, if you follow
with C-h (h for help), a list of key bindings in that prefix
map is displayed.  This is automatic and is one of the
self-documenting features of Emacs.  If you bind
C-c C-h to a different command, the user looses helpful display.

Try, for example C-x C-h or C-c C-x C-h to see what I mean.
I hardly use this, but I do use it to remind myself of
rarely used rectangle commands: C-x r C-h

Cheers

- Carsten

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

end of thread, other threads:[~2011-12-15  8:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-09 21:36 how to bind keys in orgtbl-mode Uwe Brauer
2011-12-09 21:44 ` Nick Dokos
2011-12-09 22:24 ` Carsten Dominik
2011-12-09 22:49   ` Uwe Brauer
2011-12-15  7:50   ` Sebastien Vauban
2011-12-15  8:11     ` Carsten Dominik

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).