Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem using search-forward
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bob Shanley  
View profile  
 More options Oct 5 2012, 1:46 pm
Newsgroups: gnu.emacs.help
From: Bob Shanley <rjshanle...@gmail.com>
Date: Fri, 5 Oct 2012 10:46:41 -0700 (PDT)
Local: Fri, Oct 5 2012 1:46 pm
Subject: Problem using search-forward
stringToFind("this is a string");
; Given the above string and point positioned at the beginning of the line
; I want to move point to right after the ";"
; These work:
;   (search-forward ");")
;   (let ( (n 34) ) (search-forward ");" n))
; 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?
;
Thanks for the help

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Oct 7 2012, 2:26 pm
Newsgroups: gnu.emacs.help
From: Tassilo Horn <t...@gnu.org>
Date: Sun, 07 Oct 2012 20:26:15 +0200
Local: Sun, Oct 7 2012 2:26 pm
Subject: Re: Problem using search-forward

Bob Shanley <rjshanle...@gmail.com> 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Abrahamsen  
View profile  
 More options Oct 8 2012, 12:10 am
Newsgroups: gnu.emacs.help
From: Eric Abrahamsen <e...@ericabrahamsen.net>
Date: Mon, 08 Oct 2012 12:10:21 +0800
Local: Mon, Oct 8 2012 12:10 am
Subject: Re: Problem using search-forward

I may be missing something here, but isn't this what (point-at-eol) does?

--
GNU Emacs 24.2.50.1 (i686-pc-linux-gnu, GTK+ Version 3.4.4)
 of 2012-10-03 on pellet

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »