Re: [O] how to bind keys in orgtbl-mode
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
Re: [O] how to bind keys in orgtbl-mode
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
[O] how to bind keys in orgtbl-mode
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
Re: [O] how to bind keys in orgtbl-mode
Uwe Brauer o...@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
Re: [O] how to bind keys in orgtbl-mode
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
Re: [O] how to bind keys in orgtbl-mode
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