help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Elisp code to choose a region covering a word


From: Drew Adams
Subject: RE: Elisp code to choose a region covering a word
Date: Thu, 18 Nov 2010 07:31:25 -0800

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))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]