Mercurial > emacs
comparison lisp/fringe.el @ 110426:cd8d9630f156
* lisp/fringe.el (fringe-styles): New var.
(fringe-mode, fringe-query-style): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 19 Sep 2010 11:32:52 +0200 |
parents | 42d133e002e5 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
110425:cd99c4421df9 | 110426:cd8d9630f156 |
---|---|
134 (if (equal fringe-mode '(0 . 0)) | 134 (if (equal fringe-mode '(0 . 0)) |
135 (setq fringe-mode 0))) | 135 (setq fringe-mode 0))) |
136 ;; Otherwise impose the user-specified value of fringe-mode. | 136 ;; Otherwise impose the user-specified value of fringe-mode. |
137 (custom-initialize-reset symbol value)))) | 137 (custom-initialize-reset symbol value)))) |
138 | 138 |
139 (defconst fringe-styles | |
140 '(("default" . nil) | |
141 ("no-fringes" . 0) | |
142 ("right-only" . (0 . nil)) | |
143 ("left-only" . (nil . 0)) | |
144 ("half-width" . (4 . 4)) | |
145 ("minimal" . (1 . 1)))) | |
146 | |
139 (defcustom fringe-mode nil | 147 (defcustom fringe-mode nil |
140 "Specify appearance of fringes on all frames. | 148 "Specify appearance of fringes on all frames. |
141 This variable can be nil (the default) meaning the fringes should have | 149 This variable can be nil (the default) meaning the fringes should have |
142 the default width (8 pixels), it can be an integer value specifying | 150 the default width (8 pixels), it can be an integer value specifying |
143 the width of both left and right fringe (where 0 means no fringe), or | 151 the width of both left and right fringe (where 0 means no fringe), or |
150 To set this variable in a Lisp program, use `set-fringe-mode' to make | 158 To set this variable in a Lisp program, use `set-fringe-mode' to make |
151 it take real effect. | 159 it take real effect. |
152 Setting the variable with a customization buffer also takes effect. | 160 Setting the variable with a customization buffer also takes effect. |
153 If you only want to modify the appearance of the fringe in one frame, | 161 If you only want to modify the appearance of the fringe in one frame, |
154 you can use the interactive function `set-fringe-style'." | 162 you can use the interactive function `set-fringe-style'." |
155 :type '(choice (const :tag "Default width" nil) | 163 :type `(choice |
156 (const :tag "No fringes" 0) | 164 ,@ (mapcar (lambda (style) |
157 (const :tag "Only right" (0 . nil)) | 165 (let ((name |
158 (const :tag "Only left" (nil . 0)) | 166 (replace-regexp-in-string "-" " " (car style)))) |
159 (const :tag "Half width" (4 . 4)) | 167 `(const :tag |
160 (const :tag "Minimal" (1 . 1)) | 168 ,(concat (capitalize (substring name 0 1)) |
161 (integer :tag "Specific width") | 169 (substring name 1)) |
162 (cons :tag "Different left/right sizes" | 170 ,(cdr style)))) |
163 (integer :tag "Left width") | 171 fringe-styles) |
164 (integer :tag "Right width"))) | 172 (integer :tag "Specific width") |
173 (cons :tag "Different left/right sizes" | |
174 (integer :tag "Left width") | |
175 (integer :tag "Right width"))) | |
165 :group 'fringe | 176 :group 'fringe |
166 :require 'fringe | 177 :require 'fringe |
167 :initialize 'fringe-mode-initialize | 178 :initialize 'fringe-mode-initialize |
168 :set 'set-fringe-mode-1) | 179 :set 'set-fringe-mode-1) |
169 | 180 |
176 Returns values suitable for left-fringe and right-fringe frame parameters. | 187 Returns values suitable for left-fringe and right-fringe frame parameters. |
177 If ALL-FRAMES, the negation of the fringe values in | 188 If ALL-FRAMES, the negation of the fringe values in |
178 `default-frame-alist' is used when user enters the empty string. | 189 `default-frame-alist' is used when user enters the empty string. |
179 Otherwise the negation of the fringe value in the currently selected | 190 Otherwise the negation of the fringe value in the currently selected |
180 frame parameter is used." | 191 frame parameter is used." |
181 (let ((mode (intern (completing-read | 192 (let* ((mode (completing-read |
182 (concat | 193 (concat |
183 "Select fringe mode for " | 194 "Select fringe mode for " |
184 (if all-frames "all frames" "selected frame") | 195 (if all-frames "all frames" "selected frame") |
185 " (type ? for list): ") | 196 " (type ? for list): ") |
186 '(("none") ("default") ("left-only") | 197 fringe-styles nil t)) |
187 ("right-only") ("half") ("minimal")) | 198 (style (assoc (downcase mode) fringe-styles))) |
188 nil t)))) | 199 (if style (cdr style) |
189 (cond ((eq mode 'none) 0) | 200 (if (eq 0 (cdr (assq 'left-fringe |
190 ((eq mode 'default) nil) | 201 (if all-frames |
191 ((eq mode 'left-only) '(nil . 0)) | 202 default-frame-alist |
192 ((eq mode 'right-only) '(0 . nil)) | 203 (frame-parameters (selected-frame)))))) |
193 ((eq mode 'half) '(4 . 4)) | 204 nil |
194 ((eq mode 'minimal) '(1 . 1)) | 205 0)))) |
195 ((eq mode (intern "")) | |
196 (if (eq 0 (cdr (assq 'left-fringe | |
197 (if all-frames | |
198 default-frame-alist | |
199 (frame-parameters (selected-frame)))))) | |
200 nil | |
201 0))))) | |
202 | 206 |
203 (defun fringe-mode (&optional mode) | 207 (defun fringe-mode (&optional mode) |
204 "Set the default appearance of fringes on all frames. | 208 "Set the default appearance of fringes on all frames. |
205 | 209 |
206 When called interactively, query the user for MODE. Valid values | 210 When called interactively, query the user for MODE. Valid values |