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

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

Elisp code to choose a region covering a word


From: ishi soichi
Subject: Elisp code to choose a region covering a word
Date: Thu, 18 Nov 2010 19:22:22 +0900

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

reply via email to

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