[comp.sys.hp] using HP function keys with emacs & HP-UX

eli@spdcc.COM (Steve Elias) (02/01/90)

does anyone out there have nifty *.el files which will allow me
to define my HPUX workstation function keys to arbitrary emacs commands??

thanks...



-- 
/* eli@spdcc.com ; 617-932-5598 */   
/* usenet proves that the Turing Test can be passed. */

raveling@isi.edu (Paul Raveling) (02/08/90)

In article <1461@ursa-major.SPDCC.COM>, eli@spdcc.COM (Steve Elias) writes:

> does anyone out there have nifty *.el files which will allow me
> to define my HPUX workstation function keys to arbitrary emacs commands??

	To do it decently you need to modify some source
	in emacs -- otherwise only a few of the keys you'd
	like to map are accessible.

	A few months ago I posted about an 8-part set of files
	on the gnu.emacs group to do this for 18.54.  Perhaps
	someone has them, or a variant of them, and could post
	them here.  Otherwise I can dig them up myself and either
	post or email them in about 1.5 weeks -- will be out of
	town until then.


----------------
Paul Raveling
Raveling@isi.edu

walter@hpsad.HP.COM (Walter Coole) (02/08/90)

Here's a hp.el that I use:

;;
;;    To Anyone Who Has Figured Out how to get the `Extend char' key on    
;;    their HP2392  to act as the Meta key, using GNU emacs 18.50 on an HP
;;    300 series machine (a > 350, to be exact): Help!  
;;    
;;    it is my understanding that the extend char key does not just set the
;;    top bit of the key that you hit, it accesses an alternate character
;;    set.  some keys, like "z" dont seem to have an extended char.  if you
;;    do find a way of doing this, PLEASE let me know...  it would be most
;;    useful.
;;    
;;       Also, while I'm here: if you have been able to do the above, you
;;    are also probably smart enough to have made a default.el which sets up
;;    all the special keys to the right of the main keyboard to be useful
;;    (i.e. `Clear display', `Prev', the arrow keys, etc).
;;    
;;    
;;    here is what we use for our lisp/term/hp2392.el file, minus some local
;;    junk that you probably dont want anyway...  (yes, i know, this should
;;    probably use the keypad stuff that has already been set up, but i had
;;    this written before i knew that it existed.  if someone has a cleaner
;;    hack, i would be interested in that too.)
;;    
;;                                                                          
;;
;; cursor pad
;;
(global-set-key "\C-_" 'help-command)	; Replace undo
(setq help-char ?)
(define-key global-map "\^h" 'backward-delete-char-untabify)
(define-key esc-map "\^h" 'backward-kill-word)
(setq text-mode-hook 'turn-on-auto-fill)

(global-set-key "\eA" 'previous-line)	; up arrow
(global-set-key "\eB" 'next-line)	; down arrow
(global-set-key "\eC" 'forward-char)	; right arrow
(global-set-key "\eD" 'backward-char)	; left arrow
(global-set-key "\eh" 'home)		; home to the top of the window


(global-set-key "\eS" 'beginning-of-buffer); shift up arrow - top of file
(global-set-key "\eT" 'end-of-buffer)	; shift down arrow - end of file
(global-set-key "\e&rR" 'end-of-line)	; shift right arrow - end of line
(global-set-key "\e&rL" 'beginning-of-line); shift left arrow - beg of line
(global-set-key "\eF" 'home-bottom)	; shift home to bottom of window


;;
;; named keys
;;

(global-set-key "\eK" 'clear-end-of-line) ; clear line
(global-set-key "\eJ" 'hide-window)	; clear display
(global-set-key "\eL" 'insert-line)	; insert line
(global-set-key "\eM" 'delete-line)	; delete line
(global-set-key "\eQ" 'overwrite-mode)	; insert char
(global-set-key "\eP" 'delete-char)	; delete char
(global-set-key "\eV" 'scroll-down)	; prev screen
(global-set-key "\eU" 'scroll-up)	; next screen


(global-set-key "\e&a0C" 'beginning-of-line) ; from shift clear line & display
(global-set-key "\eG" 'beginning-of-line) ; from shift clear line & display

;;(global-set-key "\eK" 'clear-end-of-line) ; shift clear line
;;(global-set-key "\eJ" 'delete-window)	; shift clear display
;;(global-set-key "\eL" 'insert-line)	; shift insert line
;;(global-set-key "\eM" 'delete-line)	; shift delete line
(global-set-key "\eN" 'overwrite-mode)	; shift insert char
(global-set-key "\eO" 'delete-char)	; shift delete char
(global-set-key "\e&r-1H" 'scroll-down)	; shift prev
(global-set-key "\e&r+1H" 'scroll-up)	; shift next



;;
;; function definitions for the cursor and named keys
;;

(defun home ()
  "Home to the upper left of the window."
  (interactive)

  (move-to-window-line 0)
  (move-to-column (window-hscroll (selected-window)))
  (setq temporary-goal-column (window-hscroll (selected-window)))
  )


(defun home-bottom ()
  "Home to the lower right of the window."
  (interactive)

  (move-to-window-line -1)
  (move-to-column (window-hscroll (selected-window)))
  (setq temporary-goal-column (window-hscroll (selected-window)))
  )


(defun insert-line ()
  "Insert a line before the current line."
  (interactive)

  (let ((org-point (point))
	)
    (condition-case conditions
	(progn
	  (beginning-of-line)
	  (open-line 1)
	  )
      (error (goto-char org-point)
	     (signal (car conditions) (cdr conditions))
	     )
      )
    )
  
  )


(defun delete-line ()
  "Delete the current line."
  (interactive)

  (let ((org-point (point))
	)
    (condition-case conditions
	(kill-region (progn
		       (beginning-of-line)
		       (point)
		       )
		     (progn
		       (end-of-line)
		       (if (eobp)
			   (point)
			 (forward-char)
			 (point)
			 )
		       )
		     )
      (error (goto-char org-point)
	     (signal (car conditions) (cdr conditions))
	     )
      )
    )

  )


(defun clear-end-of-line ()
  "Clear to the end of the line."
  (interactive)

  (let ((org-point (point))
	)
    (condition-case conditions
	(kill-region (point)
		     (progn
		       (end-of-line)
		       (point)
		       )
		     )
      (error (goto-char org-point)
	     (signal (car conditions) (cdr conditions))
	     )
      )
    )

  )


(defun hide-window ()
  "Hide the current window from view."
  (interactive)

  (if (one-window-p t)
      (bury-buffer)
    (delete-window)
    )
  )




;;
;; set up dired keys
;;

;;(define-key dired-mode-map "\eA" 'dired-previous-line)
;;(define-key dired-mode-map "\eB" 'dired-next-line)



;;
;; set up the pf keys functions
;;

(global-set-key "\C-x@"'set-mark-command)


(defun update-pf-keys ()
  "Display the updated pf key labels."
  (send-string-to-terminal "\e&jB")
  (sleep-for 1)
)


(defun set-pf (key-num label def)
  "Define a pf key."
  (interactive)

  (send-string-to-terminal
   (concat "\e&f0a" key-num "k" (length label) "d" (length def) "L"
	   label def)
   )

  )


(defun clr-pf (key-num)
  "Clear a pf key."
  (interactive)

  (send-string-to-terminal (concat "\e&f0a" key-num "k1d-1L "))
  
  )



;;
;; define the main level pf keys
;;

(defun pf-keys-main ()
  "Display main level pf keys."
  (interactive)

  (message "Main options...")
  (sit-for 0)
  
  (set-pf 1 "Printer Options" "\expf-keys-printer\r")
  (set-pf 2 " Buffer  Options" "\expf-keys-buffer\r")
  (set-pf 3 "  Word   Options" "\expf-keys-word\r")
  (set-pf 4 "Compile" "\excompile")
  
  (set-pf 5 "  Load    File" "\C-x")
  (set-pf 6 "  Save    Files" "\C-xs")
  (set-pf 7 "  Mark   Region" "\C-x@")
  (set-pf 8 "  Undo" "\exundo\r")

  (update-pf-keys)
  (message "")

  )


;;
;; define the print option pf keys
;;

(defun pf-keys-printer ()
  "Display printer option pf keys."
  (interactive)
  
  (message "Printer options...")
  (sit-for 0)
  
  (clr-pf 1 )
  (clr-pf 2 )           ; these keys send to various printers at our site
  (clr-pf 3 )
  (clr-pf 4 )
  
  (set-pf 5 " Spell   Buffer"  "\exspell-buffer\r")
  (set-pf 6 "  Find    Word"  "\exfind-word\r")
  (set-pf 7 "  Main  Options" "\expf-keys-main\r")
  (set-pf 8 "  Undo" "\exundo\r")

  (update-pf-keys)
  (message "")

  )




;;
;; define the buffer option pf keys
;;

(defun pf-keys-buffer ()
  "Display buffer option pf keys."
  (interactive)
  
  (message "Buffer options...")
  (sit-for 0)
  
  (set-pf 1 "  One    Window" "\C-x1")
  (set-pf 2 " Split   Screen" "\C-x4b\r")
  (set-pf 3 " Switch  Buffer" "\C-xb?")
  (set-pf 4 "  Kill   Buffer" "\C-xk\r")
  
  (set-pf 5 "  Read    Mail" "\exrmail\r")
  (set-pf 6 "  Send    Mail" "\C-xm")
  (set-pf 7 "  Main  Options" "\expf-keys-main\r")
  (set-pf 8 "  Undo" "\C-_")

  (update-pf-keys)
  (message "")

  )





;;
;; define the word option pf keys
;;

(defun pf-keys-word ()
  "Display buffer option pf keys."
  (interactive)
  
  (message "Word options...")
  (sit-for 0)
  
  (set-pf 1 "  Page   Break" "\C-a\C-q\C-l\r")
  (set-pf 2 "Compress Print" "\C-q\C-c")    ; we got a filter for these
  (set-pf 3 " Under    Line" "\C-q\C-u")    ; letters to translate them
  (set-pf 4 "  Bold    Text" "\C-q\C-b")    ; into something useful
  
  (set-pf 5 " Center   Text"  "\excenter-line\r")
  (set-pf 6 "  Fill  Paragrph" "\eq")
  (set-pf 7 "  Main   Options" "\expf-keys-main\r")
  (set-pf 8 "  Undo" "\C-_")

  (update-pf-keys)
  (message "")

  )



;;
;; put the options on the screen
;;


(sit-for 0)
(update-pf-keys)
(sleep-for 1)
(pf-keys-main)
(sleep-for 1)