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

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

[patch] comint-redirect-send-command-to-process changes current buffer


From: news-spam
Subject: [patch] comint-redirect-send-command-to-process changes current buffer
Date: 18 Jan 2002 17:58:14 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

In Emacs 21.1, calling comint-redirect-send-command-to-process has the
undocumented side effect of changing the current buffer to the process
buffer (ie. the buffer given by either the process argument if it is a
buffer or the value of (process-buffer process) if it is a process).
I think that this is a bug: the following patch fixes it by changing
`set-buffer' to `with-current-buffer'.


diff -u /usr/local/share/emacs/21.1/lisp/comint.el\~ 
/usr/local/share/emacs/21.1/lisp/comint.el
--- /usr/local/share/emacs/21.1/lisp/comint.el~ Tue Sep 11 09:40:08 2001
+++ /usr/local/share/emacs/21.1/lisp/comint.el  Fri Jan 18 17:44:30 2002
@@ -3068,52 +3068,52 @@
                           process))
         (proc (get-buffer-process process-buffer)))
     ;; Change to the process buffer
-    (set-buffer process-buffer)
+    (with-current-buffer process-buffer
 
-    ;; Make sure there's a prompt in the current process buffer
-    (and comint-redirect-perform-sanity-check
-        (save-excursion
-          (goto-char (point-max))
-          (or (re-search-backward comint-prompt-regexp nil t)
-              (error "No prompt found or `comint-prompt-regexp' not set 
properly"))))
+      ;; Make sure there's a prompt in the current process buffer
+      (and comint-redirect-perform-sanity-check
+          (save-excursion
+            (goto-char (point-max))
+            (or (re-search-backward comint-prompt-regexp nil t)
+                (error "No prompt found or `comint-prompt-regexp' not set 
properly"))))
 
-    ;;;;;;;;;;;;;;;;;;;;;
-    ;; Set up for redirection
-    ;;;;;;;;;;;;;;;;;;;;;
-    (comint-redirect-setup
-     ;; Output Buffer
-     output-buffer
-     ;; Comint Buffer
-     (current-buffer)
-     ;; Finished Regexp
-     comint-prompt-regexp
-     ;; Echo input
-     echo)
+      ;;;;;;;;;;;;;;;;;;;;;
+      ;; Set up for redirection
+      ;;;;;;;;;;;;;;;;;;;;;
+      (comint-redirect-setup
+       ;; Output Buffer
+       output-buffer
+       ;; Comint Buffer
+       (current-buffer)
+       ;; Finished Regexp
+       comint-prompt-regexp
+       ;; Echo input
+       echo)
 
-    ;;;;;;;;;;;;;;;;;;;;;
-    ;; Set the filter
-    ;;;;;;;;;;;;;;;;;;;;;
-    ;; Save the old filter
-    (setq comint-redirect-original-filter-function
-         (process-filter proc))
-    (set-process-filter proc 'comint-redirect-filter)
+      ;;;;;;;;;;;;;;;;;;;;;
+      ;; Set the filter
+      ;;;;;;;;;;;;;;;;;;;;;
+      ;; Save the old filter
+      (setq comint-redirect-original-filter-function
+           (process-filter proc))
+      (set-process-filter proc 'comint-redirect-filter)
 
-    ;;;;;;;;;;;;;;;;;;;;;
-    ;; Send the command
-    ;;;;;;;;;;;;;;;;;;;;;
-    (process-send-string
-     (current-buffer)
-     (concat command "\n"))
+      ;;;;;;;;;;;;;;;;;;;;;
+      ;; Send the command
+      ;;;;;;;;;;;;;;;;;;;;;
+      (process-send-string
+       (current-buffer)
+       (concat command "\n"))
 
-    ;;;;;;;;;;;;;;;;;;;;;
-    ;; Show the output
-    ;;;;;;;;;;;;;;;;;;;;;
-    (or no-display
-        (display-buffer
-         (get-buffer-create
-          (if (listp output-buffer)
-              (car output-buffer)
-            output-buffer))))))
+      ;;;;;;;;;;;;;;;;;;;;;
+      ;; Show the output
+      ;;;;;;;;;;;;;;;;;;;;;
+      (or no-display
+         (display-buffer
+          (get-buffer-create
+           (if (listp output-buffer)
+               (car output-buffer)
+             output-buffer)))))))
 
 ;;;###autoload
 (defun comint-redirect-results-list (command regexp regexp-group)




-- 
Gareth Jones <news-reply@referential.org.uk>
Imaging Science and Biomedical Engineering
University of Manchester



reply via email to

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