GNU bug report logs - #5330
Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER

Previous Next

Package: emacs;

Reported by: Scott Bell <sctb <at> me.com>

Date: Wed, 6 Jan 2010 23:57:02 UTC

Severity: normal

Tags: fixed

Merged with 5449

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5330 in the body.
You can then email your comments to 5330 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs. (Wed, 06 Jan 2010 23:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Scott Bell <sctb <at> me.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 06 Jan 2010 23:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Scott Bell <sctb <at> me.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
Date: Wed, 06 Jan 2010 16:35:20 -0700
Under Mac OS X 10.6.2, Emacs 23.1.90.1, in an M-x term buffer
running /bin/bash, I get the following undesired behavior in
Cocoa emacs (Emacs.app/Contents/MacOS/Emacs -q) when typing 
`one two M-DEL' where meta is typed as the alt/option key:

$ one twoÿ

This occurs even when ns-alternate-modifier is set to 'meta.
Running Emacs in a terminal window (Emacs.app/Contents/MacOS/
Emacs -q -nw) works as I expect:

$ one 




bug reassigned from package 'emacs' to 'emacs,ns'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 07 Jan 2010 21:47:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 07:39:02 GMT) Full text and rfc822 format available.

Message #10 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Ken Hori <fplemma <at> gmail.com>
To: Scott Bell <sctb <at> me.com>, 5330 <at> debbugs.gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not respect 
	NS-ALTERNATE-MODIFIER
Date: Sat, 16 Jan 2010 22:51:25 -0800
[Message part 1 (text/plain, inline)]
It happens on Linux as well
(For example, Emacs 23.1.91 bzr revision 99310)

So M-d (delete-next-word) on term-mode does not work, even though term-mode
is supposed to be emulating a terminal as it is.

I can confirm this bug has existed for at least 1 month.
Perhaps reporting it again with a more noticeable title might get more
attention that it deserves. This is a major bug that keeps me from using M-x
term.


On Wed, Jan 6, 2010 at 3:35 PM, Scott Bell <sctb <at> me.com> wrote:

> Under Mac OS X 10.6.2, Emacs 23.1.90.1, in an M-x term buffer
> running /bin/bash, I get the following undesired behavior in
> Cocoa emacs (Emacs.app/Contents/MacOS/Emacs -q) when typing
> `one two M-DEL' where meta is typed as the alt/option key:
>
> $ one twoÿ
>
> This occurs even when ns-alternate-modifier is set to 'meta.
> Running Emacs in a terminal window (Emacs.app/Contents/MacOS/
> Emacs -q -nw) works as I expect:
>
> $ one
>
>
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 14:24:01 GMT) Full text and rfc822 format available.

Message #13 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ken Hori <fplemma <at> gmail.com>
To: Scott Bell <sctb <at> me.com>, 5330 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not respect 
	NS-ALTERNATE-MODIFIER
Date: Sun, 17 Jan 2010 06:18:09 -0800
[Message part 1 (text/plain, inline)]
I identified the cause of this bug.

It happens when PS1 environment variable contains certain \e escape code
like '\[\e[01;32m\][\h:\w]\$\[\e[00m\] '.

In such a case, term.el gets messed up somehow and becomes
no longer able to handle meta (alt) keyboard input properly.


On Sun, Jan 17, 2010 at 6:09 AM, Ken Hori <fplemma <at> gmail.com> wrote:

