* set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
@ 2012-07-29 1:38 ishi soichi
2012-07-29 5:38 ` Jambunathan K
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ishi soichi @ 2012-07-29 1:38 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]
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))
(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))))
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
[-- Attachment #2: Type: text/html, Size: 1677 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
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
2012-07-29 18:35 ` Andreas Röhler
2012-07-30 5:10 ` Thien-Thi Nguyen
2 siblings, 0 replies; 4+ messages in thread
From: Jambunathan K @ 2012-07-29 5:38 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
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
>
>
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
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
@ 2012-07-29 18:35 ` Andreas Röhler
2012-07-30 5:10 ` Thien-Thi Nguyen
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2012-07-29 18:35 UTC (permalink / raw)
To: help-gnu-emacs
Am 29.07.2012 03:38, schrieb ishi soichi:
> 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))
> (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))))
>
>
> But this gives an error
>
> save-current-buffer: Wrong type argument: integer-or-marker-p, nil
IMO this error is raised from inside `with-current-buffer'.
Seems it doesn't get the return value it expects, which looks like a bug for me,
as docstring doesn't mention a required return value, .
The result of last form "message" will be a string, which seems not being accepted.
Andreas
>
> It looks like (set-marker ... part is doing something wrong.
>
> Could anyone point out the mistake I am making?
>
> soichi
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
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
2012-07-29 18:35 ` Andreas Röhler
@ 2012-07-30 5:10 ` Thien-Thi Nguyen
2 siblings, 0 replies; 4+ messages in thread
From: Thien-Thi Nguyen @ 2012-07-30 5:10 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
() ishi soichi <soichi777@gmail.com>
() Sun, 29 Jul 2012 10:38:00 +0900
Could anyone point out the mistake I am making?
Well, one mistake is posting HTML. I suppose that would be a "misgive",
actually. There are others... this means the primary mistake is to ask
for the (singular) mistake.
But enough negativity. A better question is: What can the programmer do
to explore this point in the behavior space, to find a path towards more
desirable behavior? One idea: do ‘M-x toggle-debug-on-error RET’ first.
--
Thien-Thi Nguyen ..................................... GPG key: 4C807502
. NB: ttn at glug dot org is not me .
. (and has not been since 2007 or so) .
. ACCEPT NO SUBSTITUTES .
........... please send technical questions to mailing lists ...........
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-30 5:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-07-29 18:35 ` Andreas Röhler
2012-07-30 5:10 ` Thien-Thi Nguyen
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.