diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/fringe.el | 130 |
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 @@ | |||
| 1 | 2012-08-05 Chong Yidong <cyd@gnu.org> | 1 | 2012-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 | ||
| 5 | 2012-08-04 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2012-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. |
| 107 | See `fringe-mode' for possible values and their effect." | 107 | See `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. | ||
| 154 | Each list element has the form (NAME . WIDTH), where NAME is a | ||
| 155 | mnemonic fringe mode name (a symbol) and WIDTH is one of the | ||
| 156 | following: | ||
| 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. |
| 148 | This variable can be nil (the default) meaning the fringes should have | 166 | The Lisp value should be one of the following: |
| 149 | the default width (8 pixels), it can be an integer value specifying | 167 | - nil, which means the default width (8 pixels). |
| 150 | the width of both left and right fringe (where 0 means no fringe), or | 168 | - a cons cell (LEFT . RIGHT), where LEFT and RIGHT are |
| 151 | a cons cell where car indicates width of left fringe and cdr indicates | 169 | respectively the left and right fringe widths in pixels, or |
| 152 | width of right fringe (where again 0 can be used to indicate no | 170 | nil (meaning to disable that fringe). |
| 153 | fringe). | 171 | - a single integer, which specifies the pixel widths of both |
| 154 | Note that the actual width may be rounded up to ensure that the sum of | 172 | fringes. |
| 155 | the width of the left and right fringes is a multiple of the frame's | 173 | Note that the actual width may be rounded up to ensure that the |
| 156 | character width. However, a fringe width of 0 is never rounded. | 174 | sum of the width of the left and right fringes is a multiple of |
| 157 | To set this variable in a Lisp program, use `set-fringe-mode' to make | 175 | the frame's character width. However, a fringe width of 0 is |
| 158 | it take real effect. | 176 | never rounded. |
| 159 | Setting the variable with a customization buffer also takes effect. | 177 | |
| 160 | If you only want to modify the appearance of the fringe in one frame, | 178 | When setting this variable from Customize, the user can choose |
| 161 | you can use the interactive function `set-fringe-style'." | 179 | from the mnemonic fringe mode names defined in `fringe-styles'. |
| 180 | |||
| 181 | When setting this variable in a Lisp program, call | ||
| 182 | `set-fringe-mode' afterward to make it take real effect. | ||
| 183 | |||
| 184 | To modify the appearance of the fringe in a specific frame, use | ||
| 185 | the 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 | 233 | When called interactively, query the user for MODE; valid values | |
| 209 | When called interactively, query the user for MODE. Valid values | 234 | are `no-fringes', `default', `left-only', `right-only', `minimal' |
| 210 | for MODE include `no-fringes', `default', `left-only', `right-only', | 235 | and `half-width'. See `fringe-styles'. |
| 211 | `minimal' and `half-width'. | 236 | |
| 212 | 237 | When used in a Lisp program, MODE should be one of these: | |
| 213 | When used in a Lisp program, MODE can be a cons cell where the | 238 | - nil, which means the default width (8 pixels). |
| 214 | integer in car specifies the left fringe width and the integer in | 239 | - a cons cell (LEFT . RIGHT), where LEFT and RIGHT are |
| 215 | cdr specifies the right fringe width. MODE can also be a single | 240 | respectively the left and right fringe widths in pixels, or |
| 216 | integer that specifies both the left and the right fringe width. | 241 | nil (meaning to disable that fringe). |
| 217 | If a fringe width specification is nil, that means to use the | 242 | - a single integer, which specifies the pixel widths of both |
| 218 | default width (8 pixels). This command may round up the left and | 243 | fringes. |
| 219 | right width specifications to ensure that their sum is a multiple | 244 | This command may round up the left and right width specifications |
| 220 | of the character width of a frame. It never rounds up a fringe | 245 | to ensure that their sum is a multiple of the character width of |
| 221 | width of 0. | 246 | a frame. It never rounds up a fringe width of 0. |
| 222 | 247 | ||
| 223 | Fringe widths set by `set-window-fringes' override the default | 248 | Fringe widths set by `set-window-fringes' override the default |
| 224 | fringe widths set by this command. This command applies to all | 249 | fringe 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 | 258 | When called interactively, query the user for MODE; valid values | |
| 234 | When called interactively, query the user for MODE. Valid values | 259 | are `no-fringes', `default', `left-only', `right-only', `minimal' |
| 235 | for MODE include `none', `default', `left-only', `right-only', | 260 | and `half-width'. See `fringe-styles'. |
| 236 | `minimal' and `half'. | 261 | |
| 237 | 262 | When used in a Lisp program, MODE should be one of these: | |
| 238 | When used in a Lisp program, MODE can be a cons cell where the | 263 | - nil, which means the default width (8 pixels). |
| 239 | integer in car specifies the left fringe width and the integer in | 264 | - a cons cell (LEFT . RIGHT), where LEFT and RIGHT are |
| 240 | cdr specifies the right fringe width. MODE can also be a single | 265 | respectively the left and right fringe widths in pixels, or |
| 241 | integer that specifies both the left and the right fringe width. | 266 | nil (meaning to disable that fringe). |
| 242 | If a fringe width specification is nil, that means to use the | 267 | - a single integer, which specifies the pixel widths of both |
| 243 | default width (8 pixels). This command may round up the left and | 268 | fringes. |
| 244 | right width specifications to ensure that their sum is a multiple | 269 | This command may round up the left and right width specifications |
| 245 | of the character width of a frame. It never rounds up a fringe | 270 | to ensure that their sum is a multiple of the character width of |
| 246 | width of 0. | 271 | a frame. It never rounds up a fringe width of 0. |
| 247 | 272 | ||
| 248 | Fringe widths set by `set-window-fringes' override the default | 273 | Fringe widths set by `set-window-fringes' override the default |
| 249 | fringe widths set by this command. If you want to set the | 274 | fringe widths set by this command. If you want to set the |
| 250 | default appearance of fringes on all frames, see the command | 275 | default 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)) |