all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Query-replace is misbehaving!
@ 2002-09-04 22:39 Siegfried Heintze
  2002-09-04 23:07 ` lawrence mitchell
       [not found] ` <gexd9.169256$8aG1.117958@news01.bloor.is.net.cable.rogers.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Siegfried Heintze @ 2002-09-04 22:39 UTC (permalink / raw)


I need to surpress the prompt so I pass nil for query but it still queries!
I am using emacs versino 21.2.1 on NT.


      (perform-replace "\\\\\\\\progra"                                  ;
from-string
         (concat (colonize *msvcdrive*) "\\\\\\\\progra")  ; replacements
         (point-min)                                       ; start
         (point-max)                                       ; end
         nil                                               ; query-flag
         t                                                 ; regexp
         nil))                                             ; delimited flags

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

* Re: Query-replace is misbehaving!
  2002-09-04 22:39 Query-replace is misbehaving! Siegfried Heintze
@ 2002-09-04 23:07 ` lawrence mitchell
       [not found] ` <gexd9.169256$8aG1.117958@news01.bloor.is.net.cable.rogers.com>
  1 sibling, 0 replies; 5+ messages in thread
From: lawrence mitchell @ 2002-09-04 23:07 UTC (permalink / raw)


Siegfried Heintze wrote:

> I need to surpress the prompt so I pass nil for query but it
> still queries!  I am using emacs versino 21.2.1 on NT.

Since you want to suppress the prompt, I guess you want to use
`perform-replace' in a lisp program, rather than interactively
(if this is not the case, I'm not sure exactly where your problem
is).  However, this is probably not a good idea.
Indeed, the docstring of `perform-replace' explicitly recommends
against its usage in lisp programs, and gives a recommended
alternative.

/----[ C-h f perform-replace RET ]
| [...]
| Subroutine of `query-replace'.  Its complexity handles interactive queries.
| Don't use this in your own program unless you want to query and set the mark
| just as `query-replace' does.  Instead, write a simple loop like this:
|
|   (while (re-search-forward "foo[ \t]+bar" nil t)
|     (replace-match "foobar" nil nil))
|
| which will run faster and probably do exactly what you want.
| [...]
\----

>       (perform-replace "\\\\\\\\progra"                    ; from-string
>          (concat (colonize *msvcdrive*) "\\\\\\\\progra")  ; replacements
>          (point-min)                                       ; start
>          (point-max)                                       ; end
>          nil                                               ; query-flag
>          t                                                 ; regexp
>          nil))                                             ; delimited flags

Hence, you would probably want to write something like:
(save-excursion                       ; restore `point' to its
                                      ; original position after
                                      ; completion
  (goto-char (point-min))
  (while (re-search-forward
          "\\\\\\\\progra"            ; search forward for this regexp
          nil                         ; don't set a bound on the search
          t)                          ; don't error if search fails
    (replace-match
     (concat (colonize *msvcdrive*)
             "\\\\\\\\progra"))))     ; replace the matched string
-- 
lawrence mitchell <wence@gmx.li>

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

* Re: Query-replace is misbehaving!
       [not found] ` <gexd9.169256$8aG1.117958@news01.bloor.is.net.cable.rogers.com>
@ 2002-09-05  4:32   ` Siegfried Heintze
  2002-09-05  4:59     ` Henrik Enberg
  2002-09-05  9:20     ` John McCabe
  0 siblings, 2 replies; 5+ messages in thread
From: Siegfried Heintze @ 2002-09-05  4:32 UTC (permalink / raw)


Is there an error in the documentation at
http://www.gnu.org/manual/elisp-manual-21-2.8/html_mono/elisp.html?

If so, were is the correct documentation?
    Thanks,
                Siegfried
----------------------------------------------------------------------------
------------------

Function: perform-replace from-string replacements start end query-flag
regexp-flag delimited-flag &optional repeat-count map
This function is the guts of query-replace and related commands. It searches
for occurrences of from-string in the text between positions start and end
and replaces some or all of them. If start is nil, point is used instead,
and the buffer's end is used for end.

If query-flag is nil, it replaces all occurrences; otherwise, it asks the
user what to do about each one.

If regexp-flag is non-nil, then from-string is considered a regular
expression; otherwise, it must match literally. If delimited-flag is
non-nil, then only replacements surrounded by word boundaries are
considered.

The argument replacements specifies what to replace occurrences with. If it
is a string, that string is used. It can also be a list of strings, to be
used in cyclic order.

If replacements is a cons cell, (function . data), this means to call
function after each match to get the replacement text. This function is
called with two arguments: data, and the number of replacements already
made.

If repeat-count is non-nil, it should be an integer. Then it specifies how
many times to use each of the strings in the replacements list before
advancing cyclicly to the next one.

If from-string contains upper-case letters, then perform-replace binds
case-fold-search to nil, and it uses the replacements without altering the
case of them.

Normally, the keymap query-replace-map defines the possible user responses
for queries. The argument map, if non-nil, is a keymap to use instead of
query-replace-map.

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

* Re: Query-replace is misbehaving!
  2002-09-05  4:32   ` Siegfried Heintze
@ 2002-09-05  4:59     ` Henrik Enberg
  2002-09-05  9:20     ` John McCabe
  1 sibling, 0 replies; 5+ messages in thread
From: Henrik Enberg @ 2002-09-05  4:59 UTC (permalink / raw)


"Siegfried Heintze" <siegfried@heintze.com> writes:

> If so, were is the correct documentation?

It is at the following key combo:

C-h f query-replace RET

Emacs is the self-documenting editor.

-- 
Booting... /vmemacs.el

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

* Re: Query-replace is misbehaving!
  2002-09-05  4:32   ` Siegfried Heintze
  2002-09-05  4:59     ` Henrik Enberg
@ 2002-09-05  9:20     ` John McCabe
  1 sibling, 0 replies; 5+ messages in thread
From: John McCabe @ 2002-09-05  9:20 UTC (permalink / raw)


On Wed, 4 Sep 2002 22:32:06 -0600, "Siegfried Heintze"
<siegfried@heintze.com> wrote:

>Is there an error in the documentation at
>http://www.gnu.org/manual/elisp-manual-21-2.8/html_mono/elisp.html?


It looks that way. From replace.el:

(defun perform-replace (from-string replacements 
		        query-flag regexp-flag delimited-flag
			&optional repeat-count map start end)

Report it to the FSF as a documentation bug to bug-gnu-emacs@gnu.org.

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

end of thread, other threads:[~2002-09-05  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-04 22:39 Query-replace is misbehaving! Siegfried Heintze
2002-09-04 23:07 ` lawrence mitchell
     [not found] ` <gexd9.169256$8aG1.117958@news01.bloor.is.net.cable.rogers.com>
2002-09-05  4:32   ` Siegfried Heintze
2002-09-05  4:59     ` Henrik Enberg
2002-09-05  9:20     ` John McCabe

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.