annotate lisp/auto-show.el @ 12411:884975f72dd5

(server-process-filter): Detect error messages from server.
author Richard M. Stallman <rms@gnu.org>
date Wed, 28 Jun 1995 10:02:03 +0000
parents 4ef3ef45089f
children 84acc3adcd63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
1 ;;; This file is in the public domain.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
2
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
3 ;;; Keywords: scroll display minor-mode
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
4 ;;; Author: Pete Ware <ware@cis.ohio-state.edu>
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
5 ;;; Maintainer: FSF
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
6
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
7 ;;; Commentary:
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
9 ;;; This file provides functions that
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;;; automatically scroll the window horizontally when the point moves
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
11 ;;; off the left or right side of the window.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
12
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
13 ;;; Once this library is loaded, automatic horizontal scrolling
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
14 ;;; occurs whenever long lines are being truncated.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
15 ;;; To request truncation of long lines, set the variable
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
16 ;;; Setting the variable `truncate-lines' to non-nil.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
17 ;;; You can do this for all buffers as follows:
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;;;
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;;; (set-default 'truncate-lines t)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
21 ;;; Here is how to do it for C mode only:
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;;;
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;;; (set-default 'truncate-lines nil) ; this is the original value
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; (defun my-c-mode-hook ()
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; "Run when C-mode starts up. Changes ..."
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; ... set various personal preferences ...
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; (setq truncate-lines t))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; (add-hook 'c-mode-hook 'my-c-mode-hook)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;;
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;;
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
31 ;;; As a finer level of control, you can still have truncated lines but
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
32 ;;; without the automatic horizontal scrolling by setting the buffer
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
33 ;;; local variable `auto-show-mode' to nil. The default value is t.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
34 ;;; The command `auto-show-mode' toggles the value of the variable
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
35 ;;; `auto-show-mode'.
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
37 ;;; Code:
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
39 (defvar auto-show-mode t
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
40 "*Non-nil enables automatic horizontal scrolling, when lines are truncated.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
41 The default value is t. To change the default, do this:
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
42 (set-default 'auto-show-mode nil)
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
43 See also command `auto-show-mode'.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
44 This variable has no effect when lines are not being truncated.")
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
46 (make-variable-buffer-local 'auto-show-mode)
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defvar auto-show-shift-amount 8
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
49 "*Extra columns to scroll. for automatic horizontal scrolling.")
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (defvar auto-show-show-left-margin-threshold 50
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
52 "*Threshold column for automatic horizontal scrolling to the right.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
53 If point is before this column, we try to scroll to make the left margin
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 visible. Setting this to 0 disables this feature.")
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defun auto-show-truncationp ()
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
57 "True if line truncation is enabled for the selected window."
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (or truncate-lines
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (and truncate-partial-width-windows
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (< (window-width) (frame-width)))))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
62 ;;;###autoload
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
63 (defun auto-show-mode (arg)
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
64 "Turn automatic horizontal scroll mode on or off.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
65 With arg, turn auto scrolling on if arg is positive, off otherwise."
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
66 (interactive "P")
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
67 (setq auto-show-mode
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
68 (if (null arg)
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
69 (not auto-show-mode)
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
70 (> (prefix-numeric-value arg) 0))))
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (defun auto-show-make-point-visible (&optional ignore-arg)
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
73 "Scroll horizontally to make point visible, if that is enabled.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
74 This function only does something if `auto-show-mode' is non-nil
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
75 and longlines are being truncated in the selected window.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
76 See also the command `auto-show-toggle'."
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (interactive)
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
78 (if (and auto-show-mode (auto-show-truncationp)
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (equal (window-buffer) (current-buffer)))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (let* ((col (current-column)) ;column on line point is at
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (scroll (window-hscroll)) ;how far window is scrolled
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (w-width (- (window-width)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (if (> scroll 0)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 2 1))) ;how wide window is on the screen
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (right-col (+ scroll w-width)))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (if (and (< col auto-show-show-left-margin-threshold)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (< col (window-width))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (> scroll 0))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (scroll-right scroll)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (if (< col scroll) ;to the left of the screen
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (scroll-right (+ (- scroll col) auto-show-shift-amount))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (if (or (> col right-col) ;to the right of the screen
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (and (= col right-col)
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (not (eolp))))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (scroll-left (+ auto-show-shift-amount
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (- col (+ scroll w-width))))
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 )
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
104 ;; Do auto-scrolling after commands.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
105 (add-hook 'post-command-hook 'auto-show-make-point-visible)
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
107 ;; Do auto-scrolling in comint buffers after process output also.
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
108 (add-hook 'comint-output-filter-functions 'auto-show-make-point-visible t)
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
110 (provide 'auto-show)
10973
a937df996aa4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
10974
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
112 ;; auto-show.el ends here
4ef3ef45089f Unconditionally add to comint-output-filter-functions.
Richard M. Stallman <rms@gnu.org>
parents: 10973
diff changeset
113