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

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

Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p


From: Jambunathan K
Subject: Re: set-marker and make-marker, Wrong type argument: integer-or-marker-p, nil
Date: Sun, 29 Jul 2012 11:08:15 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (windows-nt)

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
>
>

-- 



reply via email to

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