all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ishi soichi <soichi777@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Elisp code to choose a region covering a word
Date: Thu, 18 Nov 2010 19:22:22 +0900	[thread overview]
Message-ID: <AANLkTik43mPxWFF+dF_cF5DcxJR+nGd_h1JEF3iyxasQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 12206 bytes --]

             reply	other threads:[~2010-11-18 10:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 10:22 ishi soichi [this message]
2010-11-18 11:45 ` Elisp code to choose a region covering a word Tassilo Horn
2010-11-18 12:10   ` Tassilo Horn
2010-11-18 15:31     ` Drew Adams
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=AANLkTik43mPxWFF+dF_cF5DcxJR+nGd_h1JEF3iyxasQ@mail.gmail.com \
    --to=soichi777@gmail.com \
    --cc=help-gnu-emacs@gnu.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.