* [patch] Prompt problems in tcl-mode
@ 2006-04-18 20:45 Jesper Harder
2006-04-18 21:16 ` Stefan Monnier
2006-04-19 7:43 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: Jesper Harder @ 2006-04-18 20:45 UTC (permalink / raw
[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]
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
<http://wiki.tcl.tk/3005>:
[..] 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 <harder@phys.au.dk>
* 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tcl.el.diff --]
[-- Type: text/x-patch, Size: 3329 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Prompt problems in tcl-mode
2006-04-18 20:45 [patch] Prompt problems in tcl-mode Jesper Harder
@ 2006-04-18 21:16 ` Stefan Monnier
2006-04-18 21:38 ` Jesper Harder
2006-04-19 7:43 ` Eli Zaretskii
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2006-04-18 21:16 UTC (permalink / raw
> The following patch adresses two problems in Tcl mode:
Thanks. I've installed a similar patch.
> * On ms-windows /no/ prompt is displayed. The reason is explained on
> <http://wiki.tcl.tk/3005>:
> [..] 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).
I've used a slightly different check (check process-tty-name instead of
system-type=windows-nt, see below), hoping to make it more specific (and
more general at the same time). Can you confirm that it works as well for
you,
Stefan
@@ -1149,7 +1153,12 @@
(unless (comint-check-proc "*inferior-tcl*")
(set-buffer (apply (function make-comint) "inferior-tcl" cmd nil
tcl-command-switches))
- (inferior-tcl-mode))
+ (inferior-tcl-mode)
+ ;; Make tclsh display a prompt on ms-windows (or under Unix, when a tty
+ ;; wasn't used). Doesn't affect wish, unfortunately.
+ (unless (process-tty-name (inferior-tcl-proc))
+ (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*"))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Prompt problems in tcl-mode
2006-04-18 21:16 ` Stefan Monnier
@ 2006-04-18 21:38 ` Jesper Harder
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Harder @ 2006-04-18 21:38 UTC (permalink / raw
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> I've used a slightly different check (check process-tty-name instead
> of system-type=windows-nt, see below), hoping to make it more
> specific (and more general at the same time). Can you confirm that
> it works as well for you,
Yup, it works. Tested it on ms-windows and OS X.
--
Cheers,
Jesper Harder
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Prompt problems in tcl-mode
2006-04-18 20:45 [patch] Prompt problems in tcl-mode Jesper Harder
2006-04-18 21:16 ` Stefan Monnier
@ 2006-04-19 7:43 ` Eli Zaretskii
2006-04-19 12:04 ` Stefan Monnier
1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2006-04-19 7:43 UTC (permalink / raw
> From: Jesper Harder <jesper.harder@gmail.com>
> Date: Tue, 18 Apr 2006 22:45:51 +0200
>
> ! ;; 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")))
Should we do this in the Cygwin build as well (which has a different
value for system-type)? Or does Cygwin emulate isatty correctly?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Prompt problems in tcl-mode
2006-04-19 7:43 ` Eli Zaretskii
@ 2006-04-19 12:04 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2006-04-19 12:04 UTC (permalink / raw
Cc: emacs-devel
>> ! ;; 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")))
> Should we do this in the Cygwin build as well (which has a different
> value for system-type)? Or does Cygwin emulate isatty correctly?
I believe the patch I installed (which uses process-tty-name instead) takes
care of it.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-04-19 12:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-18 20:45 [patch] Prompt problems in tcl-mode Jesper Harder
2006-04-18 21:16 ` Stefan Monnier
2006-04-18 21:38 ` Jesper Harder
2006-04-19 7:43 ` Eli Zaretskii
2006-04-19 12:04 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).