From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bojohan+news@dd.chalmers.se (Johan =?utf-8?Q?Bockg=C3=A5rd?=) Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: 23.0.50; `read-event' changes `current-buffer' Date: Sat, 03 Nov 2007 18:14:16 +0100 Message-ID: References: <87abpvq4k9.fsf@localhorst.mine.nu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1194110114 25355 80.91.229.12 (3 Nov 2007 17:15:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2007 17:15:14 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 03 18:15:17 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IoMaa-0000ik-R4 for ged-emacs-devel@m.gmane.org; Sat, 03 Nov 2007 18:15:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoMaQ-0002jk-Gj for ged-emacs-devel@m.gmane.org; Sat, 03 Nov 2007 13:15:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IoMaN-0002fo-5K for emacs-devel@gnu.org; Sat, 03 Nov 2007 13:15:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IoMaI-0002T7-5M for emacs-devel@gnu.org; Sat, 03 Nov 2007 13:15:02 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoMaI-0002Se-0h for emacs-devel@gnu.org; Sat, 03 Nov 2007 13:14:58 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IoMaF-0005us-6t for emacs-devel@gnu.org; Sat, 03 Nov 2007 13:14:55 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IoMZx-0005Rp-Lb for emacs-devel@gnu.org; Sat, 03 Nov 2007 17:14:37 +0000 Original-Received: from remote4.student.chalmers.se ([129.16.29.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Nov 2007 17:14:37 +0000 Original-Received: from bojohan+news by remote4.student.chalmers.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Nov 2007 17:14:37 +0000 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Followup-To: gmane.emacs.devel Original-Lines: 186 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: remote4.student.chalmers.se Mail-Copies-To: never User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:10pDy9aghrDUBNYxnfBWtoznQX0= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82436 gmane.emacs.pretest.bugs:20229 Archived-At: David Hansen writes: > $ emacs -Q > M-x eshell RET > $ while #'(lambda () t) { echo XXX; sleep 1} > C-x b *scratch* RET > > (with-temp-buffer > (let ((buf (current-buffer))) > (read-event nil nil 3) > (format ":%s: :%s:" (buffer-name buf) (current-buffer)))) > > C-u C-x C-e > > ": *temp*: :*eshell*:" It is caused by an unprotected set-buffer call in eshell-sentinel. This patch fixes this. It also uses with-current-buffer in eshell-insertion-filter, and in eshell-output-filter (instead of (set-buffer BUF) ... (set-buffer OLDBUF)). 2007-11-03 Johan Bockgård * eshell/esh-proc.el (eshell-insertion-filter, eshell-sentinel): Use `with-current-buffer'. * eshell/esh-mode.el (eshell-output-filter): Ditto. Index: lisp/eshell/esh-mode.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/eshell/esh-mode.el,v retrieving revision 1.31 diff -u -r1.31 esh-mode.el --- lisp/eshell/esh-mode.el 21 Oct 2007 07:33:32 -0000 1.31 +++ lisp/eshell/esh-mode.el 3 Nov 2007 16:58:32 -0000 @@ -775,38 +775,36 @@ (setq string (funcall (car functions) string)) (setq functions (cdr functions)))) (if (and string oprocbuf (buffer-name oprocbuf)) - (let ((obuf (current-buffer)) - opoint obeg oend) - (set-buffer oprocbuf) - (setq opoint (point)) - (setq obeg (point-min)) - (setq oend (point-max)) - (let ((buffer-read-only nil) - (nchars (length string)) - (ostart nil)) - (widen) - (goto-char eshell-last-output-end) - (setq ostart (point)) - (if (<= (point) opoint) - (setq opoint (+ opoint nchars))) - (if (< (point) obeg) - (setq obeg (+ obeg nchars))) - (if (<= (point) oend) - (setq oend (+ oend nchars))) - (insert-before-markers string) - (if (= (window-start (selected-window)) (point)) - (set-window-start (selected-window) - (- (point) nchars))) - (if (= (point) eshell-last-input-end) - (set-marker eshell-last-input-end - (- eshell-last-input-end nchars))) - (set-marker eshell-last-output-start ostart) - (set-marker eshell-last-output-end (point)) - (force-mode-line-update)) - (narrow-to-region obeg oend) - (goto-char opoint) - (eshell-run-output-filters) - (set-buffer obuf))))) + (let (opoint obeg oend) + (with-current-buffer oprocbuf + (setq opoint (point)) + (setq obeg (point-min)) + (setq oend (point-max)) + (let ((buffer-read-only nil) + (nchars (length string)) + (ostart nil)) + (widen) + (goto-char eshell-last-output-end) + (setq ostart (point)) + (if (<= (point) opoint) + (setq opoint (+ opoint nchars))) + (if (< (point) obeg) + (setq obeg (+ obeg nchars))) + (if (<= (point) oend) + (setq oend (+ oend nchars))) + (insert-before-markers string) + (if (= (window-start (selected-window)) (point)) + (set-window-start (selected-window) + (- (point) nchars))) + (if (= (point) eshell-last-input-end) + (set-marker eshell-last-input-end + (- eshell-last-input-end nchars))) + (set-marker eshell-last-output-start ostart) + (set-marker eshell-last-output-end (point)) + (force-mode-line-update)) + (narrow-to-region obeg oend) + (goto-char opoint) + (eshell-run-output-filters)))))) (defun eshell-run-output-filters () "Run the `eshell-output-filter-functions' on the current output." Index: lisp/eshell/esh-proc.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/eshell/esh-proc.el,v retrieving revision 1.16 diff -u -r1.16 esh-proc.el --- lisp/eshell/esh-proc.el 26 Jul 2007 05:26:54 -0000 1.16 +++ lisp/eshell/esh-proc.el 3 Nov 2007 16:58:33 -0000 @@ -335,39 +335,39 @@ PROC is the process for which we're inserting output. STRING is the output." (when (buffer-live-p (process-buffer proc)) - (set-buffer (process-buffer proc)) - (let ((entry (assq proc eshell-process-list))) - (when entry - (setcar (nthcdr 3 entry) - (concat (nth 3 entry) string)) - (unless (nth 4 entry) ; already being handled? - (while (nth 3 entry) - (let ((data (nth 3 entry))) - (setcar (nthcdr 3 entry) nil) - (setcar (nthcdr 4 entry) t) - (eshell-output-object data nil (cadr entry)) - (setcar (nthcdr 4 entry) nil)))))))) + (with-current-buffer (process-buffer proc) + (let ((entry (assq proc eshell-process-list))) + (when entry + (setcar (nthcdr 3 entry) + (concat (nth 3 entry) string)) + (unless (nth 4 entry) ; already being handled? + (while (nth 3 entry) + (let ((data (nth 3 entry))) + (setcar (nthcdr 3 entry) nil) + (setcar (nthcdr 4 entry) t) + (eshell-output-object data nil (cadr entry)) + (setcar (nthcdr 4 entry) nil))))))))) (defun eshell-sentinel (proc string) "Generic sentinel for command processes. Reports only signals. PROC is the process that's exiting. STRING is the exit message." (when (buffer-live-p (process-buffer proc)) - (set-buffer (process-buffer proc)) - (unwind-protect - (let* ((entry (assq proc eshell-process-list))) -; (if (not entry) -; (error "Sentinel called for unowned process `%s'" -; (process-name proc)) - (when entry - (unwind-protect - (progn - (unless (string= string "run") - (unless (string-match "^\\(finished\\|exited\\)" string) - (eshell-insertion-filter proc string)) - (eshell-close-handles (process-exit-status proc) 'nil - (cadr entry)))) - (eshell-remove-process-entry entry)))) - (run-hook-with-args 'eshell-kill-hook proc string)))) + (with-current-buffer (process-buffer proc) + (unwind-protect + (let* ((entry (assq proc eshell-process-list))) +;;; (if (not entry) +;;; (error "Sentinel called for unowned process `%s'" +;;; (process-name proc)) + (when entry + (unwind-protect + (progn + (unless (string= string "run") + (unless (string-match "^\\(finished\\|exited\\)" string) + (eshell-insertion-filter proc string)) + (eshell-close-handles (process-exit-status proc) 'nil + (cadr entry)))) + (eshell-remove-process-entry entry)))) + (run-hook-with-args 'eshell-kill-hook proc string))))) (defun eshell-process-interact (func &optional all query) "Interact with a process, using PROMPT if more than one, via FUNC. -- Johan Bockgård