Show
Ignore:
Timestamp:
06/02/07 09:29:41 (1 year ago)
Author:
miyoshi
Message:

Sync up with Emacs_22_BASE.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/emulation/tpu-edt.el

    r4190 r4210  
    585585SS3 is DEC's name for the sequence <ESC>O.") 
    586586 
    587 (defvar tpu-global-map nil "TPU-edt global keymap.") 
    588 (defvar tpu-original-global-map global-map 
    589   "Original non-TPU global keymap.") 
     587(defvar tpu-global-map 
     588  (let ((map (make-sparse-keymap))) 
     589    (define-key map "\e[" CSI-map) 
     590    (define-key map "\eO" SS3-map) 
     591    map) 
     592  "TPU-edt global keymap.") 
    590593 
    591594(and (not (boundp 'minibuffer-local-ns-map)) 
     
    22682271;;;  Functions to set, reset, and toggle the control key bindings 
    22692272;;; 
    2270 (defun tpu-set-control-keys nil 
     2273 
     2274(defvar tpu-control-keys-map 
     2275  (let ((map (make-sparse-keymap))) 
     2276  (define-key map "\C-\\" 'quoted-insert)                ; ^\ 
     2277  (define-key map "\C-a" 'tpu-toggle-overwrite-mode)     ; ^A 
     2278  (define-key map "\C-b" 'repeat-complex-command)        ; ^B 
     2279  (define-key map "\C-e" 'tpu-current-end-of-line)       ; ^E 
     2280  (define-key map "\C-h" 'tpu-next-beginning-of-line)    ; ^H (BS) 
     2281  (define-key map "\C-j" 'tpu-delete-previous-word)      ; ^J (LF) 
     2282  (define-key map "\C-k" 'tpu-define-macro-key)          ; ^K 
     2283  (define-key map "\C-l" 'tpu-insert-formfeed)           ; ^L (FF) 
     2284  (define-key map "\C-r" 'recenter)                      ; ^R 
     2285  (define-key map "\C-u" 'tpu-delete-to-bol)             ; ^U 
     2286  (define-key map "\C-v" 'tpu-quoted-insert)             ; ^V 
     2287  (define-key map "\C-w" 'redraw-display)                ; ^W 
     2288  (define-key map "\C-z" 'tpu-exit)                      ; ^Z 
     2289  map)) 
     2290 
     2291(defun tpu-set-control-keys () 
    22712292  "Set control keys to TPU style functions." 
    2272   (define-key global-map "\C-\\" 'quoted-insert)                ; ^\ 
    2273   (define-key global-map "\C-a" 'tpu-toggle-overwrite-mode)     ; ^A 
    2274   (define-key global-map "\C-b" 'repeat-complex-command)        ; ^B 
    2275   (define-key global-map "\C-e" 'tpu-current-end-of-line)       ; ^E 
    2276   (define-key global-map "\C-h" 'tpu-next-beginning-of-line)    ; ^H (BS) 
    2277   (define-key global-map "\C-j" 'tpu-delete-previous-word)      ; ^J (LF) 
    2278   (define-key global-map "\C-k" 'tpu-define-macro-key)          ; ^K 
    2279   (define-key global-map "\C-l" 'tpu-insert-formfeed)           ; ^L (FF) 
    2280   (define-key global-map "\C-r" 'recenter)                      ; ^R 
    2281   (define-key global-map "\C-u" 'tpu-delete-to-bol)             ; ^U 
    2282   (define-key global-map "\C-v" 'tpu-quoted-insert)             ; ^V 
    2283   (define-key global-map "\C-w" 'redraw-display)                ; ^W 
    2284   (define-key global-map "\C-z" 'tpu-exit)                      ; ^Z 
    2285   (setq tpu-control-keys t)) 
     2293  (tpu-reset-control-keys 'tpu)) 
    22862294 
    22872295(defun tpu-reset-control-keys (tpu-style) 
    22882296  "Set control keys to TPU or Emacs style functions." 
    2289   (let* ((tpu   (and tpu-style (not tpu-control-keys))) 
    2290          (emacs (and (not tpu-style) tpu-control-keys)) 
    2291          (doit  (or tpu emacs))) 
    2292     (cond (doit 
    2293            (if emacs (setq tpu-global-map (copy-keymap global-map))) 
    2294            (let ((map (if tpu tpu-global-map tpu-original-global-map))) 
    2295  
    2296              (define-key global-map "\C-\\" (lookup-key map "\C-\\"))   ; ^\ 
    2297              (define-key global-map "\C-a" (lookup-key map "\C-a"))     ; ^A 
    2298              (define-key global-map "\C-b" (lookup-key map "\C-b"))     ; ^B 
    2299              (define-key global-map "\C-e" (lookup-key map "\C-e"))     ; ^E 
    2300              (define-key global-map "\C-h" (lookup-key map "\C-h"))     ; ^H (BS) 
    2301              (define-key global-map "\C-j" (lookup-key map "\C-j"))     ; ^J (LF) 
    2302              (define-key global-map "\C-k" (lookup-key map "\C-k"))     ; ^K 
    2303              (define-key global-map "\C-l" (lookup-key map "\C-l"))     ; ^L (FF) 
    2304              (define-key global-map "\C-r" (lookup-key map "\C-r"))     ; ^R 
    2305              (define-key global-map "\C-u" (lookup-key map "\C-u"))     ; ^U 
    2306              (define-key global-map "\C-v" (lookup-key map "\C-v"))     ; ^V 
    2307              (define-key global-map "\C-w" (lookup-key map "\C-w"))     ; ^W 
    2308              (define-key global-map "\C-z" (lookup-key map "\C-z"))     ; ^Z 
    2309              (setq tpu-control-keys tpu-style)))))) 
     2297  (let ((parent (keymap-parent tpu-global-map))) 
     2298    (if tpu-style 
     2299        (if (eq parent tpu-control-keys-map) 
     2300            nil                         ;All done already. 
     2301          ;; Insert tpu-control-keys-map in the global map. 
     2302          (set-keymap-parent tpu-control-keys-map parent) 
     2303          (set-keymap-parent tpu-global-map tpu-control-keys-map)) 
     2304      (if (not (eq parent tpu-control-keys-map)) 
     2305          nil                         ;All done already. 
     2306        ;; Remove tpu-control-keys-map from the global map. 
     2307        (set-keymap-parent tpu-global-map (keymap-parent parent)) 
     2308        (set-keymap-parent tpu-control-keys-map nil))) 
     2309    (setq tpu-control-keys tpu-style))) 
    23102310 
    23112311(defun tpu-toggle-control-keys nil 
     
    24482448  "Turn on TPU/edt emulation." 
    24492449  (interactive) 
    2450   (and window-system (tpu-load-xkeys nil)) 
    2451   (tpu-arrow-history) 
     2450  ;; First, activate tpu-global-map, while protecting the original keymap. 
     2451  (set-keymap-parent tpu-global-map global-map) 
     2452  (setq global-map tpu-global-map) 
     2453  (use-global-map global-map) 
     2454  ;; Then do the normal TPU setup. 
    24522455  (transient-mark-mode t) 
    24532456  (add-hook 'post-command-hook 'tpu-search-highlight) 
     
    24582461  (setq-default truncate-lines t) 
    24592462  (setq scroll-step 1) 
    2460   (setq global-map (copy-keymap global-map)) 
    24612463  (tpu-set-control-keys) 
    2462   (define-key global-map "\e[" CSI-map) 
    2463   (define-key global-map "\eO" SS3-map) 
     2464  (and window-system (tpu-load-xkeys nil)) 
     2465  (tpu-arrow-history) 
     2466  ;; Then protect tpu-global-map from user modifications. 
     2467  (let ((map (make-sparse-keymap))) 
     2468    (set-keymap-parent map global-map) 
     2469    (setq global-map map) 
     2470    (use-global-map map)) 
    24642471  (setq tpu-edt-mode t)) 
    24652472 
     
    24732480  (setq-default truncate-lines nil) 
    24742481  (setq scroll-step 0) 
    2475   (setq global-map tpu-original-global-map) 
    2476   (use-global-map global-map) 
     2482  ;; Remove tpu-global-map from the global map. 
     2483  (let ((map global-map)) 
     2484    (while map 
     2485      (let ((parent (keymap-parent map))) 
     2486        (if (eq tpu-global-map parent) 
     2487            (set-keymap-parent map (keymap-parent parent)) 
     2488          (setq map parent))))) 
    24772489  (setq tpu-edt-mode nil)) 
    24782490