[comp.emacs] Terminal sensitive initialization

pswisnov@shrike.bcm.tmc.edu (Peter Wisnovsky) (07/22/88)

Hi: I would like to put some terminal sensitive initializations in my
.emacs file, but my Lisp is a little rusty.  Could someone send me an
example of such an initialization?  If you also have setups for the
Sun (under SunView), the Mac (under uw) and the vt100 those would be
nice too.

Thanks,
Peter Wisnovsky
pswisnov@shrike.bcm.tmc.edu
pswisnov@phoenix.princeton.edu

rbj@nav.icst.nbs.GOV (Root Boy Jim) (07/23/88)

? From: Peter Wisnovsky <uwmcsd1!mailrus!bcm!shrike!pswisnov@bbn.com>

? Hi: I would like to put some terminal sensitive initializations in my
? .emacs file, but my Lisp is a little rusty.  Could someone send me an
? example of such an initialization?  If you also have setups for the
? Sun (under SunView), the Mac (under uw) and the vt100 those would be
? nice too.

Here is my term-hook.el file. I have the command (load "term-hook") in .emacs.

(setq term-setup-hook 'term-hook)

(defun term-hook () "Add various key definitions"
  (let ((term (substring (getenv "TERM") 0
			 (string-match "-" (getenv "TERM")))))
    (cond ((string= term "vt100") (vt100-hook))
	   ((or (string= term "vt200")
		(string= term "vt220")) (vt200-hook))
	   ((string= term "tvi950") (tvi950-hook))
	   ((string= term "sun") (sun-hook))
	  )))

; DEC VT100/220 Initialization (radically different)

(defun vt100-hook () "Add vt100/220 key definitions"
  (enable-arrow-keys)
  (global-set-key "\e[[" 'backward-paragraph)

  (define-key function-keymap "u" 'scroll-down-in-place)
  (define-key function-keymap "d" 'scroll-up-in-place)
  (define-key function-keymap "l" "\e1\^x\^r")	; beg window
  (define-key function-keymap "r" "\e-2\^x\^r")	; end window

  (define-key function-keymap "." 'copy-region-as-kill)
  (define-key function-keymap "e" 'lisp-complete-symbol)
  (define-key function-keymap "0" 'yank)

  (define-key function-keymap "1" "\^e\^f\^@\^p")	; mark line
  (define-key function-keymap "2" 'kill-rectangle)
  (define-key function-keymap "3" 'yank-rectangle)

  (define-key function-keymap "4" 'backward-kill-sentence)
  (define-key function-keymap "5" 'backward-sentence)
  (define-key function-keymap "6" 'forward-sentence)
  (define-key function-keymap "," 'kill-sentence)

  (define-key function-keymap "7" "\e0\^k")		; kill to beg line
  (define-key function-keymap "8" 'beginning-of-line)
  (define-key function-keymap "9" 'end-of-line)
  (define-key function-keymap "-" "\e1\^k")		; kill line & newline

  (define-key function-keymap "\^a" 'backward-kill-word)
  (define-key function-keymap "\^b" 'backward-word)
  (define-key function-keymap "\^c" 'forward-word)
  (define-key function-keymap "\^d" 'kill-word)
  nil)

(defun vt200-hook ()
  "VT2[02]0 Terminal Initialization"
  (vt100-hook)
  (define-key function-keymap "s" 'prev-complex-command) ; select
  (define-key function-keymap "x" 'rerun-prev-command) ; do
  nil)

; Televideo 950 Initialization (Not Done Yet)

(defun tvi950-hook ()
  "Televidiot Customization"
  nil)

; Sun Workstation Initialization (Merge with VT keypad)
; Use what-line as a place holder

(setq sun-esc-bracket t)

(defun sun-hook ()
  "Define a few other function keys"
  (define-key sun-raw-map "192z" 'what-line) ; L1
  (define-key sun-raw-map "208z" 'what-line) ; R1
  (define-key sun-raw-map "209z" 'what-line) ; R2
  (define-key sun-raw-map "211z" 'what-line) ; R4
  (define-key sun-raw-map "212z" 'what-line) ; R5
  (define-key sun-raw-map "224z" 'what-line) ; T1 CAPS
  (define-key sun-raw-map "225z" 'describe-key-briefly) ; T2
  (define-key sun-raw-map "231z" 'describe-function) ; T8
  (define-key sun-raw-map "232z" 'describe-variable) ; T9
  (define-key suntool-map "ar" 'what-line) ; r1
  (define-key suntool-map "br" 'what-line) ; r2
  (define-key suntool-map "cr" 'what-line) ; r3
  (define-key suntool-map "dr" 'what-line) ; r4
  (define-key suntool-map "er" 'what-line) ; r5
  (define-key suntool-map "fr" 'what-line) ; r6  
  (define-key suntool-map "bt" 'describe-key-briefly) ; t2
  (define-key suntool-map "ht" 'describe-function) ; t8
  (define-key suntool-map "it" 'describe-variable) ; t9
  nil)

; Stolen from lisp/term/sun.el

(defun scroll-down-in-place (n)
  (interactive "p")
  (previous-line n)
  (scroll-down n))

(defun scroll-up-in-place (n)
  (interactive "p")
  (next-line n)
  (scroll-up n))

(defun prev-complex-command ()
  "Select Previous-complex-command"
  (interactive)
  (if (zerop (minibuffer-depth))
      (repeat-complex-command 1)
    (previous-complex-command 1)))

(defun rerun-prev-command ()
  "Repeat Previous-complex-command."
  (interactive)
  (eval (nth 0 command-history)))

? Thanks,
? Peter Wisnovsky
? pswisnov@shrike.bcm.tmc.edu
? pswisnov@phoenix.princeton.edu


	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
	Careful with that VAX Eugene!

janssen@titan.SW.MCC.COM (Bill Janssen) (07/27/88)

With the window system hacks, it is no longer sufficient to case
on TERM; you must also consider the value of "window-system".
If (eq window-system 'x), the correct value for term-setup-hook
is 'x-pop-up-window (at least for the near future).

I believe that version 19 will have a separate terminal initialization
file, .emacs_term_init (or some name with fewer than 14 chars).

Bill
--
 Bill Janssen, MCC Software Technology Program
 ARPA:  janssen@sw.mcc.com
 UUCP:  {seismo,harvard,gatech,pyramid}!ut-sally!im4u!milano!janssen