# HG changeset patch # User Stefan Monnier # Date 1234023876 0 # Node ID 76d5e3386e2310dba2907779bf32d228776bf5c5 # Parent 5cb3814c8e09b629375c99c96c44b86d0859fe51 (server-execute): Enable quit. diff -r 5cb3814c8e09 -r 76d5e3386e23 lisp/ChangeLog --- a/lisp/ChangeLog Sat Feb 07 15:29:11 2009 +0000 +++ b/lisp/ChangeLog Sat Feb 07 16:24:36 2009 +0000 @@ -1,3 +1,7 @@ +2009-02-07 Stefan Monnier + + * server.el (server-execute): Enable quit. + 2009-02-07 Andreas Schwab * image-mode.el (image-mode): Always set image-type. @@ -19,8 +23,8 @@ * mail/rmailedit.el (rmail-cease-edit): narrow-to-region before extracting mail message headers. Use encode-coding-region instead - of insert-buffer-substring for re-encoding edited message. Add - qp/b64 encoding only after text was encoded. + of insert-buffer-substring for re-encoding edited message. + Add qp/b64 encoding only after text was encoded. 2009-02-07 Eli Zaretskii diff -r 5cb3814c8e09 -r 76d5e3386e23 lisp/server.el --- a/lisp/server.el Sat Feb 07 15:29:11 2009 +0000 +++ b/lisp/server.el Sat Feb 07 16:24:36 2009 +0000 @@ -1036,40 +1036,48 @@ (error (server-return-error proc err)))) (defun server-execute (proc files nowait commands dontkill frame tty-name) - (condition-case err - (let* ((buffers - (when files - (run-hooks 'pre-command-hook) - (prog1 (server-visit-files files proc nowait) - (run-hooks 'post-command-hook))))) + ;; This is run from timers and process-filters, i.e. "asynchronously". + ;; But w.r.t the user, this is not really asynchronous since the timer + ;; is run after 0s and the process-filter is run in response to the + ;; user running `emacsclient'. So it is OK to override the + ;; inhibit-quit flag, which is good since `commands' (as well as + ;; find-file-noselect via the major-mode) can run arbitrary code, + ;; including code that needs to wait. + (with-local-quit + (condition-case err + (let* ((buffers + (when files + (run-hooks 'pre-command-hook) + (prog1 (server-visit-files files proc nowait) + (run-hooks 'post-command-hook))))) - (mapc 'funcall (nreverse commands)) + (mapc 'funcall (nreverse commands)) - ;; Delete the client if necessary. - (cond - (nowait - ;; Client requested nowait; return immediately. - (server-log "Close nowait client" proc) - (server-delete-client proc)) - ((and (not dontkill) (null buffers)) - ;; This client is empty; get rid of it immediately. - (server-log "Close empty client" proc) - (server-delete-client proc))) - (cond - ((or isearch-mode (minibufferp)) - nil) - ((and frame (null buffers)) - (message "%s" (substitute-command-keys - "When done with this frame, type \\[delete-frame]"))) - ((not (null buffers)) - (server-switch-buffer (car buffers) nil (cdr (car files))) - (run-hooks 'server-switch-hook) - (unless nowait + ;; Delete the client if necessary. + (cond + (nowait + ;; Client requested nowait; return immediately. + (server-log "Close nowait client" proc) + (server-delete-client proc)) + ((and (not dontkill) (null buffers)) + ;; This client is empty; get rid of it immediately. + (server-log "Close empty client" proc) + (server-delete-client proc))) + (cond + ((or isearch-mode (minibufferp)) + nil) + ((and frame (null buffers)) (message "%s" (substitute-command-keys - "When done with a buffer, type \\[server-edit]"))))) - (when (and frame (null tty-name)) - (server-unselect-display frame))) - (error (server-return-error proc err)))) + "When done with this frame, type \\[delete-frame]"))) + ((not (null buffers)) + (server-switch-buffer (car buffers) nil (cdr (car files))) + (run-hooks 'server-switch-hook) + (unless nowait + (message "%s" (substitute-command-keys + "When done with a buffer, type \\[server-edit]"))))) + (when (and frame (null tty-name)) + (server-unselect-display frame))) + (error (server-return-error proc err))))) (defun server-return-error (proc err) (ignore-errors