all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to search whole buffer?
@ 2009-04-22  9:14 Ulrich Scholz
  2009-04-22 10:39 ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Scholz @ 2009-04-22  9:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hi, I'm using search-forward to search and replace strings.

(defun my-replace nil "change escape sequences to umlauts"
  (interactive)
   (while (search-forward "<DF>" nil t)
           (replace-match "ß" nil nil))
)

But that search does not search the whole buffer.  In particular, if I
perform two subsequent searches then the second does not find
anything.  So either I'm looking for something like
search-buffer (which I did not find yet) or for a method to set the
begin of the search to the first character of the current buffer.
(I've had a look at search but there was no documentation)

Thanks,

Ulrich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to search whole buffer?
  2009-04-22  9:14 How to search whole buffer? Ulrich Scholz
@ 2009-04-22 10:39 ` Tassilo Horn
  2009-04-22 10:51   ` Tassilo Horn
       [not found]   ` <mailman.5793.1240397484.31690.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Tassilo Horn @ 2009-04-22 10:39 UTC (permalink / raw)
  To: help-gnu-emacs

Ulrich Scholz <d7@thispla.net> writes:

Hi Ulrich,

what you want is this:

--8<---------------cut here---------------start------------->8---
(defun my-replace ()
  "change escape sequences to umlauts"
  (interactive)
  (save-excursion
    (goto-char 1)
    (while (search-forward "ß" nil t)
      (replace-match "ß" nil nil))))
--8<---------------cut here---------------end--------------->8---

The `save-excursion' takes care that point is on the same position after
the replace and (goto-char 1) sets the point to the first position in
the buffer, so that the replace is done in the whole buffer.

HTH,
Tassilo
-- 
A morning without coffee is like something without something else.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to search whole buffer?
  2009-04-22 10:39 ` Tassilo Horn
@ 2009-04-22 10:51   ` Tassilo Horn
       [not found]   ` <mailman.5793.1240397484.31690.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2009-04-22 10:51 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn <tassilo@member.fsf.org> writes:

> Ulrich Scholz <d7@thispla.net> writes:
>
> Hi Ulrich,
>
> what you want is this:
>
> (defun my-replace ()
>   "change escape sequences to umlauts"
>   (interactive)
>   (save-excursion
>     (goto-char 1)
>     (while (search-forward "ß" nil t)
                              ^

Ups, while testing I replaced the <DF> with ß. ;-)

>       (replace-match "ß" nil nil))))

Bye,
Tassilo
-- 
Chuck Norris' sperm can be seen with the naked eye. Each one is the size of a quarter. 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to search whole buffer?
       [not found]   ` <mailman.5793.1240397484.31690.help-gnu-emacs@gnu.org>
@ 2009-04-22 12:15     ` d7
  0 siblings, 0 replies; 4+ messages in thread
From: d7 @ 2009-04-22 12:15 UTC (permalink / raw)
  To: help-gnu-emacs

Great! Thanks!

Ulrich



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-22 12:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22  9:14 How to search whole buffer? Ulrich Scholz
2009-04-22 10:39 ` Tassilo Horn
2009-04-22 10:51   ` Tassilo Horn
     [not found]   ` <mailman.5793.1240397484.31690.help-gnu-emacs@gnu.org>
2009-04-22 12:15     ` d7

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.