From: southern@sunny.NoSubdomain.NoDomain (Lawrence Buja)
Subject: ]-mode   (was Re: hand injuries
Reply-To: southern@ncar.ucar.edu
Organization: National Center for Atmospheric Research
Distribution: usa
Date: Wed, 27 Jan 1993 16:13:35 GMT

Barry A. Warsaw writes:
>
>I keep hearing about new key input devices (not keyboards) which are
>supposed to be much better for your hands. Can anybody give more
>information on these things and does anybody use one regularly?  Any
>Sun type-4 replacements available?

Though this is not exactly what you are asking about, I thought I'd post
it up anyway.  I inherited the following set-up from a friend who was a
great programmer debilitated by a stroke/heart-attack which greatly
limited his motion.

Essentially it make ] act like another ESC key.  Since ]-anything is
not, by default, defined, you can make it anything you like and not
worry about nuking any emacs default key sequences.

First I set up the defaults sequences, then I apply the mode specific
definitions.  For example, my macs-lisp-mode-hook looks like:

    (setq emacs-lisp-mode-hook
          (function
            (lambda nil
              (load                   "my-modekeys"  nil t)
              (define-emacs-lisp-mode-keys)
              (setq comment-start     ";")
              (setq set-fill-prefix   "; ")
              (setq default-directory "~ccmproc2/emacs/")
             )
           )
    )

The first line after the "(lambda nil" line loads it, then the
next line applies the emacs-lisp specific definitions.


