From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ishi soichi Newsgroups: gmane.emacs.help Subject: Elisp code to choose a region covering a word Date: Thu, 18 Nov 2010 19:22:22 +0900 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd73180579bdb0495512a22 X-Trace: dough.gmane.org 1290075787 1998 80.91.229.12 (18 Nov 2010 10:23:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 18 Nov 2010 10:23:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 18 11:23:02 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 1PJ1dt-000186-M8 for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Nov 2010 11:23:02 +0100 Original-Received: from localhost ([127.0.0.1]:35866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ1ds-0005OA-HZ for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Nov 2010 05:23:00 -0500 Original-Received: from [140.186.70.92] (port=52617 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ1dI-0005O1-G6 for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 05:22:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ1dH-0003bh-7C for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 05:22:24 -0500 Original-Received: from mail-px0-f169.google.com ([209.85.212.169]:54390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ1dG-0003bN-Se for help-gnu-emacs@gnu.org; Thu, 18 Nov 2010 05:22:23 -0500 Original-Received: by pxi12 with SMTP id 12so966781pxi.0 for ; Thu, 18 Nov 2010 02:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=iYfhKYpycmp9wwMdmU9GdBv9dYOoE7KtnRlYKNZ8QiA=; b=l0oVddd5V56V94rJ3M5uGpkqFlDJMtaH2Ry7YV+RXZr3I4r5gwFNDwz3PsFqyXq2L0 QqoWZxDcfTI2G8UO1urznYqezXWIKB1xc0RCvUz+deJTDtyZUjDOcmpbRvkCN1Q2vBNf FSRrBncUVVtAiOa5dlqVgVz8LGK4P/iUB/59E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=gTBFadUj3p8yrD7xH+HTQy853OkSbZ5Q8JIk3gYNOJdSekJH0KjQhofG6BbeosW3wR WPlCV9G9osWdpV5H2CdtghjW2nwassMXpDugnbuQmOk58hp1eLC1Jn/nKt9ieNOOrSgt mvwHIN04N+Wjd7E+lN1MzNqmZvlDYeU67qDTk= Original-Received: by 10.142.128.19 with SMTP id a19mr336696wfd.323.1290075742116; Thu, 18 Nov 2010 02:22:22 -0800 (PST) Original-Received: by 10.142.214.6 with HTTP; Thu, 18 Nov 2010 02:22:22 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:75395 Archived-At: --000e0cd73180579bdb0495512a22 Content-Type: text/plain; charset=ISO-8859-1 I am trying to develop an elisp program that sets a region covering a word in text. I am a newbie in elisp so please be adviced. For example, we have a text like... ---------------------------- In late 2008, it (<=point here!!!) reduced its interest to 13 percent to raise much-needed cash, in a move that many saw as the beginning of a distancing of the long-time partners. Ford's stake fell further to 11 percent when Mazda issued new shares last year. ---------------------- by tying "C-f" (I know it's not a good idea to override "C-f". It's a test), the region is set to be ---------------------------- In late 2008, it (Mark here!!!=>) reduced(<=point here!!!) its interest to 13 percent to raise much-needed cash, in a move that many saw as the beginning of a distancing of the long-time partners. Ford's stake fell further to 11 percent when Mazda issued new shares last year. ---------------------- by typing "C-f" again, the region would be ---------------------------- In late 2008, it reduced (Mark here!!!=>)its(<=point here!!!) interest to 13 percent to raise much-needed cash, in a move that many saw as the beginning of a distancing of the long-time partners. Ford's stake fell further to 11 percent when Mazda issued new shares last year. ---------------------- and so on. Every time we execute the interactive function, each individual word is chosen. So I tried, ;;------------------------- (defun word-choice () (interactive) (let (foo) (re-search-forward "\\w") (goto-char (match-beginning 0)) (setq foo (point-marker)) (re-search-forward "\\s ") (goto-char (match-beginning 0)) )) (define-key global-map "\C-f" 'word-choice) ;;--------------------------- Obviously it does not do the job. I don't think it sets a mark at all. Maybe the use of "point-marker" is wrong. Could anyone help me for it? soichi --000e0cd73180579bdb0495512a22 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I am trying to develop an elisp program that sets a region covering a word = in text.
I am a newbie in elisp so please be adviced.

For example, we have a text like...

------= ----------------------
In late 2008, it (<=3Dpoint here!!= !) =A0reduced its interest to 13 percent to raise much-needed cash, in a mo= ve that many saw as the beginning of a distancing of the long-time partners= . Ford's stake fell further to 11 percent when Mazda issued new shares = last year.
----------= ------------

by tying "C-f" (I know it's not a good idea = to override "C-f". It's a test), the region is set to be

----------------------------
In late 2008, it (Mark here!= !!=3D>) reduced(<=3Dpoint here!!!) its interest to 13 percent to rais= e much-needed cash, in a move that many saw as the beginning of a distancin= g of the long-time partners. Ford's stake fell further to 11 percent wh= en Mazda issued new shares last year.
----------------------

by typing "C-f" again, th= e region would be=A0

----------------------------
In late 2008, = it reduced=A0(Mark here!!!=3D>)its<= /span>(<=3Dpoint here!!!)=A0interest to 13 percent to ra= ise much-needed cash, in a move that many saw as the beginning of a distanc= ing of the long-time partners. Ford's stake fell further to 11 percent = when Mazda issued new shares last year.
----------------------

and so on. =A0Every time we execute= the interactive function, each individual word is chosen. =A0So I tried,

;;-------------------------<= /span>
(defun word-choice ()
=A0=A0(= interactive)
=A0=A0(let =A0(foo)
(re-s= earch-forward "\\w")
(goto-char (match-beginning 0))
(setq foo (point-marker))
(re-search-forward "\\s ")
(goto-char (match-beginning 0))
))
(define-key global-map "\C-f" 'word-choice)=
;;---------------------------

Obviously it does not do= the job. =A0I don't think it sets a mark at all. =A0Maybe the use of &= quot;point-marker" is wrong.
Could anyone help me for it?
=

soichi
--000e0cd73180579bdb0495512a22--