;;; emacs18to19.el          Version 1.0                         9/29/94
;;;
;;; Author:          James A. Bednar
;;; Internet email:  jbednar@cs.utexas.edu
;;; 
;;; 
;;; This GNU Emacs lisp file modifies most keybindings and some
;;; functions from GNUEmacs v18.58 to behave like those in GNUEmacs
;;; v19.  The changes enable a user to switch between v18 on the Amiga
;;; and v19 on Unix without confusion.  This is only an interim
;;; solution to the lack of a port of v19 to the Amiga; once that has
;;; been completed by someone, this file will be of historical
;;; interest only.  
;;; 
;;;
;;; Except as detailed in the charts below, all of the globally bound
;;; keys from Emacs v19 (for functions which are present in v18)
;;; should have identical keybindings.  Of course, there are many,
;;; many functions which have been added in v19, and those functions
;;; will not be available until a full port is done.  The good news is
;;; that nearly all of the most popular functions are also in v18,
;;; judging by whether they were put on the GNUEmacs reference card
;;; from v19 (from the file etc/refcard.tex).  The first table below
;;; lists the exceptions to this rule.
;;; 
;;; 
;;;                V19 features on RefCard not supported
;;;               ***************************************
;;; 
;;;   RefCard Section      Key         Status under v18.58
;;;  -------------------- ----------- ---------------------------------
;;;   Incremental Search   M-p         unbound, function not available
;;;   Incremental Search   M-n         unbound, function not available
;;;   Multiple Windows     C-x 4 C-o   unbound, function broken
;;;   Multiple Windows     C-x 4 r     unbound, function not available
;;;   Minibuffer           M-p         unbound, function not available
;;;   Minibuffer           M-n         unbound, function not available
;;;   Minibuffer           M-r         unbound, function not available
;;;   Minibuffer           M-s         unbound, function not available
;;;  -------------------- ----------- ---------------------------------
;;;
;;;
;;; There is also one keybinding on the reference card which remains 
;;; different from v19:
;;;
;;;
;;;          V19 features on RefCard with different keybindings
;;;         ****************************************************
;;; 
;;;   RefCardSection         Command                     v18     v19
;;;  ---------------------- --------------------------- ------- -------
;;;   Incremental Search     Exit incremental search     ESC     RET
;;;  ---------------------- --------------------------- ------- -------
;;;   
;;;
;;; Of the globally-bound functions which are not on the reference
;;; card, the ones whose keybindings remain different from v19 are
;;; listed in the table below.  Note that the statements which
;;; redefine keys not on the reference card have been marked with ##.
;;; Since I have not included any documentation other than the
;;; reference card, some people might want to comment these lines out
;;; if they find the binding of their favorite function to be
;;; mysteriously redefined.  
;;; 
;;;
;;;            Other V19 features with different keybindings
;;;           ***********************************************
;;; 
;;;   Command              v18                    v19
;;;  -------------------- ---------------------- ----------------------
;;;   digit-argument       M-0 through M-9        M-0   through M-9
;;;                                               C-0   through C-9
;;;                                               C-M-0 through C-M-9
;;;
;;;   negative-argument    M--                    M-- 
;;;                                               C--
;;;                                               C-M--
;;;  -------------------- ---------------------- ----------------------
;;;
;;;
;;; Note also that M-x ispell-region and M-x ispell-buffer work under
;;; Amiga GNU Emacs 18, but only if ISpell has been installed (from
;;; ispell-3.3LJR.LHA on AmiNet). 
;;;
;;; 
;;; 
;;; 
;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 
;;; 
;;;
;;; To use this file, place it somewhere in your emacs load path
;;; (e.g., in GNUEmacs:lisp) and add lines like the following two in
;;; your .emacs file:
;;; 
;;; ;; Modify keybindings for compatibility with Emacs v19:
;;; (load "emacs18to19")
;;; 
;;; You may want to use a byte-compiled version to reduce loading time.
;;; 
;;; This file may be redistributed freely as long as this notice 
;;; remains intact.  If you distribute modified versions of this 
;;; file, please document your changes and add your name to these
;;; comments.  If you discover a bug, or have added more keybindings
;;; or functions from v19, please email me at the above address.
;;; Note that the GNU functions are covered by the GNU General 
;;; Public License; see the included file COPYING for details.
;;; 
;;; Have fun!
;;;
;;; Jim
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;
;;                      ADDED KEY BINDINGS 
;;
;;   These keys were unbound in v18, so these commands do not disturb
;;   any previous functionality.
;;
(global-set-key   "\e{"        'backward-paragraph)
(global-set-key   "\e}"        'forward-paragraph)
(global-set-key   "\C-x3"      'split-window-horizontally)
(global-set-key   "\e\C-r"     'isearch-backward-regexp)
(global-set-key   "\C-x6}"     'enlarge-window-horizontally)   ; ##
(global-set-key   "\C-x6{"     'shrink-window-horizontally)    ; ##
(global-set-key   "\C-xXq"     'top-level)                     ; ##
(global-set-key   "\C-xXq"     'top-level)                     ; ##
;;
;;                    MODIFIED KEY BINDINGS 
;;
;;   The bindings of these keys bindings changed from v18 to v19.
;;   These should be the only commands which no longer operate 
;;   using the same keys as they did in v18.
;;
;; 
(global-set-key "\e$" 'ispell-word)  ;; Old binding was to 'spell-word
;
(global-unset-key "\C-x\e")          ;; Old binding was to 'repeat-complex-command
(global-unset-key "\C-xn")           ;; Old binding was to 'narrow-to-region  ##
(global-unset-key "\C-xr")           ;; Old binding was to 'copy-rectangle-to-register
(global-unset-key "\C-xa")           ;; Old binding was to 'append-to-buffer
;;
;;                   MORE ADDED KEY BINDINGS 
;;
;;   The bindings of these keys bindings changed from v18 to v19.
;;   In order to add these new bindings, the old ones for the keys in 
;;   the section Modified Key Bindings had to be changed.  Once those
;;   have been changed, the new bindings below can be added.
;;   For instance, C-x n becomes a prefix, allowing the new bindings
;;   of 'narrow-to-page, etc.
;;
;; 
(global-set-key   "\C-x\e\e"   'repeat-complex-command)
;
(global-set-key   "\C-xnn"     'narrow-to-region)              ; ##
(global-set-key   "\C-xnp"     'narrow-to-page)                ; ##
(global-set-key   "\C-xnw"     'widen)                         ; ##
;
(global-set-key   "\C-xrr"     'copy-rectangle-to-register)
(global-set-key   "\C-xrk"     'kill-rectangle)
(global-set-key   "\C-xry"     'yank-rectangle)
(global-set-key   "\C-xro"     'open-rectangle)
(global-set-key   "\C-xrt"     'string-rectangle)              ; ##
(global-set-key   "\C-xrc"     'clear-rectangle)               ; ##
;
(global-set-key   "\C-xrs"     'copy-to-register)
(global-set-key   "\C-xrx"     'copy-to-register)              ; ##
(global-set-key   "\C-xri"     'insert-register)
(global-set-key   "\C-xrg"     'insert-register)               ; ##
(global-set-key   "\C-xr "     'point-to-register)
(global-set-key   "\C-xrj"     'register-to-point)
(global-set-key   "\C-xr\C-@"  'point-to-register)             ; ##
(global-set-key   "\C-xr\C- "  'point-to-register)             ; ##
;;
(global-set-key   "\C-xag"     'add-global-abbrev)
(global-set-key   "\C-xal"     'add-mode-abbrev)
(global-set-key   "\C-xa+"     'add-mode-abbrev)               ; ##
(global-set-key   "\C-xa\C-a"  'add-mode-abbrev)               ; ##
(global-set-key   "\C-xaig"    'inverse-add-global-abbrev)
(global-set-key   "\C-xa-"     'inverse-add-global-abbrev)     ; ##
(global-set-key   "\C-xail"    'inverse-add-mode-abbrev)
(global-set-key   "\C-xae"     'expand-abbrev)
(global-set-key   "\C-xa "     'expand-abbrev)                 ; ##



;;
;; Functions imported from GNUEmacs 19:
;;

;; Because the functions below don't load rect.el automatically,
(load "rect")
;; If you don't use the rectangle functions, you may comment out
;; the above line to save a small amount of memory and reduce
;; loading time very slightly. 

;;; From rect.el in the GNUEmacs v19.22 distribution (unmodified)
;;; I find this function to be extremely useful, so I had to have
;;; it...  No doubt there are many more that are similarly useful, but
;;; I have not had the inclination to include them. -- J.A.B.
;;;
;;;###autoload
(defun string-rectangle (start end string)
  "Insert STRING on each line of the region-rectangle, shifting text right.
The left edge of the rectangle specifies the column for insertion.
This command does not delete or overwrite any existing text.

Called from a program, takes three args; START, END and STRING."
  (interactive "r\nsString rectangle: ")
  (operate-on-rectangle 'string-rectangle-line start end nil)
  (goto-char start))

(defun string-rectangle-line (startpos begextra endextra)
  (let ((column (+ (current-column) begextra endextra)))
    (goto-char startpos)
    (let ((ocol (current-column)))
      (skip-chars-forward " \t")
      (setq column (+ column (- (current-column) ocol))))
    (delete-region (point)
		   ;; Use skip-chars-backward's LIM argument to leave
		   ;; characters before STARTPOS undisturbed.
                   (progn (skip-chars-backward " \t" startpos)
			  (point)))
    (insert string)))

;;; Material from v19 rect.el ends here
