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

From: Chong Yidong <[email-masked]>
Date: Wed, 20 Jan 2010 12:18:14 -0500

I narrowed the problem down to this specific change:

2009-12-04  Stefan Monnier  <[email-masked]>

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