/\      Lawrence Buja           Climate and Global Dynamics Division
  \_][  southern@ncar.ucar.edu  National Center for Atmospheric Research
      \_________________________Boulder,_Colorado___80307-3000__________


;  
;   File:   /home/ccmproc2/emacs/my-modekeys.el  (4607 bytes) 
;   Date:   Wed Jan 27 08:57:45 1993
;   Author: Lawrence Buja <ccmproc2@sunny>
;  
;   ] key definitions functions to be called by mode hooks
;   
;   See ~ccmproc2/emacs/hooks.el for examples on loading the mode-specific definitions
;  
;   Default map to be used with all modes.  
;
;   Warning: Many of these functions are NOT generic emacs functions.
;
 (local-set-key "][" 'hide-all-non-matching-lines)
 (local-set-key "]'" 'other-window)
 (local-set-key "] " 'set-mark-command)
 (local-set-key "];" 'goto-line)
 (local-set-key "]!" 'shell-command)
 (local-set-key "]=" 'occur-all)
 (local-set-key "]-" 'line-boundary)
 (local-set-key "]1" 'delete-other-windows)
 (local-set-key "]2" 'split-window-vertically-find-file)
 (local-set-key "]3" 'scroll-other-window)
 (local-set-key "]0" 'change-case)
 (local-set-key "]a" 'show-file-buffers)
 (local-set-key "]b" 'switch-to-buffer-quick)
 (local-set-key "]c" 'comment-region)
 (local-set-key "]d" 'kill-line)
 (local-set-key "]i" 'overwrite-mode)
 (local-set-key "]j" 'merge-lines)
 (local-set-key "]k" 'kill-region)
 (local-set-key "]n" 'bury-buffer)
 (local-set-key "]o" 'open-line-below)
 (local-set-key "]r" 'search-forward)
 (local-set-key "]s" 'ispell-complete-word)
 (local-set-key "]t" 'toggle-truncate)
 (local-set-key "]u" 'uncomment-region)
 (local-set-key "]w" 'widen)
 (local-set-key "]y" 'yank)
 (local-set-key "]z" 'zap-to-char)
 (local-set-key "]]" 'self-insert-command)

(defvar fortran-mode-keys    nil "*Nil if fortran mode keys have not yet been defined.")
(defvar ccmfor-mode-keys     nil "*Nil if ccmfor mode keys have not yet been defined.")
(defvar text-mode-keys       nil "*Nil if text-mode keys have not yet been defined.")
(defvar emacs-lisp-mode-keys nil "*Nil if emacs-lisp mode keys have not yet been defined.")
(defvar tex-mode-keys        nil "*Nil if tex mode keys have not yet been defined.")

(defun define-fortran-mode-keys () "Define additional fortran-mode keys."
(if fortran-mode-keys  ()  (setq fortran-mode-keys t)
 (local-set-key "]j" 'ccmfor-unsplit-nextline)
 (local-set-key "]e" 'end-of-fortran-subprogram)
 (local-set-key "]ff" 'fortran-compile-buffer)
 (local-set-key "]fb" 'fortran-beautify-subprogram)    
 (local-set-key "]fc" 'fortran-compile-buffer)         
 (local-set-key "]fe" 'end-of-fortran-subprogram)      
 (local-set-key "]fm" 'mark-fortran-subprogram)        
 (local-set-key "]fn" 'narrow-to-fortran-subprogram)   
 (local-set-key "]fs" 'beginning-of-fortran-subprogram)
 (local-set-key "]g" 'get-subroutine)
 (local-set-key "]l" 'lock)
 (local-set-key "]m" 'mark-fortran-subprogram)
 (local-set-key "]pm" 'mark-jobstep)        
 (local-set-key "]pn" 'narrow-to-jobstep)   
 (local-set-key "]pb" 'beautify-jobstep)    
 (local-set-key "]pe" 'end-of-jobstep)      
 (local-set-key "]ps" 'beginning-of-jobstep)
 (local-set-key "]pp" 'printout)
 (local-set-key "]pd" 'printout-debug)
 (local-set-key "]s" 'fortran-split-line)
 (local-set-key "]w" 'fortran-window-create)
 (local-set-key "]x" 'f77-file)
))


(defun define-text-mode-keys () "Define additional text-mode keys."
(if text-mode-keys ()  (setq text-mode-keys t)
))

(defun define-emacs-lisp-mode-keys () "Define additional emacs-lisp-mode keys."
(if emacs-lisp-mode-keys  () 
 (setq emacs-lisp-mode-keys t)
 (local-set-key "]b" 'beginning-of-defun)
 (local-set-key "]e" 'end-of-defun)
 (local-set-key "]m" 'mark-defun)
 (local-set-key "]l" 'narrow-to-defun)
 (local-set-key "]x" 'eval-defun)
 ))

(defun define-tex-mode-keys () "Define additional tex-mode keys."
(if tex-mode-keys () (setq tex-mode-keys t)
 (local-set-key "]x" 'tex-file)
 (local-set-key "]g" 'ghostview-tex-file)
 (local-set-key "]p" 'print-tex-file)
))

(defun define-ccmfor-mode-keys () "Define additional ccmfor-mode keys."
(if ccmfor-mode-keys  ()  (setq ccmfor-mode-keys t)
 (local-set-key "]j" 'ccmfor-unsplit-nextline)
 (local-set-key "]-" 'ccmfor-insert-dash-comment)
 (local-set-key "]a" 'ccmfor-align-continuation)
 (local-set-key "]A" 'ccmfor-align-continuation)
 (local-set-key "]e" 'end-of-ccmfor-subprogram)
 (local-set-key "]E" 'end-of-ccmfor-subprogram)
 (local-set-key "]f" 'ccmfor-fill-align-continuation)
 (local-set-key "]F" 'ccmfor-fill-align-continuation)
 (local-set-key "]l" 'ccmfor-indent-line)
 (local-set-key "]L" 'ccmfor-indent-line)
 (local-set-key "]m" 'mark-ccmfor-subprogram)
 (local-set-key "]M" 'mark-ccmfor-subprogram)
 (local-set-key "]p" 'ccmfor-previous-statement)
 (local-set-key "]P" 'ccmfor-previous-statement)
 (local-set-key "]s" 'ccmfor-split-line)
 (local-set-key "]S" 'ccmfor-split-line)
 (local-set-key "]u" 'ccmfor-unsplit-line)
 (local-set-key "]U" 'ccmfor-unsplit-line)
 (local-set-key "]w" 'ccmfor-window-create)
 (local-set-key "]W" 'ccmfor-window-create)
 ))



Newsgroups: comp.emacs