unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Continuing after an interactive command?
@ 2013-05-28  2:24 gentsquash
  2013-05-28  7:39 ` Thien-Thi Nguyen
       [not found] ` <mailman.502.1369726605.22516.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: gentsquash @ 2013-05-28  2:24 UTC (permalink / raw)
  To: help-gnu-emacs

How can I define a function which contains a command that
I interact with, which then continues?

I seek a function like the following, executed when in a
buffer:

  (defun foo ()
    (ns-narrow-to-region 100 200)
    (goto-char (point-min))
    (dired-jump)
    ;; This next cmd interacts with the user.
    (dired-do-query-replace-regexp FROM TO)
    ;; If the above cmd terminates normally, I'd like these
    ;; to be executed:
    (dired-find-file)
    (ns-widen)
    )

Typically, when the `dired-do-query-replace-regexp' runs,
I'll hit "!" to have it do all the replacements.  I then
would like to end up in the buffer, widened.

However, in the above function, when the
`dired-do-query-replace-regexp' terminates, it seems to
terminate `foo' as well.

                        --Jonathan


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

* Re: Continuing after an interactive command?
  2013-05-28  2:24 Continuing after an interactive command? gentsquash
@ 2013-05-28  7:39 ` Thien-Thi Nguyen
       [not found] ` <mailman.502.1369726605.22516.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2013-05-28  7:39 UTC (permalink / raw)
  To: gentsquash; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]

() gentsquash <gentsquash@gmail.com>
() Mon, 27 May 2013 19:24:54 -0700 (PDT)

     (defun foo ()
       (ns-narrow-to-region 100 200)
       (goto-char (point-min))
       (dired-jump)
       ;; This next cmd interacts with the user.
       (dired-do-query-replace-regexp FROM TO)
       ;; If the above cmd terminates normally, I'd like these
       ;; to be executed:
       (dired-find-file)
       (ns-widen)
       )

That's like leaving the house and walking around the block (complaining
loudly to annoy the neighbors) to get from the kitchen to the bathroom.
If you really must, then try:

  (ignore-errors
    (save-excursion
      (dired-do-query-replace-regexp FROM TO)))

which catches the throw out of the stateful query-replace loop and
furthermore preserves context such that ‘dired-find-file’ does not
complain.  That is like remembering to lock the door (to thwart
negative neighborly retribution) and bring a key.

But i have to wonder... Why do you treat your neighbors so?
Is it really their business that your soup is too spicy?

-- 
Thien-Thi Nguyen
GPG key: 4C807502

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Continuing after an interactive command?
       [not found] ` <mailman.502.1369726605.22516.help-gnu-emacs@gnu.org>
@ 2013-05-29  2:34   ` gentsquash
  0 siblings, 0 replies; 3+ messages in thread
From: gentsquash @ 2013-05-29  2:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hello  Thien-Thi Nguyen.

I don't understand your metaphor, but `ignore-errors' is sufficient to
do what I wanted.   Thank you.     -Jonathan


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

end of thread, other threads:[~2013-05-29  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28  2:24 Continuing after an interactive command? gentsquash
2013-05-28  7:39 ` Thien-Thi Nguyen
     [not found] ` <mailman.502.1369726605.22516.help-gnu-emacs@gnu.org>
2013-05-29  2:34   ` gentsquash

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).