From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: org-table-mark-field Date: Sat, 14 May 2016 07:10:20 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c092f6c2d11410532c81637 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1Tib-0002BY-Ct for emacs-orgmode@gnu.org; Sat, 14 May 2016 03:10:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1TiZ-0002f5-7j for emacs-orgmode@gnu.org; Sat, 14 May 2016 03:10:32 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:36054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1TiZ-0002f1-0h for emacs-orgmode@gnu.org; Sat, 14 May 2016 03:10:31 -0400 Received: by mail-oi0-x232.google.com with SMTP id x201so202999538oif.3 for ; Sat, 14 May 2016 00:10:30 -0700 (PDT) In-Reply-To: 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 --94eb2c092f6c2d11410532c81637 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The solution was unnecessarily over-complicated. Below one seems simpler and more intuitive. It requires the hydra package. (defun org-table-mark-field () "Mark the current table field." (interactive) ;; Do not try to jump to the beginning of field if the point is already there (when (not (looking-back "|\\s-?")) (org-table-beginning-of-field 1)) (set-mark-command nil) (org-table-end-of-field 1)) (defhydra hydra-org-table-mark-field (:body-pre (org-table-mark-field) :color pink :hint nil) " ^^ _p_ ^^ _b_ selection _f_ | org table mark =E2=96=AFfield=E2=96=AE | ^^ _n_ ^^ " ("x" exchange-point-and-mark "exchange point/mark") ("f" (lambda (arg) (interactive "p") (when (eq 1 arg) (setq arg 2)) (org-table-end-of-field arg))) ("b" (lambda (arg) (interactive "p") (when (eq 1 arg) (setq arg 2)) (org-table-beginning-of-field arg))) ("n" next-line) ("p" previous-line) ("q" nil "cancel" :color blue)) (bind-keys :map org-mode-map :filter (org-at-table-p) ("S-SPC" . hydra-org-table-mark-field/body)) --=20 --=20 Kaushal Modi --94eb2c092f6c2d11410532c81637 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The solution was unnecessarily over-complicated.

<= /div>
Below one seems simpler and more intuitive. It requires the hydra= package.

(defun org-table-mark-field ()
=C2=A0 "Mark the current table field."
=C2=A0 (in= teractive)
=C2=A0 ;; Do not try to jump to the beginning of field= if the point is already there
=C2=A0 (when (not (looking-back &q= uot;|\\s-?"))
=C2=A0 =C2=A0 (org-table-beginning-of-field 1)= )
=C2=A0 (set-mark-command nil)
=C2=A0 (org-table-end-o= f-field 1))

(defhydra hydra-org-table-mark-field
=C2=A0 (:body-pre (org-table-mark-field)
=C2=A0 =C2=A0:c= olor pink
=C2=A0 =C2=A0:hint nil)
=C2=A0 "
=C2=A0 =C2=A0^^ =C2=A0 =C2=A0 =C2=A0_p_ = =C2=A0 =C2=A0 ^^
=C2=A0_b_ =C2=A0selection =C2=A0_f_ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | org table mark =E2=96=AFfield=E2=96=AE= |
=C2=A0 =C2=A0^^ =C2=A0 =C2=A0 =C2=A0_n_ =C2=A0 =C2=A0 ^^
=
"
=C2=A0 (&q= uot;x" exchange-point-and-mark "exchange point/mark")
<= div>=C2=A0 ("f" (lambda (arg)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(interactive "p")
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(when (eq 1 arg)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (setq arg 2))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-table-end-of= -field arg)))
=C2=A0 ("b" (lambda (arg)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(interactive "p")
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (eq 1 arg)
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0(setq arg 2))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(org-table-beginning-of-field arg)))
=C2=A0 ("n" = next-line)
=C2=A0 ("p" previous-line)
=C2=A0 = ("q" nil "cancel" :color blue))

(bind-keys
=C2=A0:map org-mode-map
=C2=A0:filter (org= -at-table-p)
=C2=A0 ("S-SPC" . hydra-org-table-mark-fie= ld/body))

--

--
Kaushal Modi

--94eb2c092f6c2d11410532c81637--