aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-08-05 11:52:02 +0800
committerChong Yidong2012-08-05 11:52:02 +0800
commitd014c740b08c07d0c6166d2ffb01ea3c366b37ce (patch)
treeeabf71cbc1471bc25e4b427500bdf6c59fadf6ff
parenta9dd575408cbc905c0c79ee91b045c79d0e971a7 (diff)
downloademacs-d014c740b08c07d0c6166d2ffb01ea3c366b37ce.tar.gz
emacs-d014c740b08c07d0c6166d2ffb01ea3c366b37ce.zip
* fringe.el: Docstring and minor code improvements.
(fringe-styles): Add docstring. (fringe--check-style): New function. (set-fringe-mode, set-fringe-style): Use it. (fringe-mode, set-fringe-style): Doc fixes. Fixes: debbugs:6480
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/fringe.el130
2 files changed, 83 insertions, 52 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 22fedc4095c..1df710cc189 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12012-08-05 Chong Yidong <cyd@gnu.org> 12012-08-05 Chong Yidong <cyd@gnu.org>
2 2
3 * fringe.el (fringe-styles): Add docstring.
4 (fringe--check-mode): New function.
5 (set-fringe-mode, set-fringe-style): Use it.
6 (fringe-mode, set-fringe-style): Doc fixes (Bug#6480).
7
3 * files.el (set-auto-mode): Fix invalid setq call. 8 * files.el (set-auto-mode): Fix invalid setq call.
4 9
52012-08-04 Stefan Monnier <monnier@iro.umontreal.ca> 102012-08-04 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/lisp/fringe.el b/lisp/fringe.el
index 329370b5fe5..6ff27a71355 100644
--- a/lisp/fringe.el
+++ b/lisp/fringe.el
@@ -105,8 +105,8 @@ This is usually invoked when setting `fringe-mode' via customize."
105(defun set-fringe-mode (value) 105(defun set-fringe-mode (value)
106 "Set `fringe-mode' to VALUE and put the new value into effect. 106 "Set `fringe-mode' to VALUE and put the new value into effect.
107See `fringe-mode' for possible values and their effect." 107See `fringe-mode' for possible values and their effect."
108 (fringe--check-style value)
108 (setq fringe-mode value) 109 (setq fringe-mode value)
109
110 (when fringe-mode-explicit 110 (when fringe-mode-explicit
111 (modify-all-frames-parameters 111 (modify-all-frames-parameters
112 (list (cons 'left-fringe (if (consp fringe-mode) 112 (list (cons 'left-fringe (if (consp fringe-mode)
@@ -116,6 +116,14 @@ See `fringe-mode' for possible values and their effect."
116 (cdr fringe-mode) 116 (cdr fringe-mode)
117 fringe-mode)))))) 117 fringe-mode))))))
118 118
119(defun fringe--check-style (style)
120 (or (null style)
121 (integerp style)
122 (and (consp style)
123 (or (null (car style)) (integerp (car style)))
124 (or (null (cdr style)) (integerp (cdr style))))
125 (error "Invalid fringe style `%s'" style)))
126
119;; For initialization of fringe-mode, take account of changes 127;; For initialization of fringe-mode, take account of changes
120;; made explicitly to default-frame-alist. 128;; made explicitly to default-frame-alist.
121(defun fringe-mode-initialize (symbol value) 129(defun fringe-mode-initialize (symbol value)
@@ -141,24 +149,40 @@ See `fringe-mode' for possible values and their effect."
141 ("right-only" . (0 . nil)) 149 ("right-only" . (0 . nil))
142 ("left-only" . (nil . 0)) 150 ("left-only" . (nil . 0))
143 ("half-width" . (4 . 4)) 151 ("half-width" . (4 . 4))
144 ("minimal" . (1 . 1)))) 152 ("minimal" . (1 . 1)))
153 "Alist mapping fringe mode names to fringe widths.
154Each list element has the form (NAME . WIDTH), where NAME is a
155mnemonic fringe mode name (a symbol) and WIDTH is one of the
156following:
157- nil, which means the default width (8 pixels).
158- a cons cell (LEFT . RIGHT), where LEFT and RIGHT are
159 respectively the left and right fringe widths in pixels, or
160 nil (meaning to disable that fringe).
161- a single integer, which specifies the pixel widths of both
162 fringes.")
145 163
146(defcustom fringe-mode nil 164(defcustom fringe-mode nil
147 "Specify appearance of fringes on all frames. 165 "Default appearance of fringes on all frames.
148This variable can be nil (the default) meaning the fringes should have 166The Lisp value should be one of the following:
149the default width (8 pixels), it can be an integer value specifying 167- nil, which means the default width (8 pixels).
150the width of both left and right fringe (where 0 means no fringe), or 168- a cons cell (LEFT . RIGHT), where LEFT and RIGHT are
151a cons cell where car indicates width of left fringe and cdr indicates 169 respectively the left and right fringe widths in pixels, or
152width of right fringe (where again 0 can be used to indicate no 170 nil (meaning to disable that fringe).
153fringe). 171- a single integer, which specifies the pixel widths of both
154Note that the actual width may be rounded up to ensure that the sum of 172 fringes.
155the width of the left and right fringes is a multiple of the frame's 173Note that the actual width may be rounded up to ensure that the
156character width. However, a fringe width of 0 is never rounded. 174sum of the width of the left and right fringes is a multiple of
157To set this variable in a Lisp program, use `set-fringe-mode' to make 175the frame's character width. However, a fringe width of 0 is
158it take real effect. 176never rounded.
159Setting the variable with a customization buffer also takes effect. 177
160If you only want to modify the appearance of the fringe in one frame, 178When setting this variable from Customize, the user can choose
161you can use the interactive function `set-fringe-style'." 179from the mnemonic fringe mode names defined in `fringe-styles'.
180
181When setting this variable in a Lisp program, call
182`set-fringe-mode' afterward to make it take real effect.
183
184To modify the appearance of the fringe in a specific frame, use
185the interactive function `set-fringe-style'."
162 :type `(choice 186 :type `(choice
163 ,@ (mapcar (lambda (style) 187 ,@ (mapcar (lambda (style)
164 (let ((name 188 (let ((name
@@ -195,30 +219,31 @@ frame parameter is used."
195 ": ") 219 ": ")
196 fringe-styles nil t)) 220 fringe-styles nil t))
197 (style (assoc (downcase mode) fringe-styles))) 221 (style (assoc (downcase mode) fringe-styles)))
198 (if style (cdr style) 222 (cond
199 (if (eq 0 (cdr (assq 'left-fringe 223 (style
200 (if all-frames 224 (cdr style))
201 default-frame-alist 225 ((not (eq 0 (cdr (assq 'left-fringe
202 (frame-parameters (selected-frame)))))) 226 (if all-frames
203 nil 227 default-frame-alist
204 0)))) 228 (frame-parameters))))))
229 0))))
205 230
206(defun fringe-mode (&optional mode) 231(defun fringe-mode (&optional mode)
207 "Set the default appearance of fringes on all frames. 232 "Set the default appearance of fringes on all frames.
208 233When called interactively, query the user for MODE; valid values
209When called interactively, query the user for MODE. Valid values 234are `no-fringes', `default', `left-only', `right-only', `minimal'
210for MODE include `no-fringes', `default', `left-only', `right-only', 235and `half-width'. See `fringe-styles'.
211`minimal' and `half-width'. 236
212 237When used in a Lisp program, MODE should be one of these:
213When used in a Lisp program, MODE can be a cons cell where the 238- nil, which means the default width (8 pixels).
214integer in car specifies the left fringe width and the integer in 239- a cons cell (LEFT . RIGHT), where LEFT and RIGHT are
215cdr specifies the right fringe width. MODE can also be a single 240 respectively the left and right fringe widths in pixels, or
216integer that specifies both the left and the right fringe width. 241 nil (meaning to disable that fringe).
217If a fringe width specification is nil, that means to use the 242- a single integer, which specifies the pixel widths of both
218default width (8 pixels). This command may round up the left and 243 fringes.
219right width specifications to ensure that their sum is a multiple 244This command may round up the left and right width specifications
220of the character width of a frame. It never rounds up a fringe 245to ensure that their sum is a multiple of the character width of
221width of 0. 246a frame. It never rounds up a fringe width of 0.
222 247
223Fringe widths set by `set-window-fringes' override the default 248Fringe widths set by `set-window-fringes' override the default
224fringe widths set by this command. This command applies to all 249fringe widths set by this command. This command applies to all
@@ -230,26 +255,27 @@ frame only, see the command `set-fringe-style'."
230 255
231(defun set-fringe-style (&optional mode) 256(defun set-fringe-style (&optional mode)
232 "Set the default appearance of fringes on the selected frame. 257 "Set the default appearance of fringes on the selected frame.
233 258When called interactively, query the user for MODE; valid values
234When called interactively, query the user for MODE. Valid values 259are `no-fringes', `default', `left-only', `right-only', `minimal'
235for MODE include `none', `default', `left-only', `right-only', 260and `half-width'. See `fringe-styles'.
236`minimal' and `half'. 261
237 262When used in a Lisp program, MODE should be one of these:
238When used in a Lisp program, MODE can be a cons cell where the 263- nil, which means the default width (8 pixels).
239integer in car specifies the left fringe width and the integer in 264- a cons cell (LEFT . RIGHT), where LEFT and RIGHT are
240cdr specifies the right fringe width. MODE can also be a single 265 respectively the left and right fringe widths in pixels, or
241integer that specifies both the left and the right fringe width. 266 nil (meaning to disable that fringe).
242If a fringe width specification is nil, that means to use the 267- a single integer, which specifies the pixel widths of both
243default width (8 pixels). This command may round up the left and 268 fringes.
244right width specifications to ensure that their sum is a multiple 269This command may round up the left and right width specifications
245of the character width of a frame. It never rounds up a fringe 270to ensure that their sum is a multiple of the character width of
246width of 0. 271a frame. It never rounds up a fringe width of 0.
247 272
248Fringe widths set by `set-window-fringes' override the default 273Fringe widths set by `set-window-fringes' override the default
249fringe widths set by this command. If you want to set the 274fringe widths set by this command. If you want to set the
250default appearance of fringes on all frames, see the command 275default appearance of fringes on all frames, see the command
251`fringe-mode'." 276`fringe-mode'."
252 (interactive (list (fringe-query-style))) 277 (interactive (list (fringe-query-style)))
278 (fringe--check-style mode)
253 (modify-frame-parameters 279 (modify-frame-parameters
254 (selected-frame) 280 (selected-frame)
255 (list (cons 'left-fringe (if (consp mode) (car mode) mode)) 281 (list (cons 'left-fringe (if (consp mode) (car mode) mode))