From: Jambunathan K <kjambunathan@gmail.com>
To: ishi soichi <soichi777@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
Date: Sun, 29 Jul 2012 11:08:15 +0530 [thread overview]
Message-ID: <81boizi0u0.fsf@gmail.com> (raw)
In-Reply-To: <CAEjRLuShrmpQq_2TZ9BYimY-7RtyRU630p1g80ZQ=UV_K3iVSg@mail.gmail.com> (ishi soichi's message of "Sun, 29 Jul 2012 10:38:00 +0900")
ishi soichi <soichi777@gmail.com> writes:
> Emacs23
>
> This should be simple for many of you.
> I am trying to develop a function that searches a word definition
> stored in a dict file.
>
> As you can see, when reading a text, you might need to look for
> additional information about the encountered word.
> The following function searches the information for the word in the
> region.
>
>
> (defvar sfl-dictionary-directory "~/Dropbox/ElmLab/dict")
> (defvar sfl-base-dict-file "test5.txt")
>
> (defun sfl-search-word-meaning ()
> (interactive)
> (let ((word
> (buffer-substring (region-beginning) (region-end)))
> (result))
Look at "r" construct of C-h f interactive.
> (with-current-buffer
> (find-file (concat sfl-dictionary-directory "/"
> sfl-base-dict-file))
> (goto-char (point-min))
> (search-forward word)
> (set-marker (make-marker) (beginning-of-line))
> (goto-char (end-of-line))
> (setq result (buffer-substring (region-beginning) (region-end)))
> (message result))))
To take a `buffer-substring' you don't need a region or set markers.
Simply any two points will do. How about
(buffer-substring-no-properties (point-at-bol) (point-at-eol))
If you are searching, and have a successful match you can do for
example,
(buffer-substring-no-properties (match-beginning 0) (match-end 0))
I am not trying to solve your particular problem. I am just giving
hints for you to proceed ahead.
> But this gives an error
>
> save-current-buffer: Wrong type argument: integer-or-marker-p, nil
>
> It looks like (set-marker ... part is doing something wrong.
>
> Could anyone point out the mistake I am making?
>
> soichi
>
>
--
next prev parent reply other threads:[~2012-07-29 5:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-29 1:38 set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil ishi soichi
2012-07-29 5:38 ` Jambunathan K [this message]
2012-07-29 18:35 ` Andreas Röhler
2012-07-30 5:10 ` Thien-Thi Nguyen
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=81boizi0u0.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=soichi777@gmail.com \
/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.