-;;; tpu-extras.el --- Scroll margins and free cursor mode for TPU-edt
+;;; tpu-extras.el --- scroll margins and free cursor mode for TPU-edt
-;; Copyright (C) 1993 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 2000 Free Software Foundation, Inc.
;; Author: Rob Riepel <riepel@networking.stanford.edu>
;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
-;; Keywords: tpu-edt
+;; Keywords: emulations
;; This file is part of GNU Emacs.
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
+;; Use the functions defined here to customize TPU-edt to your tastes by
+;; setting scroll margins and/or turning on free cursor mode. Here's an
+;; example for your .emacs file.
+
+;; (tpu-set-cursor-free) ; Set cursor free.
+;; (tpu-set-scroll-margins "10%" "15%") ; Set scroll margins.
+
+;; Scroll margins and cursor binding can be changed from within emacs using
+;; the following commands:
+
+;; tpu-set-scroll-margins or set scroll margins
+;; tpu-set-cursor-bound or set cursor bound
+;; tpu-set-cursor-free or set cursor free
+
+;; Additionally, Gold-F toggles between bound and free cursor modes.
+
+;; Note that switching out of free cursor mode or exiting TPU-edt while in
+;; free cursor mode strips trailing whitespace from every line in the file.
+
+
+;;; Details:
+
;; The functions contained in this file implement scroll margins and free
;; cursor mode. The following keys and commands are affected.
;; performance of TPU-edt on slower computers. In order to support the
;; widest range of computers, scroll margin support is optional.
-;; I don't know for a fact that the overhead associated with scroll
-;; margin support is significant. If you find that it is, please send me
+;; It's actually not known whether the overhead associated with scroll
+;; margin support is significant. If you find that it is, please send
;; a note describing the extent of the performance degradation. Be sure
;; to include a description of the platform where you're running TPU-edt.
;; Send your note to the address provided by Gold-V.
;; important aspects of the real TPU/edt. Those who miss free cursor mode
;; and/or scroll margins will appreciate these implementations.
-;;; Usage:
-
-;; To use this file, simply load it after loading TPU-edt. After that,
-;; customize TPU-edt to your tastes by setting scroll margins and/or
-;; turning on free cursor mode. Here's an example for your .emacs file.
-
-;; (load "tpu-edt") ; Load the base TPU-edt
-;; (load "tpu-extras") ; and the extras.
-;; (tpu-set-scroll-margins "10%" "15%") ; Set scroll margins.
-
-;; Once the extras are loaded, scroll margins and cursor binding can be
-;; changed with the following commands:
-
-;; tpu-set-scroll-margins or set scroll margins
-;; tpu-set-cursor-bound or set cursor bound
-;; tpu-set-cursor-free or set cursor free
-
-;; Additionally, Gold-F toggles between bound and free cursor modes.
-
-;; Note that switching out of free cursor mode or exiting TPU-edt while in
-;; free cursor mode strips trailing whitespace from every line in the file.
-
;;; Code:
-;;; Revision Information
+;;; Gotta have tpu-edt
-(defconst tpu-extras-revision "$Revision: 3.5 $"
- "Revision number of the TPU-edt extras.")
+(require 'tpu-edt)
;;; Customization variables
-(defconst tpu-top-scroll-margin 0
+(defcustom tpu-top-scroll-margin 0
"*Scroll margin at the top of the screen.
-Interpreted as a percent of the current window size.")
-(defconst tpu-bottom-scroll-margin 0
+Interpreted as a percent of the current window size."
+ :type 'integer
+ :group 'tpu)
+(defcustom tpu-bottom-scroll-margin 0
"*Scroll margin at the bottom of the screen.
-Interpreted as a percent of the current window size.")
+Interpreted as a percent of the current window size."
+ :type 'integer
+ :group 'tpu)
-(defvar tpu-backward-char-like-tpu t
+(defcustom tpu-backward-char-like-tpu t
"*If non-nil, in free cursor mode backward-char (left-arrow) works
just like TPU/edt. Otherwise, backward-char will move to the end of
-the previous line when starting from a line beginning.")
+the previous line when starting from a line beginning."
+ :type 'boolean
+ :group 'tpu)
;;; Global variables
;;; Hooks -- Set cursor free in picture mode.
;;; Clean up when writing a file from cursor free mode.
-(if tpu-gnu-emacs18-p
- (or (memq 'tpu-set-cursor-free edit-picture-hook)
- (setq edit-picture-hook
- (cons 'tpu-set-cursor-free edit-picture-hook)))
- (add-hook 'picture-mode-hook 'tpu-set-cursor-free))
+(add-hook 'picture-mode-hook 'tpu-set-cursor-free)
(defun tpu-write-file-hook nil
"Eliminate whitespace at ends of lines, if the cursor is free."
- (if (and (buffer-modified-p) tpu-cursor-free) (picture-clean)))
+ (if (and (buffer-modified-p) tpu-cursor-free) (tpu-trim-line-ends)))
(or (memq 'tpu-write-file-hook write-file-hooks)
(setq write-file-hooks
(interactive "p")
(let ((beg (tpu-current-line)))
(backward-char 1)
- (forward-line (- 1 num))
+ (forward-visible-line (- 1 num))
(tpu-top-check beg num)))
(defun tpu-next-end-of-line (num)
Prefix argument serves as repeat count."
(interactive "p")
(let ((beg (tpu-current-line)))
+ (or (bolp) (>= 0 num) (setq num (- num 1)))
(next-line-internal (- num))
(tpu-top-check beg num)
(beginning-of-line)))
;;; Function to set scroll margins
+;;;###autoload
(defun tpu-set-scroll-margins (top bottom)
"Set scroll margins."
(interactive
(message "Scroll margins set. Top = %s%%, Bottom = %s%%"
tpu-top-scroll-margin tpu-bottom-scroll-margin)))
-(fset 'set\ scroll\ margins 'tpu-set-scroll-margins)
-(fset 'SET\ SCROLL\ MARGINS 'tpu-set-scroll-margins)
-
;;; Functions to set cursor bound or free
+;;;###autoload
(defun tpu-set-cursor-free nil
"Allow the cursor to move freely about the screen."
(interactive)
GOLD-map)
(message "The cursor will now move freely about the screen."))
+;;;###autoload
(defun tpu-set-cursor-bound nil
"Constrain the cursor to the flow of the text."
(interactive)
- (picture-clean)
+ (tpu-trim-line-ends)
(setq tpu-cursor-free nil)
(substitute-key-definition 'tpu-set-cursor-bound
'tpu-set-cursor-free
GOLD-map)
(message "The cursor is now bound to the flow of your text."))
-(fset 'set\ cursor\ bound 'tpu-set-cursor-bound)
-(fset 'SET\ CURSOR\ BOUND 'tpu-set-cursor-bound)
-(fset 'set\ cursor\ free 'tpu-set-cursor-free)
-(fset 'SET\ CURSOR\ FREE 'tpu-set-cursor-free)
-
-
-;;; Keypad Mapping
-
-(define-key GOLD-map "F" 'tpu-set-cursor-free) ; F
-(define-key GOLD-map "f" 'tpu-set-cursor-free) ; f
-
;;; tpu-extras.el ends here