From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: org-table bindings available outside org tables too? Date: Mon, 23 May 2016 19:37:47 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113e39dcd59c51053387935f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vfs-0006D5-N8 for emacs-orgmode@gnu.org; Mon, 23 May 2016 15:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4vfq-0007Pt-DP for emacs-orgmode@gnu.org; Mon, 23 May 2016 15:37:59 -0400 Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:35239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vfq-0007Pp-6Z for emacs-orgmode@gnu.org; Mon, 23 May 2016 15:37:58 -0400 Received: by mail-oi0-x234.google.com with SMTP id x19so294472562oix.2 for ; Mon, 23 May 2016 12:37:57 -0700 (PDT) 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" To: emacs-org list --001a113e39dcd59c51053387935f Content-Type: text/plain; charset=UTF-8 Hi, We have a lot of org-table specific functions bound in org-mode-map whether or not the point is actually in an org table. Reference[1]. Is there a specific reason to have those bindings available globally in an org mode buffer? To prevent that, I have come up with this[2]. The idea is to use context-aware key mapping[3]. Also the info node: "(elisp) Extended Menu Items". Here is what binding "C-c SPC" looks like when using the bind-keys macro from bind-key.el[4]. (bind-keys :map org-mode-map :filter (org-at-table-p) ("C-c SPC" . org-table-blank-field)) Below is the same without bind-key.el dependency: (define-key org-mode-map (kbd "C-c SPC") '(menu-item "" nil :filter (lambda (&optional _) (when (org-at-table-p) 'org-table-blank-field)))) [1]: http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/org.el?id=58f5def6256ebef9cde9485daf7f57c45cd4402a#n20025 [2]: http://emacs.stackexchange.com/a/22457/115 [3]: http://endlessparentheses.com/define-context-aware-keys-in-emacs.html [4]: https://github.com/jwiegley/use-package/blob/master/bind-key.el -- -- Kaushal Modi --001a113e39dcd59c51053387935f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

We have a lot of org-table specific= functions bound in org-mode-map whether or not the point is actually in an= org table.

Reference[1].

Is there a specific reason to have those bindings available globally = in an org mode buffer?

To prevent that, I have come up with this[2].
The idea is to use context-aware key mapping[3]. Also the info = node: "(elisp) Extended Menu Items".

Her= e is what binding "C-c SPC" looks like when using the bind-keys m= acro from bind-key.el[4].

(bind-keys
=C2=A0:map org-mode-map
=C2=A0:filter (org-at-table-p)
=C2=A0 ("C-c SPC" . org-table-blank-field))
Below is the same without bind-key.el dependency:
(define-key org-mode-map (kbd "C-c SPC")
=C2=A0 '(menu-item "" nil :filter
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (&optional _)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (org-at-table-p)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &= #39;org-table-blank-field))))

--
=

--
Kaushal Modi

--001a113e39dcd59c51053387935f--