From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: Emacs 23.1 flushes stdin on startup Date: Tue, 11 Aug 2009 15:14:11 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87vdkukt0s.fsf@lifelogs.com> References: <4A789738.8090008@roaringpenguin.com> <87r5vquzrc.fsf@jumptrading.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1250021689 15385 80.91.229.12 (11 Aug 2009 20:14:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2009 20:14:49 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 11 22:14:42 2009 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 1Maxk0-0007g4-OE for ged-emacs-devel@m.gmane.org; Tue, 11 Aug 2009 22:14:41 +0200 Original-Received: from localhost ([127.0.0.1]:49182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Maxjy-0004wA-V2 for ged-emacs-devel@m.gmane.org; Tue, 11 Aug 2009 16:14:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Maxjt-0004w2-4P for emacs-devel@gnu.org; Tue, 11 Aug 2009 16:14:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Maxjo-0004vq-Ho for emacs-devel@gnu.org; Tue, 11 Aug 2009 16:14:32 -0400 Original-Received: from [199.232.76.173] (port=51125 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Maxjo-0004vn-CN for emacs-devel@gnu.org; Tue, 11 Aug 2009 16:14:28 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:45406 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 1Maxjn-0000gR-MH for emacs-devel@gnu.org; Tue, 11 Aug 2009 16:14:28 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Maxji-0007yG-C3 for emacs-devel@gnu.org; Tue, 11 Aug 2009 20:14:22 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Aug 2009 20:14:22 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Aug 2009 20:14:22 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 153 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:ENIGq10j0aJSUBvpmknjfM+jRxw= X-detected-operating-system: by monty-python.gnu.org: GNU/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:114099 Archived-At: On Thu, 06 Aug 2009 12:33:47 -0400 Stefan Monnier wrote: SM> Please merge the when and the cond into a single cond (which will give SM> meaning to this `cond', since as it stands it only has two arms and SM> could hence as well use `if'). On Thu, 06 Aug 2009 12:35:05 -0400 Stefan Monnier wrote: SM> One more thing: terminal-init- should only be used for "the setup SM> code for terminal FOO". Since there aren't any terminal named SM> "xterm-modify-other-keys" and this function doesn't treat them, better SM> use some other name, such as just `xterm-modify-other-keys'. OK, I did both. On Fri, 07 Aug 2009 23:02:03 +0200 bojohan+news@dd.chalmers.se (Johan Bockgård) wrote: JB> Yes. I just don't like the name. I would set this new variable to nil, JB> but not because the feature is not supported in my terminal, but rather JB> that it is already enabled there without having Emacs turn it on. I don't know how to choose a better name, sorry. Feel free to suggest alternatives. Another version lies below. Let me know if it looks OK. My change is minor but I may have missed something. Ted Index: xterm.el =================================================================== RCS file: /sources/emacs/emacs/lisp/term/xterm.el,v retrieving revision 1.62 diff -c -r1.62 xterm.el *** xterm.el 5 Jan 2009 03:23:59 -0000 1.62 --- xterm.el 11 Aug 2009 20:11:29 -0000 *************** *** 25,30 **** --- 25,36 ---- ;;; Code: + (defcustom xterm-supported-modify-other-keys 'check + "Whether the XTerm supports modifyOtherKeys." + :type '(choice (const :tag "No" nil) + (const :tag "Yes" t) + (const :tag "Check" check))) + (defvar xterm-function-map (let ((map (make-sparse-keymap))) *************** *** 470,515 **** ;; C-. C-, etc. ;; To do that we need to find out if the current terminal supports ;; modifyOtherKeys. At this time only xterm does. ! (let ((coding-system-for-read 'binary) ! (chr nil) ! (str nil)) ! ;; Pending input can be mistakenly returned by the calls to ! ;; read-event below. Discard it. ! (discard-input) ! ;; Try to find out the type of terminal by sending a "Secondary ! ;; Device Attributes (DA)" query. ! (send-string-to-terminal "\e[>0c") ! ! ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c ! ;; If the timeout is completely removed for read-event, this ! ;; might hang for terminals that pretend to be xterm, but don't ! ;; respond to this escape sequence. RMS' opinion was to remove ! ;; it completely. That might be right, but let's first try to ! ;; see if by using a longer timeout we get rid of most issues. ! (when (equal (read-event nil nil 2) ?\e) ! (when (equal (read-event nil nil 2) ?\[) ! (while (not (equal (setq chr (read-event nil nil 2)) ?c)) ! (setq str (concat str (string chr)))) ! (when (string-match ">0;\\([0-9]+\\);0" str) ! ;; NUMBER2 is the xterm version number, look for something ! ;; greater than 216, the version when modifyOtherKeys was ! ;; introduced. ! (when (>= (string-to-number ! (substring str (match-beginning 1) (match-end 1))) 216) ! ;; Make sure that the modifyOtherKeys state is restored when ! ;; suspending, resuming and exiting. ! (add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys) ! (add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys) ! (add-hook 'kill-emacs-hook 'xterm-remove-modify-other-keys) ! (add-hook 'delete-terminal-functions 'xterm-remove-modify-other-keys) ! ;; Add the selected frame to the list of frames that ! ;; need to deal with modify-other-keys. ! (push (frame-terminal (selected-frame)) ! xterm-modify-other-keys-terminal-list) ! (xterm-turn-on-modify-other-keys)))))) (run-hooks 'terminal-init-xterm-hook)) ;; Set up colors, for those versions of xterm that support it. (defvar xterm-standard-colors ;; The names in the comments taken from XTerm-col.ad in the xterm --- 476,528 ---- ;; C-. C-, etc. ;; To do that we need to find out if the current terminal supports ;; modifyOtherKeys. At this time only xterm does. ! (cond ! ((eq xterm-supported-modify-other-keys 'check) ! (let ((coding-system-for-read 'binary) ! (chr nil) ! (str nil)) ! ;; Pending input can be mistakenly returned by the calls to ! ;; read-event below. Discard it. ! (discard-input) ! ;; Try to find out the type of terminal by sending a "Secondary ! ;; Device Attributes (DA)" query. ! (send-string-to-terminal "\e[>0c") ! ! ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c ! ;; If the timeout is completely removed for read-event, this ! ;; might hang for terminals that pretend to be xterm, but don't ! ;; respond to this escape sequence. RMS' opinion was to remove ! ;; it completely. That might be right, but let's first try to ! ;; see if by using a longer timeout we get rid of most issues. ! (when (equal (read-event nil nil 2) ?\e) ! (when (equal (read-event nil nil 2) ?\[) ! (while (not (equal (setq chr (read-event nil nil 2)) ?c)) ! (setq str (concat str (string chr)))) ! (when (string-match ">0;\\([0-9]+\\);0" str) ! ;; NUMBER2 is the xterm version number, look for something ! ;; greater than 216, the version when modifyOtherKeys was ! ;; introduced. ! (when (>= (string-to-number ! (substring str (match-beginning 1) (match-end 1))) 216) ! (xterm-modify-other-keys))))))) ! (xterm-supported-modify-other-keys (xterm-modify-other-keys))) (run-hooks 'terminal-init-xterm-hook)) + (defun xterm-modify-other-keys () + "Terminal initialization for xterm's modifyOtherKeys support." + ;; Make sure that the modifyOtherKeys state is restored when + ;; suspending, resuming and exiting. + (add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys) + (add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys) + (add-hook 'kill-emacs-hook 'xterm-remove-modify-other-keys) + (add-hook 'delete-terminal-functions 'xterm-remove-modify-other-keys) + ;; Add the selected frame to the list of frames that + ;; need to deal with modify-other-keys. + (push (frame-terminal (selected-frame)) + xterm-modify-other-keys-terminal-list) + (xterm-turn-on-modify-other-keys)) + ;; Set up colors, for those versions of xterm that support it. (defvar xterm-standard-colors ;; The names in the comments taken from XTerm-col.ad in the xterm