[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (goto-char ...) error
From: |
Deniz Dogan |
Subject: |
Re: (goto-char ...) error |
Date: |
Tue, 22 Feb 2011 18:31:03 +0100 |
2011/2/22 ken <gebser@mousecar.com>:
> Performing one search, I save the result with
>
> (setq ptname (re-search-forward ...))
>
> Then I want to back up one character and perform another search, so I do
>
> (goto-char (- ptname 1))
>
> But this pukes an error. What's unkosher here?
>
It's much easier if you tell us what the error is.
I tried to reproduce the problem using this code:
;; search for "a"
(let ((ptname (re-search-forward "a" nil t)))
(when ptname
(goto-char (- ptname 1))))
It all depends on how you use re-search-forward. As you can see in my
example, I pass t as the third argument meaning "don't error if you
can't find it, just return nil". I then make sure that ptname is
non-nil before I try to act on it using `-', otherwise we would be
doing (- nil 1) which makes no sense.
--
Deniz Dogan
Message not available