From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: how to bind keys in orgtbl-mode Date: Fri, 9 Dec 2011 23:24:37 +0100 Message-ID: References: <878vmltojo.fsf@mat.ucm.es> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZ8s0-0005Bw-T4 for emacs-orgmode@gnu.org; Fri, 09 Dec 2011 17:24:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZ8rz-0000G3-SN for emacs-orgmode@gnu.org; Fri, 09 Dec 2011 17:24:44 -0500 Received: from mail-ey0-f169.google.com ([209.85.215.169]:53696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZ8rz-0000Fp-Kc for emacs-orgmode@gnu.org; Fri, 09 Dec 2011 17:24:43 -0500 Received: by eaah1 with SMTP id h1so2090428eaa.0 for ; Fri, 09 Dec 2011 14:24:42 -0800 (PST) In-Reply-To: <878vmltojo.fsf@mat.ucm.es> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Uwe Brauer Cc: emacs-orgmode@gnu.org 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