> It happens on Linux as well
> (For example, Emacs 23.1.91 bzr revision 99310)
>
> So M-d (delete-next-word) on term-mode does not work, even though term-mode
> is supposed to be emulating a terminal as it is.
>
> I can confirm this bug has existed for at least 1 month.
> Perhaps reporting it again with a more noticeable title might get more
> attention that it deserves. This is a major bug that keeps me from using M-x
> term.
>
> On Wed, Jan 6, 2010 at 3:35 PM, Scott Bell <sctb <at> me.com> wrote:
>
>> Under Mac OS X 10.6.2, Emacs 23.1.90.1, in an M-x term buffer
>> running /bin/bash, I get the following undesired behavior in
>> Cocoa emacs (Emacs.app/Contents/MacOS/Emacs -q) when typing
>> `one two M-DEL' where meta is typed as the alt/option key:
>>
>> $ one twoÿ
>>
>> This occurs even when ns-alternate-modifier is set to 'meta.
>> Running Emacs in a terminal window (Emacs.app/Contents/MacOS/
>> Emacs -q -nw) works as I expect:
>>
>> $ one
>>
>>
>>
>>
>>
>
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 14:24:02 GMT) Full text and rfc822 format available.

Message #16 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Ken Hori <fplemma <at> gmail.com>
To: Scott Bell <sctb <at> me.com>, 5330 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not respect 
	NS-ALTERNATE-MODIFIER
Date: Sun, 17 Jan 2010 06:09:33 -0800
[Message part 1 (text/plain, inline)]
It happens on Linux as well
(For example, Emacs 23.1.91 bzr revision 99310)

So M-d (delete-next-word) on term-mode does not work, even though term-mode
is supposed to be emulating a terminal as it is.

I can confirm this bug has existed for at least 1 month.
Perhaps reporting it again with a more noticeable title might get more
attention that it deserves. This is a major bug that keeps me from using M-x
term.

On Wed, Jan 6, 2010 at 3:35 PM, Scott Bell <sctb <at> me.com> wrote:

> Under Mac OS X 10.6.2, Emacs 23.1.90.1, in an M-x term buffer
> running /bin/bash, I get the following undesired behavior in
> Cocoa emacs (Emacs.app/Contents/MacOS/Emacs -q) when typing
> `one two M-DEL' where meta is typed as the alt/option key:
>
> $ one twoÿ
>
> This occurs even when ns-alternate-modifier is set to 'meta.
> Running Emacs in a terminal window (Emacs.app/Contents/MacOS/
> Emacs -q -nw) works as I expect:
>
> $ one
>
>
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 14:24:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 14:38:01 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Sun, 17 Jan 2010 23:47:02 GMT) Full text and rfc822 format available.

Message #25 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Scott Bell <sctb <at> me.com>
To: 5330 <at> debbugs.gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not
	respect	NS-ALTERNATE-MODIFIER
Date: Sun, 17 Jan 2010 16:46:23 -0700
On 2010-01-17, at 7:18 AM, Ken Hori wrote:

> I identified the cause of this bug.
> 
> It happens when PS1 environment variable contains certain \e escape code
> like '\[\e[01;32m\][\h:\w]\$\[\e[00m\] '.

I can't reproduce this -- I still encounter the problem
when PS1='> ' (no escape codes).





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Mon, 18 Jan 2010 21:28:02 GMT) Full text and rfc822 format available.

Message #28 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Ken Hori <fplemma <at> gmail.com>
To: Scott Bell <sctb <at> me.com>
Cc: 5330 <at> debbugs.gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not respect 
	NS-ALTERNATE-MODIFIER
Date: Mon, 18 Jan 2010 13:17:28 -0800
[Message part 1 (text/plain, inline)]
Please ignore my last post.

You can instead apply the following patch for a quick fix:

