From: "Drew Adams" <drew.adams@oracle.com>
To: "'Tassilo Horn'" <tassilo@member.fsf.org>, <help-gnu-emacs@gnu.org>
Subject: RE: Elisp code to choose a region covering a word
Date: Thu, 18 Nov 2010 07:31:25 -0800 [thread overview]
Message-ID: <5CAC77A0ADDD42A39AE234AB3882D5C7@us.oracle.com> (raw)
In-Reply-To: <87ipzux26c.fsf@member.fsf.org>
What would you do it interactively? Then just do that and create a keyboard
macro.
Or look up the commands associated with the keys you use and use those commands
to define your command.
Interactively, you would just do this: `C-SPC M-f...' (This assumes
transient-mark-mode is turned on, which it is now by default.)
`C-SPC' is `set-mark-command'. But as others have pointed out, all you need in
your function is `push-mark'.
`M-f' is `forward-word'.
The mark is deactivated automatically after each command, but you can prevent
that by setting `mark-active' to non-nil.
(defun foo (n)
"Mark the next N words. N is the prefix arg."
(interactive "p")
(push-mark)
(forward-word n)
(setq mark-active t))
next prev parent reply other threads:[~2010-11-18 15:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-18 10:22 Elisp code to choose a region covering a word ishi soichi
2010-11-18 11:45 ` Tassilo Horn
2010-11-18 12:10 ` Tassilo Horn
2010-11-18 15:31 ` Drew Adams [this message]
2010-11-18 11:46 ` Deniz Dogan
2010-11-19 6:49 ` ishi soichi
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=5CAC77A0ADDD42A39AE234AB3882D5C7@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tassilo@member.fsf.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.