unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
@ 2010-01-06 23:35 Scott Bell
  2010-01-17  6:51 ` Ken Hori
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Scott Bell @ 2010-01-06 23:35 UTC (permalink / raw)
  To: bug-gnu-emacs

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 






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-06 23:35 bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Scott Bell
@ 2010-01-17  6:51 ` Ken Hori
  2010-01-17 14:09 ` Ken Hori
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Ken Hori @ 2010-01-17  6:51 UTC (permalink / raw)
  To: Scott Bell, 5330

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

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@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
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1265 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-06 23:35 bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Scott Bell
  2010-01-17  6:51 ` Ken Hori
@ 2010-01-17 14:09 ` Ken Hori
  2010-01-17 14:18   ` Ken Hori
  2010-01-18 22:40 ` bug#5330: M-d broken in term.el [Was: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER] Chong Yidong
  2010-01-20 17:18 ` bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Chong Yidong
  3 siblings, 1 reply; 11+ messages in thread
From: Ken Hori @ 2010-01-17 14:09 UTC (permalink / raw)
  To: Scott Bell, 5330; +Cc: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 959 bytes --]

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@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
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1337 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-17 14:09 ` Ken Hori
@ 2010-01-17 14:18   ` Ken Hori
  2010-01-17 23:46     ` Scott Bell
  0 siblings, 1 reply; 11+ messages in thread
From: Ken Hori @ 2010-01-17 14:18 UTC (permalink / raw)
  To: Scott Bell, 5330; +Cc: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]

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@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@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
>>
>>
>>
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 2045 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-17 14:18   ` Ken Hori
@ 2010-01-17 23:46     ` Scott Bell
  2010-01-18 21:17       ` Ken Hori
  0 siblings, 1 reply; 11+ messages in thread
From: Scott Bell @ 2010-01-17 23:46 UTC (permalink / raw)
  To: 5330

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).







^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-17 23:46     ` Scott Bell
@ 2010-01-18 21:17       ` Ken Hori
  2010-01-18 22:00         ` Scott Bell
  0 siblings, 1 reply; 11+ messages in thread
From: Ken Hori @ 2010-01-18 21:17 UTC (permalink / raw)
  To: Scott Bell; +Cc: 5330

[-- Attachment #1: Type: text/plain, Size: 1857 bytes --]

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@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).
>
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 2414 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-18 21:17       ` Ken Hori
@ 2010-01-18 22:00         ` Scott Bell
  0 siblings, 0 replies; 11+ messages in thread
From: Scott Bell @ 2010-01-18 22:00 UTC (permalink / raw)
  To: Ken Hori; +Cc: 5330

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






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: M-d broken in term.el [Was: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER]
  2010-01-06 23:35 bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Scott Bell
  2010-01-17  6:51 ` Ken Hori
  2010-01-17 14:09 ` Ken Hori
@ 2010-01-18 22:40 ` Chong Yidong
  2010-01-20 17:18 ` bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Chong Yidong
  3 siblings, 0 replies; 11+ messages in thread
From: Chong Yidong @ 2010-01-18 22:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 5330

> 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@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.






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-06 23:35 bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Scott Bell
                   ` (2 preceding siblings ...)
  2010-01-18 22:40 ` bug#5330: M-d broken in term.el [Was: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER] Chong Yidong
@ 2010-01-20 17:18 ` Chong Yidong
  2010-01-20 19:04   ` Scott Bell
  3 siblings, 1 reply; 11+ messages in thread
From: Chong Yidong @ 2010-01-20 17:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Scott Bell, 5330

I narrowed the problem down to this specific change:

2009-12-04  Stefan Monnier  <monnier@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))






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-20 17:18 ` bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Chong Yidong
@ 2010-01-20 19:04   ` Scott Bell
  2011-09-18 11:48     ` bug#5449: " Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 11+ messages in thread
From: Scott Bell @ 2010-01-20 19:04 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5330

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@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






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#5449: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER
  2010-01-20 19:04   ` Scott Bell
@ 2011-09-18 11:48     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 11+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-18 11:48 UTC (permalink / raw)
  To: Scott Bell; +Cc: 5449, Chong Yidong, 5330

Scott Bell <sctb@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/





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-09-18 11:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-06 23:35 bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Scott Bell
2010-01-17  6:51 ` Ken Hori
2010-01-17 14:09 ` Ken Hori
2010-01-17 14:18   ` Ken Hori
2010-01-17 23:46     ` Scott Bell
2010-01-18 21:17       ` Ken Hori
2010-01-18 22:00         ` Scott Bell
2010-01-18 22:40 ` bug#5330: M-d broken in term.el [Was: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER] Chong Yidong
2010-01-20 17:18 ` bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER Chong Yidong
2010-01-20 19:04   ` Scott Bell
2011-09-18 11:48     ` bug#5449: " Lars Magne Ingebrigtsen

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).