help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stop a macro from terminating on beep


From: Evans Winner
Subject: Re: Stop a macro from terminating on beep
Date: Thu, 02 Apr 2009 00:43:13 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

kazza765 <lowe.john@gmail.com> writes:

    So, basically I'm trying to do what the title
    suggests. I have a macro that searches through a file,
    finds an instance of the text I'm looking for, and
    deletes the next three lines. I then have another macro
    that runs \C-u10000000\C-[xname-of-macro
    \C-x\C-s\C-x\C-c , so I want it to exit after tha macro
    is finished. This works fine in macros that don't cause
    a beep, and I can run them using emacs -f name-of-macro,
    but the system beep that occurs when this macro can't
    find any more matching patterns causes the macro to
    abort, and doesn't execute the save and quit
    commands. Is there any way around this? Or is there any
    better way to execute a search macro an unknown number
    of times and still have emacs exit afterwards?

This may not be helpful, because I am not sure I understand
what you are asking.  When you say ``macro'' I think you are
talking about an interactive search-and-replace text
function of some kind.  Is this a function you are writing?
If so, it might be helpful to note that some of the search
functions take arguments like a limit, or what to do on
error.  For instance:

,----[ C-h f search-forward RET ]
| search-forward is an interactive built-in function in `C source code'.
| 
| It is bound to <find>.
| 
| (search-forward STRING &optional BOUND NOERROR COUNT)
| 
| Search forward from point for STRING.
| Set point to the end of the occurrence found, and return point.
| An optional second argument bounds the search; it is a buffer position.
| The match found must not extend after that position.  A value of nil is
|   equivalent to (point-max).
| Optional third argument, if t, means if fail just return nil (no error).
|   If not nil and not t, move to limit of search and return nil.
| Optional fourth argument is repeat count--search for successive occurrences.
| 
| Search case-sensitivity is determined by the value of the variable
| `case-fold-search', which see.
| 
| See also the functions `match-beginning', `match-end' and `replace-match'.
`----

So something like--

,----
| (search-forward "nonexistent string" (point-max) t)
`----

--won't signal a "beep," as I understand it.  

Anyway if you're using lisp, you might post your code; as
for keyboard macros, I don't know much about them, if that's
what you're using, but someone might.  You could post more
specific details.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]