From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: org-table-mark-field
Date: Fri, 13 May 2016 23:38:40 +0000 [thread overview]
Message-ID: <CAFyQvY1EdsG9Wk0bNo2FFvamEGGiaiAGwugoKK9KHK9uObo0kA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY1Pim2BNMM=ONb0OpBkSzBgSt25j4Lnin_0ykwq0jU5SQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]
Here's a minor update with a bug fix (to handle the case when the point is
at the end of a table field initially):
(defun org-table-mark-field (n)
"Mark the current table field.
If N is negative, select (- N) fields to the left of the current field,
including the current field.
If N >= 2, select (1- N) fields to the right of the current field,
including the current field.
If N is 0 or 1 (default), only the current field is selected."
(interactive "p")
(let ((bol-point (save-excursion
(beginning-of-line)
(point)))
(bof-arg 1)
(eof-arg 1)
(p (point))
bof-p eof-p)
;; Check if the point is already at the beginning of the current field.
(when (looking-back "|\\s-?" bol-point)
(setq bof-p t))
;; Check if the point is already at the end of the current field.
(when (looking-at "\\s-?|")
(setq eof-p t))
;; When selecting current field plus fields to the right
(when (>= n 2)
(setq eof-arg n))
;; When selecting current field plus fields to the left
(when (<= n -1)
(setq bof-arg (- n)))
(org-table-beginning-of-field bof-arg)
(when bof-p
(org-table-next-field))
(set-mark-command nil)
(goto-char p)
(when eof-p
(org-table-beginning-of-field 1))
(org-table-end-of-field eof-arg)
(exchange-point-and-mark)))
--
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 2061 bytes --]
next prev parent reply other threads:[~2016-05-13 23:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 23:15 org-table-mark-field Kaushal Modi
2016-05-13 23:38 ` Kaushal Modi [this message]
2016-05-14 7:10 ` org-table-mark-field Kaushal Modi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFyQvY1EdsG9Wk0bNo2FFvamEGGiaiAGwugoKK9KHK9uObo0kA@mail.gmail.com \
--to=kaushal.modi@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.