]> git.eshelyaron.com Git - emacs.git/commitdiff
Unconditionally add to comint-output-filter-functions.
authorRichard M. Stallman <rms@gnu.org>
Sun, 12 Mar 1995 09:15:08 +0000 (09:15 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 12 Mar 1995 09:15:08 +0000 (09:15 +0000)
(auto-show-mode): Command renamed from auto-show-toggle.
Handle an arg in the standard way.
(auto-show-mode): Variable renamed from auto-show-enable.

lisp/auto-show.el

index d4384ef3369886cc5a06199921303c555ab1eb22..ce36b2e73d29b82715e3250e30a6e80a1815096a 100644 (file)
@@ -1,57 +1,24 @@
-;;  LCD Archive Entry:
-;;  auto-show|Pete Ware|ware@cis.ohio-state.edu|
-;;  Automatically scroll horizontally|
-;;  95-02-24|1.9|~/misc/auto-show.el|
-;;
-;;;
-;;; Author:
-;;;
-;;;    Pete Ware                                       ware@cis.ohio-state.edu
-;;;    CIS Dept, Ohio State University                 w/ (614) 292-8501
-;;;    774 Dreese, 2015 Neil Ave.                      h/ (614) 791-1347
-;;;    Columbus, OH 43210              http://www.cis.ohio-state.edu/~ware
-;;;
-;;;
-;;; Modification history:
-;;; 02/24/95   Added auto-show-show-left-margin-threshold so that if
-;;;            there is anyway for the left margin to be displayed it is.
-;;; 02/24/95   Only scroll window if it matches current buffer.  Added
-;;;            function for enabeling scrolling in comint buffers on output.
-;;; 02/13/95   Aded Kevin Broadey <KevinB@bartley.demon.co.uk> fix so that
-;;;            it doesn't scroll if we are at window border and at the
-;;;            end of the line (i.e. newline character)
-;;; 02/10/95   jeff.dwork@amd.com added auto-show-toggle function.
-;;; 02/08/95   Added auto-show-enable as per
-;;;            jeff.dwork@amd.com (Jeff Dwork)'s suggestion.  Cleaned up
-;;;            documentation.
-;;; 02/07/95   Rewrote for emacs 19: much, much cleaner.  Renamed auto-show
-;;; 8/6/90     Make next-line/previous-line do better job following movement.
-;;; 3/21/90         better calculation of w-width in e-make-point-visible
-;;;                 test for truncated windows
-;;;                 added substitute-in-keymap
-;;;                 renamed to auto-horizontal
-;;;                 added backward-delete-char
-;;; 8/13/88    Created
+;;; This file is in the public domain.
 
-;;;
-;;; This is a rewrite of auto-horizontal.  It is comparable in
-;;; functionality to hscroll.el except it is not a minor mode and does
-;;; not use any timers.  This file provides functions that
+;;; Keywords: scroll display minor-mode
+;;; Author: Pete Ware <ware@cis.ohio-state.edu>
+;;; Maintainer: FSF
+
+;;; Commentary:
+
+;;; This file provides functions that
 ;;; automatically scroll the window horizontally when the point moves
-;;; off the left or right side of the window.  To load it just add:
-;;;    (require 'auto-show)
-;;; to your .emacs.
-;;;
-;;; Setting the variable ``truncate-lines'' to non-nil causes long
-;;; lines to disappear off the end of the screen instead of wrapping
-;;; to the beginning of the next line.  To make this the default for
-;;; all buffers add the following line to your .emacs (sans ;;;):
+;;; off the left or right side of the window.
+
+;;; Once this library is loaded, automatic horizontal scrolling
+;;; occurs whenever long lines are being truncated.
+;;; To request truncation of long lines, set the variable
+;;; Setting the variable `truncate-lines' to non-nil.
+;;; You can do this for all buffers as follows:
 ;;;
 ;;; (set-default 'truncate-lines t)
-;;;
 
-;;; However, I've found that I only want this when I'm editing C code.
-;;; Accordingly I have something like the following in my .emacs:
+;;; Here is how to do it for C mode only:
 ;;;
 ;;; (set-default 'truncate-lines nil)  ; this is the original value
 ;;; (defun my-c-mode-hook ()
 ;;; (add-hook 'c-mode-hook 'my-c-mode-hook)
 ;;;
 ;;;
-;;; As a finer level of control, one can still have truncated lines but
-;;; without the automatic left and right scrolling by setting the buffer
-;;; local variable ``auto-show-enable'' to nil.  The default value is t.
-;;; The command ``auto-show-toggle'' will toggle the value of
-;;; ``auto-show-enable''.
-;;;
-;;;
-;;; I also like the output from my shell's (and other comint.el based commands)
-;;; to scroll on output.  One can call:
-;;;
-;;;    (auto-show-comint-make-point-visible)
-;;;
-;;; which adds auto-show-make-point-visible to comint-output-filter-functions.
-
-(provide 'auto-show)
-
-;;;************************************************************
-;;;*
-;;;*  Define Automatic Horizontal Scrolling Functions
-;;;*
-;;;************************************************************
+;;; As a finer level of control, you can still have truncated lines but
+;;; without the automatic horizontal scrolling by setting the buffer
+;;; local variable `auto-show-mode' to nil.  The default value is t.
+;;; The command `auto-show-mode' toggles the value of the variable
+;;; `auto-show-mode'.
 
-(add-hook 'post-command-hook 'auto-show-make-point-visible)
+;;; Code:
 
-(defvar auto-show-enable t
-  "*Allows one to turn off automatic horizontal scrolling on a per buffer
-basis independent of whether truncate-lines is t.  The default value is t.
-To change the default:
-       (set-default 'auto-show-enable nil)
-Any time auto-show-enable is changed it is only in the current buffer:
-       (setq auto-show-enable nil)
-turns it on for this buffer.
-See also command `auto-show-toggle'.")
+(defvar auto-show-mode t
+  "*Non-nil enables automatic horizontal scrolling, when lines are truncated.
+The default value is t.  To change the default, do this:
+       (set-default 'auto-show-mode nil)
+See also command `auto-show-mode'.
+This variable has no effect when lines are not being truncated.")
 
-(make-variable-buffer-local 'auto-show-enable)
+(make-variable-buffer-local 'auto-show-mode)
 
 (defvar auto-show-shift-amount 8 
-  "*Extra amount to shift a line when point is not visible.")
+  "*Extra columns to scroll. for automatic horizontal scrolling.")
 
 (defvar auto-show-show-left-margin-threshold 50
-  "*Point must be before this column for us to try and make the left margin
+  "*Threshold column for automatic horizontal scrolling to the right.
+If point is before this column, we try to scroll to make the left margin
 visible.  Setting this to 0 disables this feature.")
 
 (defun auto-show-truncationp ()
-  "True if truncation is on for current window."
+  "True if line truncation is enabled for the selected window."
   (or truncate-lines 
       (and truncate-partial-width-windows
           (< (window-width) (frame-width)))))
 
-(defun auto-show-toggle ()
-  "Toggle value of auto-show-enable."
-  (interactive)
-  (setq auto-show-enable (not auto-show-enable)))
+;;;###autoload
+(defun auto-show-mode (arg)
+  "Turn automatic horizontal scroll mode on or off.
+With arg, turn auto scrolling on if arg is positive, off otherwise."
+  (interactive "P")
+  (setq auto-show-mode
+       (if (null arg)
+           (not auto-show-mode)
+         (> (prefix-numeric-value arg) 0))))
   
 (defun auto-show-make-point-visible (&optional ignore-arg)
-  "Scrolls the screen horizontally to make point visible but only if
-auto-show-enable is non-nil and lines are truncated.  See also variable
-`auto-show-enable' and command `auto-show-toggle'."
+  "Scroll horizontally to make point visible, if that is enabled.
+This function only does something if `auto-show-mode' is non-nil
+and longlines are being truncated in the selected window.
+See also the command `auto-show-toggle'."
   (interactive)
-  (if (and auto-show-enable (auto-show-truncationp)
+  (if (and auto-show-mode (auto-show-truncationp)
           (equal (window-buffer) (current-buffer)))
       (let* ((col (current-column))    ;column on line point is at
             (scroll (window-hscroll))  ;how far window is scrolled
@@ -146,15 +101,13 @@ auto-show-enable is non-nil and lines are truncated.  See also variable
     )
   )
 
-(defun auto-show-comint-make-point-visible ()
-  "Add a function to comint-output-filter-functions that auto-scrolls
-left or right on output to the buffer.
+;; Do auto-scrolling after commands.
+(add-hook 'post-command-hook 'auto-show-make-point-visible)
 
-NOTE: you should load comint mode before this as comint.el uses a
-defvar to initialize comint-output-filter-functions to the default value."
-  (interactive)
-  (add-hook 'comint-output-filter-functions 'auto-show-make-point-visible t)
-  )
+;; Do auto-scrolling in comint buffers after process output also.
+(add-hook 'comint-output-filter-functions 'auto-show-make-point-visible t)
+
+(provide 'auto-show)
 
-;; end of auto-show.el
+;; auto-show.el ends here