Mercurial > emacs
annotate lisp/fringe.el @ 54283:d0c3cadb7e21
(help-at-pt-timer-delay): Minor doc fix (remove stray space).
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Fri, 05 Mar 2004 04:42:46 +0000 |
parents | 5588b6cc6fba |
children | ad02f6299e9a |
rev | line source |
---|---|
45493 | 1 ;;; fringe.el --- change fringes appearance in various ways |
2 | |
50127
7efc8970b32c
(fringe-mode): Autoload so that
Simon Josefsson <jas@extundo.com>
parents:
45524
diff
changeset
|
3 ;; Copyright (C) 2002, 2003 Free Software Foundation, Inc. |
45493 | 4 |
5 ;; Author: Simon Josefsson <simon@josefsson.org> | |
6 ;; Maintainer: FSF | |
7 ;; Keywords: frames | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; This file contains helpful functions for customizing the appearance | |
29 ;; of the fringe. | |
30 | |
31 ;; The code is influenced by scroll-bar.el and avoid.el. The author | |
32 ;; gratefully acknowledge comments and suggestions made by Miles | |
33 ;; Bader, Eli Zaretski, Richard Stallman, Pavel JanÃk and others which | |
34 ;; improved this package. | |
35 | |
36 ;;; Code: | |
37 | |
53890
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
38 ;; Standard fringe bitmaps |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
39 |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
40 (defconst no-fringe-bitmap 0) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
41 (defconst undef-fringe-bitmap 1) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
42 (defconst left-truncation-fringe-bitmap 2) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
43 (defconst right-truncation-fringe-bitmap 3) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
44 (defconst up-arrow-fringe-bitmap 4) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
45 (defconst down-arrow-fringe-bitmap 5) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
46 (defconst continued-line-fringe-bitmap 6) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
47 (defconst continuation-line-fringe-bitmap 7) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
48 (defconst overlay-arrow-fringe-bitmap 8) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
49 (defconst top-left-angle-fringe-bitmap 9) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
50 (defconst top-right-angle-fringe-bitmap 10) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
51 (defconst bottom-left-angle-fringe-bitmap 11) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
52 (defconst bottom-right-angle-fringe-bitmap 12) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
53 (defconst left-bracket-fringe-bitmap 13) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
54 (defconst right-bracket-fringe-bitmap 14) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
55 (defconst filled-box-cursor-fringe-bitmap 15) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
56 (defconst hollow-box-cursor-fringe-bitmap 16) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
57 (defconst hollow-square-fringe-bitmap 17) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
58 (defconst bar-cursor-fringe-bitmap 18) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
59 (defconst hbar-cursor-fringe-bitmap 19) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
60 (defconst empty-line-fringe-bitmap 20) |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
61 |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
62 |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
63 ;; Control presence of fringes |
5588b6cc6fba
(no-fringe-bitmap, undef-fringe-bitmap)
Kim F. Storm <storm@cua.dk>
parents:
53257
diff
changeset
|
64 |
45493 | 65 (defvar fringe-mode) |
66 | |
67 (defun set-fringe-mode-1 (ignore value) | |
68 "Call `set-fringe-mode' with VALUE. | |
69 See `fringe-mode' for valid values and their effect. | |
70 This is usually invoked when setting `fringe-mode' via customize." | |
71 (set-fringe-mode value)) | |
72 | |
73 (defun set-fringe-mode (value) | |
74 "Set `fringe-mode' to VALUE and put the new value into effect. | |
75 See `fringe-mode' for possible values and their effect." | |
76 (setq fringe-mode value) | |
77 | |
78 ;; Apply it to default-frame-alist. | |
79 (let ((parameter (assq 'left-fringe default-frame-alist))) | |
80 (if (consp parameter) | |
45524
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
81 (setcdr parameter (if (consp fringe-mode) |
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
82 (car fringe-mode) |
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
83 fringe-mode)) |
45493 | 84 (setq default-frame-alist |
85 (cons (cons 'left-fringe (if (consp fringe-mode) | |
86 (car fringe-mode) | |
87 fringe-mode)) | |
88 default-frame-alist)))) | |
89 (let ((parameter (assq 'right-fringe default-frame-alist))) | |
90 (if (consp parameter) | |
45524
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
91 (setcdr parameter (if (consp fringe-mode) |
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
92 (cdr fringe-mode) |
f48a8ed9d03a
(set-fringe-mode): Work when updating
Simon Josefsson <jas@extundo.com>
parents:
45518
diff
changeset
|
93 fringe-mode)) |
45493 | 94 (setq default-frame-alist |
95 (cons (cons 'right-fringe (if (consp fringe-mode) | |
96 (cdr fringe-mode) | |
97 fringe-mode)) | |
98 default-frame-alist)))) | |
99 | |
100 ;; Apply it to existing frames. | |
101 (let ((frames (frame-list))) | |
102 (while frames | |
103 (modify-frame-parameters | |
104 (car frames) | |
105 (list (cons 'left-fringe (if (consp fringe-mode) | |
106 (car fringe-mode) | |
107 fringe-mode)) | |
108 (cons 'right-fringe (if (consp fringe-mode) | |
109 (cdr fringe-mode) | |
110 fringe-mode)))) | |
111 (setq frames (cdr frames))))) | |
112 | |
50127
7efc8970b32c
(fringe-mode): Autoload so that
Simon Josefsson <jas@extundo.com>
parents:
45524
diff
changeset
|
113 ;;;###autoload |
45493 | 114 (defcustom fringe-mode nil |
115 "*Specify appearance of fringes on all frames. | |
116 This variable can be nil (the default) meaning the fringes should have | |
117 the default width (8 pixels), it can be an integer value specifying | |
118 the width of both left and right fringe (where 0 means no fringe), or | |
119 a cons cell where car indicates width of left fringe and cdr indicates | |
120 width of right fringe (where again 0 can be used to indicate no | |
121 fringe). | |
122 To set this variable in a Lisp program, use `set-fringe-mode' to make | |
123 it take real effect. | |
124 Setting the variable with a customization buffer also takes effect. | |
125 If you only want to modify the appearance of the fringe in one frame, | |
126 you can use the interactive function `toggle-fringe'" | |
127 :type '(choice (const :tag "Default width" nil) | |
128 (const :tag "No fringes" 0) | |
129 (const :tag "Only right" (0 . nil)) | |
130 (const :tag "Only left" (nil . 0)) | |
131 (const :tag "Half width" (5 . 5)) | |
45518
182c7dd36ef1
Fix :type of `fringe-mode' for last modification.
Simon Josefsson <jas@extundo.com>
parents:
45516
diff
changeset
|
132 (const :tag "Minimal" (1 . 1)) |
45493 | 133 (integer :tag "Specific width") |
134 (cons :tag "Different left/right sizes" | |
135 (integer :tag "Left width") | |
136 (integer :tag "Right width"))) | |
137 :group 'frames | |
138 :require 'fringe | |
139 :set 'set-fringe-mode-1) | |
140 | |
141 (defun fringe-query-style (&optional all-frames) | |
142 "Query user for fringe style. | |
143 Returns values suitable for left-fringe and right-fringe frame parameters. | |
144 If ALL-FRAMES, the negation of the fringe values in | |
145 `default-frame-alist' is used when user enters the empty string. | |
146 Otherwise the negation of the fringe value in the currently selected | |
147 frame parameter is used." | |
148 (let ((mode (intern (completing-read | |
53257
869dfa7b9022
(fringe-query-style): Suggest `?' in minibuffer prompt (instead of
Luc Teirlinck <teirllm@auburn.edu>
parents:
52854
diff
changeset
|
149 "Select fringe mode for all frames (type ? for list): " |
45493 | 150 '(("none") ("default") ("left-only") |
45516
6b848a738ec6
(fringe-query-style): New fringe style "minimal".
Simon Josefsson <jas@extundo.com>
parents:
45493
diff
changeset
|
151 ("right-only") ("half") ("minimal")) |
45493 | 152 nil t)))) |
153 (cond ((eq mode 'none) 0) | |
154 ((eq mode 'default) nil) | |
155 ((eq mode 'left-only) '(nil . 0)) | |
156 ((eq mode 'right-only) '(0 . nil)) | |
157 ((eq mode 'half) '(5 . 5)) | |
45516
6b848a738ec6
(fringe-query-style): New fringe style "minimal".
Simon Josefsson <jas@extundo.com>
parents:
45493
diff
changeset
|
158 ((eq mode 'minimal) '(1 . 1)) |
45493 | 159 ((eq mode (intern "")) |
160 (if (eq 0 (cdr (assq 'left-fringe | |
161 (if all-frames | |
162 default-frame-alist | |
163 (frame-parameters (selected-frame)))))) | |
164 nil | |
165 0))))) | |
166 | |
167 ;;;###autoload | |
168 (defun fringe-mode (&optional mode) | |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
169 "Set the default appearance of fringes on all frames. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
170 |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
171 When called interactively, query the user for MODE. Valid values |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
172 for MODE include `none', `default', `left-only', `right-only', |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
173 `minimal' and `half'. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
174 |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
175 When used in a Lisp program, MODE can be a cons cell where the |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
176 integer in car specifies the left fringe width and the integer in |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
177 cdr specifies the right fringe width. MODE can also be a single |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
178 integer that specifies both the left and the right fringe width. |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
179 If a fringe width specification is nil, that means to use the |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
180 default width (8 pixels). This command may round up the left and |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
181 right width specifications to ensure that their sum is a multiple |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
182 of the character width of a frame. It never rounds up a fringe |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
183 width of 0. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
184 |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
185 Fringe widths set by `set-window-fringes' override the default |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
186 fringe widths set by this command. This command applies to all |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
187 frames that exist and frames to be created in the future. If you |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
188 want to set the default appearance of fringes on the selected |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
189 frame only, see the command `set-fringe-style'." |
45493 | 190 (interactive (list (fringe-query-style 'all-frames))) |
191 (set-fringe-mode mode)) | |
192 | |
193 ;;;###autoload | |
194 (defun set-fringe-style (&optional mode) | |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
195 "Set the default appearance of fringes on the selected frame. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
196 |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
197 When called interactively, query the user for MODE. Valid values |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
198 for MODE include `none', `default', `left-only', `right-only', |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
199 `minimal' and `half'. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
200 |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
201 When used in a Lisp program, MODE can be a cons cell where the |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
202 integer in car specifies the left fringe width and the integer in |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
203 cdr specifies the right fringe width. MODE can also be a single |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
204 integer that specifies both the left and the right fringe width. |
52854
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
205 If a fringe width specification is nil, that means to use the |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
206 default width (8 pixels). This command may round up the left and |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
207 right width specifications to ensure that their sum is a multiple |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
208 of the character width of a frame. It never rounds up a fringe |
f6ac1fc587f8
(fringe-mode): Use active voice in docstring.
Lute Kamstra <lute@gnu.org>
parents:
52832
diff
changeset
|
209 width of 0. |
52832
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
210 |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
211 Fringe widths set by `set-window-fringes' override the default |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
212 fringe widths set by this command. If you want to set the |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
213 default appearance of fringes on all frames, see the command |
43bad0db6791
(fringe-mode): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
214 `fringe-mode'." |
45493 | 215 (interactive (list (fringe-query-style))) |
216 (modify-frame-parameters | |
217 (selected-frame) | |
218 (list (cons 'left-fringe (if (consp mode) (car mode) mode)) | |
219 (cons 'right-fringe (if (consp mode) (cdr mode) mode))))) | |
220 | |
221 (provide 'fringe) | |
222 | |
52401 | 223 ;;; arch-tag: 6611ef60-0869-47ed-8b93-587ee7d3ff5d |
45493 | 224 ;;; fringe.el ends here |