From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Elisp code to choose a region covering a word Date: Thu, 18 Nov 2010 07:31:25 -0800 Message-ID: <5CAC77A0ADDD42A39AE234AB3882D5C7@us.oracle.com> References: <87r5eix3cx.fsf@member.fsf.org> <87ipzux26c.fsf@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1290094419 28662 80.91.229.12 (18 Nov 2010 15:33:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 18 Nov 2010 15:33:39 +0000 (UTC) To: "'Tassilo Horn'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 18 16:33:34 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PJ6UM-0002pK-Vp for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Nov 2010 16:33:31 +0100 Original-Received: from localhost ([127.0.0.1]:36569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ6UL-0002n8-JY for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Nov 2010 10:33:29 -0500 Original-Received: from [140.186.70.92] (port=35799 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ6Tu-0002mA-Ql for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 10:33:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ6Tt-0003Ux-SQ for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 10:33:02 -0500 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:63986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ6Tt-0003Ug-Ly for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 10:33:01 -0500 Original-Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oAIFWtFg021685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Nov 2010 15:32:57 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id oAI9e62I029576; Thu, 18 Nov 2010 15:32:54 GMT Original-Received: from abhmt017.oracle.com by acsmt355.oracle.com with ESMTP id 789169011290094288; Thu, 18 Nov 2010 07:31:28 -0800 Original-Received: from dradamslap1 (/10.159.234.244) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 18 Nov 2010 07:31:28 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87ipzux26c.fsf@member.fsf.org> thread-index: AcuHGawCy4un5moNQmW+St7ukL/qRwAGm3MQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75404 Archived-At: 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))