Subject: Re: bug#5330: Term mode in Cocoa does not respect NS-ALTERNATE-MODIFIER

From: Ken Hori <[email-masked]>
Date: Mon, 18 Jan 2010 13:17:28 -0800

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 <[email-masked]> 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).
>
>
>
>
>
>