+++ term.el    2010-01-18 09:27:33.085376730 -0800
@@ -1208,8 +1208,17 @@

 (defun term-send-raw-meta ()
   (interactive)
-  (let* ((keys (this-command-keys))
-         (char (aref keys (1- (length keys)))))
+  (let ((char last-input-event))
+    (when (symbolp last-input-event)
+      ;; Convert `return' to C-m, etc.
+      (let ((tmp (get char 'event-symbol-elements)))
+    (when tmp
+      (setq char (car tmp)))
+    (when (symbolp char)
+      (setq tmp (get char 'ascii-character))
+      (when tmp
+        (setq char tmp)))))
+    (setq char (event-basic-type char))
     (term-send-raw-string (if (and (numberp char)
                    (> char 127)
                    (< char 256))

Or, just replace your term-send-raw-meta with:

(defun term-send-raw-meta ()
  (interactive)
  (let ((char last-input-event))
    (when (symbolp last-input-event)
      ;; Convert `return' to C-m, etc.
      (let ((tmp (get char 'event-symbol-elements)))
    (when tmp
      (setq char (car tmp)))
    (when (symbolp char)
      (setq tmp (get char 'ascii-character))
      (when tmp
        (setq char tmp)))))
    (setq char (event-basic-type char))
    (term-send-raw-string (if (and (numberp char)
                   (> char 127)
                   (< char 256))
                  (make-string 1 char)
                (format "\e%c" char)))))

Let me know if it succeeds or not.

On Sun, Jan 17, 2010 at 3:46 PM, Scott Bell <sctb <at> me.com> wrote:

> On 2010-01-17, at 7:18 AM, Ken Hori wrote:
>
> > I identified the cause of this bug.
> >
> > It happens when PS1 environment variable contains certain \e escape code
> > like '\[\e[01;32m\][\h:\w]\$\[\e[00m\] '.
>
> I can't reproduce this -- I still encounter the problem
> when PS1='> ' (no escape codes).
>
>
>
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Mon, 18 Jan 2010 22:01:01 GMT) Full text and rfc822 format available.

Message #31 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Scott Bell <sctb <at> me.com>
To: Ken Hori <fplemma <at> gmail.com>
Cc: 5330 <at> debbugs.gnu.org
Subject: Re: bug#5330: Term mode in Cocoa does not
	respect	NS-ALTERNATE-MODIFIER
Date: Mon, 18 Jan 2010 15:00:17 -0700
On 2010-01-18, at 2:17 PM, Ken Hori wrote:

> Please ignore my last post.
> 
> You can instead apply the following patch for a quick fix:
> 
> +++ term.el    2010-01-18 09:27:33.085376730 -0800
> @@ -1208,8 +1208,17 @@
>  
>  (defun term-send-raw-meta ()
>    (interactive)
> -  (let* ((keys (this-command-keys))
> -         (char (aref keys (1- (length keys)))))
> +  (let ((char last-input-event))
> +    (when (symbolp last-input-event)
> +      ;; Convert `return' to C-m, etc.
> +      (let ((tmp (get char 'event-symbol-elements)))
> +    (when tmp
> +      (setq char (car tmp)))
> +    (when (symbolp char)
> +      (setq tmp (get char 'ascii-character))
> +      (when tmp
> +        (setq char tmp)))))
> +    (setq char (event-basic-type char))
>      (term-send-raw-string (if (and (numberp char)
>                     (> char 127)
>                     (< char 256))
> 
> Or, just replace your term-send-raw-meta with:
> 
> (defun term-send-raw-meta ()
>   (interactive)
>   (let ((char last-input-event))
>     (when (symbolp last-input-event)
>       ;; Convert `return' to C-m, etc.
>       (let ((tmp (get char 'event-symbol-elements)))
>     (when tmp
>       (setq char (car tmp)))
>     (when (symbolp char)
>       (setq tmp (get char 'ascii-character))
>       (when tmp
>         (setq char tmp)))))
>     (setq char (event-basic-type char))
>     (term-send-raw-string (if (and (numberp char)
>                    (> char 127)
>                    (< char 256))
>                   (make-string 1 char)
>                 (format "\e%c" char)))))
> 
> Let me know if it succeeds or not.

This works, at least in my common use cases (M-d, M-RET, etc.)

- Scott




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs,ns. (Mon, 18 Jan 2010 22:41:02 GMT) Full text and rfc822 format available.

Message #34 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Stefan Monnier  <monnier <at> iro.umontreal.ca>
Cc: 5330 <at> debbugs.gnu.org
Subject: Re: M-d broken in term.el [Was: Term mode in Cocoa does not respect
	NS-ALTERNATE-MODIFIER]
Date: Mon, 18 Jan 2010 17:40:45 -0500
> It happens on Linux as well
> (For example, Emacs 23.1.91 bzr revision 99310)
>
> So M-d (delete-next-word) on term-mode does not work, even though term-mode
> is supposed to be emulating a terminal as it is.

Hi Stefan,

This bug started with your 2009-11-13 change to term.el:

2009-11-13  Stefan Monnier  <monnier <at> iro.umontreal.ca>

  * term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
  (term-write-input-ring, term-check-source, term-start-output-log):
  (term-display-buffer-line, term-dynamic-list-completions):
  (term-ansi-make-term, serial-term):
  ...
  Use with-current-buffer.

Could you please fix it?  I'm not sure Ken Hori's patch is right,
because it affects for another part of term.el.  Better to find out how
your change broke term.el first.

Thanks.




Severity set to 'serious' from 'normal' Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Mon, 18 Jan 2010 22:42:02 GMT) Full text and rfc822 format available.

bug reassigned from package 'emacs,ns' to 'emacs'. Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Mon, 18 Jan 2010 22:42:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs. (Wed, 20 Jan 2010 17:19:02 GMT) Full text and rfc822 format available.

Message #41 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Stefan Monnier  <monnier <at> iro.umontreal.ca>
Cc: Scott Bell <sctb <at> me.com>, 5330 <at> debbugs.gnu.org
Subject: Re: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
Date: Wed, 20 Jan 2010 12:18:14 -0500
I narrowed the problem down to this specific change:

2009-12-04  Stefan Monnier  <monnier <at> iro.umontreal.ca>

   Minor cleanup.
   * term.el (term-send-raw, term-send-raw-meta): Use read-key-sequence's
   key decoding rather than do it manually via last-input-event +
   ascii-character.

I'm not sure if the change to term-send-raw breaks anything, but the the
change to term-send-raw-meta definitely prevents the process from
getting M-d correctly.  I've reverted it in the repository for now
(change attached), but you might want to double-check the entire change.


*** lisp/term.el	2010-01-13 08:35:10 +0000
--- lisp/term.el	2010-01-20 17:12:01 +0000
***************
*** 1208,1215 ****
  
  (defun term-send-raw-meta ()
    (interactive)
!   (let* ((keys (this-command-keys))
!          (char (aref keys (1- (length keys)))))
      (term-send-raw-string (if (and (numberp char)
  				   (> char 127)
  				   (< char 256))
--- 1208,1224 ----
  
  (defun term-send-raw-meta ()
    (interactive)
!   (let ((char last-input-event))
!     (when (symbolp last-input-event)
!       ;; Convert `return' to C-m, etc.
!       (let ((tmp (get char 'event-symbol-elements)))
! 	(when tmp
! 	  (setq char (car tmp)))
! 	(when (symbolp char)
! 	  (setq tmp (get char 'ascii-character))
! 	  (when tmp
! 	    (setq char tmp)))))
!     (setq char (event-basic-type char))
      (term-send-raw-string (if (and (numberp char)
  				   (> char 127)
  				   (< char 256))




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs. (Wed, 20 Jan 2010 19:05:02 GMT) Full text and rfc822 format available.

Message #44 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Scott Bell <sctb <at> me.com>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 5330 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
Date: Wed, 20 Jan 2010 12:04:15 -0700
On 2010-01-20, at 10:18 AM, Chong Yidong wrote:

> I narrowed the problem down to this specific change:
> 
> 2009-12-04  Stefan Monnier  <monnier <at> iro.umontreal.ca>
> 
>   Minor cleanup.
>   * term.el (term-send-raw, term-send-raw-meta): Use read-key-sequence's
>   key decoding rather than do it manually via last-input-event +
>   ascii-character.
> 
> I'm not sure if the change to term-send-raw breaks anything, but the the
> change to term-send-raw-meta definitely prevents the process from
> getting M-d correctly.  I've reverted it in the repository for now
> (change attached), but you might want to double-check the entire change.

The latest repository seems to work for me with
this change, thanks!

- Scott




Severity set to 'normal' from 'serious' Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Fri, 22 Jan 2010 16:19:01 GMT) Full text and rfc822 format available.

Merged 5330 5449. Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Fri, 22 Jan 2010 16:19:01 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 18 Sep 2011 11:58:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.1, send any further explanations to 5449 <at> debbugs.gnu.org and Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 18 Sep 2011 11:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5330; Package emacs. (Sun, 18 Sep 2011 12:13:01 GMT) Full text and rfc822 format available.

Message #55 received at 5330 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Scott Bell <sctb <at> me.com>
Cc: 5449 <at> debbugs.gnu.org, Chong Yidong <cyd <at> stupidchicken.com>,
	5330 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
Date: Sun, 18 Sep 2011 13:48:42 +0200
Scott Bell <sctb <at> me.com> writes:

>> I'm not sure if the change to term-send-raw breaks anything, but the the
>> change to term-send-raw-meta definitely prevents the process from
>> getting M-d correctly.  I've reverted it in the repository for now
>> (change attached), but you might want to double-check the entire change.
>
> The latest repository seems to work for me with
> this change, thanks!

Reading the thread, it seems like the bug was fixed, so I'm closing this
report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 17 Oct 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 243 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.