From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.devel Subject: [patch] Prompt problems in tcl-mode Date: Tue, 18 Apr 2006 22:45:51 +0200 Organization: http://purl.org/harder/ Message-ID: <877j5mwr28.fsf@Jesper-Harders-Computer.local> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1145393188 11851 80.91.229.2 (18 Apr 2006 20:46:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Apr 2006 20:46:28 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 18 22:46:23 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FVx5Y-0003bG-1r for ged-emacs-devel@m.gmane.org; Tue, 18 Apr 2006 22:46:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVx5X-0005yR-Gx for ged-emacs-devel@m.gmane.org; Tue, 18 Apr 2006 16:46:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FVx5K-0005xW-LV for emacs-devel@gnu.org; Tue, 18 Apr 2006 16:46:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FVx5J-0005xK-6L for emacs-devel@gnu.org; Tue, 18 Apr 2006 16:46:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVx5J-0005xH-0c for emacs-devel@gnu.org; Tue, 18 Apr 2006 16:46:05 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FVx6F-0007Ne-Pp for emacs-devel@gnu.org; Tue, 18 Apr 2006 16:47:04 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FVx5F-0003XS-6i for emacs-devel@gnu.org; Tue, 18 Apr 2006 22:46:01 +0200 Original-Received: from 0x5552821a.adsl.cybercity.dk ([85.82.130.26]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Apr 2006 22:46:01 +0200 Original-Received: from jesper.harder by 0x5552821a.adsl.cybercity.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Apr 2006 22:46:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-To: emacs-devel@gnu.org Original-Lines: 134 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 0x5552821a.adsl.cybercity.dk X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; 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:53023 Archived-At: --=-=-= Hi, The following patch adresses two problems in Tcl mode: * The Tcl prompt, "%", isn't deleted correctly, which results in multiple prompts on the same line when sending functions or the region to the inferior Tcl buffer. There are two reasons for this: 1. Due to field boundaries `beginning-of-line' doesn't move over the prompt. 2. A trailing newline is always added even if it's already present. * On ms-windows /no/ prompt is displayed. The reason is explained on : [..] on Windows, Emacs is unable to make the Tcl interpreter start in the "interactive" mode. The problem is that Tcl calls istty() to determine whether tcl_interactive should be set and whether prompts should be displayed. But the Windows version of Emacs can not make istty() return the right value so this doesn't happen and tclsh thinks it's running non-interactive. My change makes it work out-of-the-box if you're using tclsh. It doesn't fix it if you're using wish, though (which is the default in Emacs). 2006-04-18 Jesper Harder * tcl.el (tcl-eval-region): Replace multiple trailing newlines with just one. (tcl-send-string): Use (forward-line 0) rather than beginning-of-line. (tcl-send-region): Delete. (inferior-tcl): Set tcl_interactive to 1 on ms-windows. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=tcl.el.diff diff -c /Users/harder/emacs/lisp/progmodes/tcl.el /Users/harder/tcl.el *** /Users/harder/emacs/lisp/progmodes/tcl.el Tue Jan 17 00:09:02 2006 --- /Users/harder/tcl.el Tue Apr 18 22:23:25 2006 *************** *** 1042,1060 **** (defun tcl-send-string (proc string) (with-current-buffer (process-buffer proc) (goto-char (process-mark proc)) ! (beginning-of-line) (if (looking-at comint-prompt-regexp) (set-marker inferior-tcl-delete-prompt-marker (point)))) (comint-send-string proc string)) - (defun tcl-send-region (proc start end) - (with-current-buffer (process-buffer proc) - (goto-char (process-mark proc)) - (beginning-of-line) - (if (looking-at comint-prompt-regexp) - (set-marker inferior-tcl-delete-prompt-marker (point)))) - (comint-send-region proc start end)) - (defun switch-to-tcl (eob-p) "Switch to inferior Tcl process buffer. With argument, positions cursor at end of buffer." --- 1042,1052 ---- (defun tcl-send-string (proc string) (with-current-buffer (process-buffer proc) (goto-char (process-mark proc)) ! (forward-line 0) (if (looking-at comint-prompt-regexp) (set-marker inferior-tcl-delete-prompt-marker (point)))) (comint-send-string proc string)) (defun switch-to-tcl (eob-p) "Switch to inferior Tcl process buffer. With argument, positions cursor at end of buffer." *************** *** 1079,1088 **** "Send the current region to the inferior Tcl process. Prefix argument means switch to the Tcl buffer afterwards." (interactive "r\nP") ! (let ((proc (inferior-tcl-proc))) ! (tcl-send-region proc start end) ! (tcl-send-string proc "\n") ! (if and-go (switch-to-tcl t)))) (defun tcl-eval-defun (&optional and-go) "Send the current defun to the inferior Tcl process. --- 1071,1080 ---- "Send the current region to the inferior Tcl process. Prefix argument means switch to the Tcl buffer afterwards." (interactive "r\nP") ! (tcl-send-string ! (inferior-tcl-proc) ! (replace-regexp-in-string "\n*$" "\n" (buffer-substring start end))) ! (when and-go (switch-to-tcl t))) (defun tcl-eval-defun (&optional and-go) "Send the current defun to the inferior Tcl process. *************** *** 1149,1155 **** (unless (comint-check-proc "*inferior-tcl*") (set-buffer (apply (function make-comint) "inferior-tcl" cmd nil tcl-command-switches)) ! (inferior-tcl-mode)) (set (make-local-variable 'tcl-application) cmd) (setq inferior-tcl-buffer "*inferior-tcl*") (pop-to-buffer "*inferior-tcl*")) --- 1141,1150 ---- (unless (comint-check-proc "*inferior-tcl*") (set-buffer (apply (function make-comint) "inferior-tcl" cmd nil tcl-command-switches)) ! (inferior-tcl-mode) ! ;; Make tclsh display a prompt on ms-windows. Doesn't affect wish, unfortunately. ! (when (eq system-type 'windows-nt) ! (tcl-send-string (inferior-tcl-proc) "set ::tcl_interactive 1; concat\n"))) (set (make-local-variable 'tcl-application) cmd) (setq inferior-tcl-buffer "*inferior-tcl*") (pop-to-buffer "*inferior-tcl*")) *************** *** 1551,1553 **** --- 1546,1549 ---- ;; arch-tag: 8a032554-c3ef-422e-b84c-acec0522179d ;;; tcl.el ends here + Diff finished. Tue Apr 18 22:23:37 2006 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--