+2007-08-14 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * emulation/tpu-extras.el: Remove spurious * in docstrings.
+ Put its autoloads into tpu-edt.el rather than loaddefs.el.
+ (tpu-cursor-free-mode): Rename from tpu-cursor-free.
+ Make into a proper minor-mode.
+ (tpu-backward-char, tpu-next-line, tpu-previous-line)
+ (tpu-next-end-of-line, tpu-current-end-of-line): Use new name.
+ (tpu-trim-line-ends-if-needed): Rename from tpu-before-save-hook.
+ (tpu-set-cursor-free, tpu-set-cursor-bound):
+ Delegate to tpu-cursor-free-mode.
+ (tpu-next-line, tpu-previous-line, tpu-forward-line)
+ (tpu-backward-line, tpu-scroll-window-down, tpu-scroll-window-up):
+ Use line-move or forward-line instead of next-line-internal.
+
2007-08-13 Nick Roberts <nickrob@snap.net.nz>
* progmodes/gdb-ui.el (gdb-send): Handle CTRL-D more carefully.
* pcvs-util.el (cvs-qtypedesc-strings): Use new names
combine-and-quote-strings and split-string-and-unquote.
- * subr.el (combine-and-quote-strings): Renamed from strings->string.
- (split-string-and-unquote): Renamed from string->strings.
+ * subr.el (combine-and-quote-strings): Rename from strings->string.
+ (split-string-and-unquote): Rename from string->strings.
2007-08-10 Stefan Monnier <monnier@iro.umontreal.ca>
;;; Customization variables
(defcustom tpu-top-scroll-margin 0
- "*Scroll margin at the top of the screen.
+ "Scroll margin at the top of the screen.
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.
+ "Scroll margin at the bottom of the screen.
Interpreted as a percent of the current window size."
:type 'integer
:group 'tpu)
(defcustom tpu-backward-char-like-tpu t
- "*If non-nil, in free cursor mode backward-char (left-arrow) works
+ "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."
:type 'boolean
;;; Global variables
-(defvar tpu-cursor-free nil
- "If non-nil, let the cursor roam free.")
+;;;###autoload
+(define-minor-mode tpu-cursor-free-mode
+ "Minor mode to allow the cursor to move freely about the screen."
+ :init-value nil
+ (if (not tpu-cursor-free-mode)
+ (tpu-trim-line-ends)))
;;; Hooks -- Set cursor free in picture mode.
(add-hook 'picture-mode-hook 'tpu-set-cursor-free)
-(defun tpu-before-save-hook ()
+(defun tpu-trim-line-ends-if-needed ()
"Eliminate whitespace at ends of lines, if the cursor is free."
- (if (and (buffer-modified-p) tpu-cursor-free) (tpu-trim-line-ends)))
-
-(add-hook 'before-save-hook 'tpu-before-save-hook)
+ (if (and (buffer-modified-p) tpu-cursor-free-mode) (tpu-trim-line-ends)))
+(add-hook 'before-save-hook 'tpu-trim-line-ends-if-needed)
;;; Utility routines for implementing scroll margins
(defun tpu-forward-char (num)
"Move right ARG characters (left if ARG is negative)."
(interactive "p")
- (if tpu-cursor-free (picture-forward-column num) (forward-char num)))
+ (if tpu-cursor-free-mode (picture-forward-column num) (forward-char num)))
(defun tpu-backward-char (num)
"Move left ARG characters (right if ARG is negative)."
(interactive "p")
- (cond ((not tpu-cursor-free)
+ (cond ((not tpu-cursor-free-mode)
(backward-char num))
(tpu-backward-char-like-tpu
(picture-backward-column num))
Prefix argument serves as a repeat count."
(interactive "p")
(let ((beg (tpu-current-line)))
- (if tpu-cursor-free (or (eobp) (picture-move-down num))
- (next-line-internal num))
+ (if tpu-cursor-free-mode (or (eobp) (picture-move-down num))
+ (line-move num))
(tpu-bottom-check beg num)
(setq this-command 'next-line)))
Prefix argument serves as a repeat count."
(interactive "p")
(let ((beg (tpu-current-line)))
- (if tpu-cursor-free (picture-move-up num) (next-line-internal (- num)))
+ (if tpu-cursor-free-mode (picture-move-up num) (line-move (- num)))
(tpu-top-check beg num)
(setq this-command 'previous-line)))
Accepts a prefix argument for the number of lines to move."
(interactive "p")
(let ((beg (tpu-current-line)))
- (cond (tpu-cursor-free
+ (cond (tpu-cursor-free-mode
(let ((beg (point)))
(if (< 1 num) (forward-line num))
(picture-end-of-line)
Accepts a prefix argument for the number of lines to move."
(interactive "p")
(let ((beg (tpu-current-line)))
- (cond (tpu-cursor-free
+ (cond (tpu-cursor-free-mode
(picture-end-of-line (- 1 num)))
(t
(end-of-line (- 1 num))))
"Move point to end of current line."
(interactive)
(let ((beg (point)))
- (if tpu-cursor-free (picture-end-of-line) (end-of-line))
+ (if tpu-cursor-free-mode (picture-end-of-line) (end-of-line))
(if (= beg (point)) (message "You are already at the end of a line."))))
(defun tpu-forward-line (num)
Prefix argument serves as a repeat count."
(interactive "p")
(let ((beg (tpu-current-line)))
- (next-line-internal num)
- (tpu-bottom-check beg num)
- (beginning-of-line)))
+ (forward-line num)
+ (tpu-bottom-check beg num)))
(defun tpu-backward-line (num)
"Move to beginning of previous line.
(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)))
+ (forward-line (- num))
+ (tpu-top-check beg num)))
;;; Movement by paragraph
(let* ((beg (tpu-current-line))
(height (1- (window-height)))
(lines (* num (/ (* height tpu-percent-scroll) 100))))
- (next-line-internal (- lines))
+ (line-move (- lines))
(tpu-top-check beg lines)))
(defun tpu-scroll-window-up (num)
(let* ((beg (tpu-current-line))
(height (1- (window-height)))
(lines (* num (/ (* height tpu-percent-scroll) 100))))
- (next-line-internal lines)
+ (line-move lines)
(tpu-bottom-check beg lines)))
(defun tpu-set-cursor-free ()
"Allow the cursor to move freely about the screen."
(interactive)
- (setq tpu-cursor-free t)
- (substitute-key-definition 'tpu-set-cursor-free
- 'tpu-set-cursor-bound
- GOLD-map)
+ (tpu-cursor-free-mode 1)
(message "The cursor will now move freely about the screen."))
;;;###autoload
(defun tpu-set-cursor-bound ()
"Constrain the cursor to the flow of the text."
(interactive)
- (tpu-trim-line-ends)
- (setq tpu-cursor-free nil)
- (substitute-key-definition 'tpu-set-cursor-bound
- 'tpu-set-cursor-free
- GOLD-map)
+ (tpu-cursor-free-mode -1)
(message "The cursor is now bound to the flow of your text."))
+;; Local Variables:
+;; generated-autoload-file: "tpu-edt.el"
+;; End:
+
;; arch-tag: 89676fa4-33ec-48cb-9135-6f3bf230ab1a
;;; tpu-extras.el ends here