From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Problem using search-forward Date: Sun, 07 Oct 2012 20:26:15 +0200 Message-ID: <874nm6rveg.fsf@thinkpad.tsdh.de> References: <9aed3b85-f743-4bd0-994f-c44304d8078a@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1349634396 21572 80.91.229.3 (7 Oct 2012 18:26:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2012 18:26:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 20:26:43 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TKvYl-0005CL-Qp for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2012 20:26:39 +0200 Original-Received: from localhost ([::1]:35881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKvYf-0005eN-SJ for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2012 14:26:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKvYa-0005eI-KG for help-gnu-emacs@gnu.org; Sun, 07 Oct 2012 14:26:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TKvYZ-0007Tf-Mf for help-gnu-emacs@gnu.org; Sun, 07 Oct 2012 14:26:28 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:58760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKvYZ-0007Ta-G3 for help-gnu-emacs@gnu.org; Sun, 07 Oct 2012 14:26:27 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TKvYc-000585-Tf for help-gnu-emacs@gnu.org; Sun, 07 Oct 2012 20:26:30 +0200 Original-Received: from 91-67-8-160-dynip.superkabel.de ([91.67.8.160]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Oct 2012 20:26:30 +0200 Original-Received: from tsdh by 91-67-8-160-dynip.superkabel.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Oct 2012 20:26:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 91-67-8-160-dynip.superkabel.de User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) Cancel-Lock: sha1:6k4H07m8yDHLeCQfkD3GM/TC7Tg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87128 Archived-At: Bob Shanley writes: Hi Bob, > ; These do not: > ; (defun eol ( ) (end-of-line) (point)) > ; (search-forward ");" (eol)) > ; (let ( (n (eol)) ) (message "this is the value %d" n) (search-forward ");" n)) > ; They result in a Search failed: ");" and point moves to end of line > ; What am I missing? The `end-of-line' call already moves point to the end of line, thus you bound the search to the same position where it starts. Try this definition of `eol'. (defun eol () (save-excursion (end-of-line) (point))) ,----[ C-h f save-excursion RET ] | save-excursion is a special form in `C source code'. | | (save-excursion &rest BODY) | | Save point, mark, and current buffer; execute BODY; restore those things. | Executes BODY just like `progn'. | The values of point, mark and the current buffer are restored | even in case of abnormal exit (throw or error). | The state of activation of the mark is also restored. | | This construct does not save `deactivate-mark', and therefore | functions that change the buffer will still cause deactivation | of the mark at the end of the command. To prevent that, bind | `deactivate-mark' with `let'. | | If you only want to save the current buffer but not point nor mark, | then just use `save-current-buffer', or even `with-current-buffer'. `---- Bye, Tassilo