Mercurial > emacs
comparison lisp/face-remap.el @ 95527:0f9689c194e6
Add adjust-buffer-face-height command
... and move face-height adjustment bindings into ctl-x-map using it.
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1203
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 04 Jun 2008 05:38:04 +0000 |
parents | 328f63bafded |
children | 3a67eec377e0 |
comparison
equal
deleted
inserted
replaced
95526:437d3830a398 | 95527:0f9689c194e6 |
---|---|
179 :height | 179 :height |
180 (expt text-scale-mode-step | 180 (expt text-scale-mode-step |
181 text-scale-mode-amount)))) | 181 text-scale-mode-amount)))) |
182 (force-window-update (current-buffer))) | 182 (force-window-update (current-buffer))) |
183 | 183 |
184 ;;;###autoload (global-set-key [(control =)] 'increase-buffer-face-height) | |
185 ;;;###autoload (global-set-key [(control +)] 'increase-buffer-face-height) | |
186 ;;;###autoload | 184 ;;;###autoload |
187 (defun increase-buffer-face-height (&optional inc) | 185 (defun increase-buffer-face-height (&optional inc) |
188 "Increase the height of the default face in the current buffer by INC steps. | 186 "Increase the height of the default face in the current buffer by INC steps. |
189 If the new height is other than the default, `text-scale-mode' is enabled. | 187 If the new height is other than the default, `text-scale-mode' is enabled. |
190 | 188 |
191 Each step scales the height of the default face by the variable | 189 Each step scales the height of the default face by the variable |
192 `text-scale-mode-step' (a negative number of steps decreases the | 190 `text-scale-mode-step' (a negative number of steps decreases the |
193 height by the same amount). As a special case, an argument of 0 | 191 height by the same amount). As a special case, an argument of 0 |
194 will remove any scaling currently active." | 192 will remove any scaling currently active." |
195 (interactive | 193 (interactive "p") |
196 (list | |
197 (cond ((eq current-prefix-arg '-) -1) | |
198 ((numberp current-prefix-arg) current-prefix-arg) | |
199 ((consp current-prefix-arg) -1) | |
200 (t 1)))) | |
201 (setq text-scale-mode-amount (if (= inc 0) 0 (+ text-scale-mode-amount inc))) | 194 (setq text-scale-mode-amount (if (= inc 0) 0 (+ text-scale-mode-amount inc))) |
202 (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))) | 195 (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))) |
203 | 196 |
204 ;;;###autoload (global-set-key [(control -)] 'decrease-buffer-face-height) | |
205 ;;;###autoload | 197 ;;;###autoload |
206 (defun decrease-buffer-face-height (&optional dec) | 198 (defun decrease-buffer-face-height (&optional dec) |
207 "Decrease the height of the default face in the current buffer by DEC steps. | 199 "Decrease the height of the default face in the current buffer by DEC steps. |
208 See `increase-buffer-face-height' for more details." | 200 See `increase-buffer-face-height' for more details." |
209 (interactive | 201 (interactive "p") |
210 (list | |
211 (cond ((eq current-prefix-arg '-) -1) | |
212 ((numberp current-prefix-arg) current-prefix-arg) | |
213 ((consp current-prefix-arg) -1) | |
214 (t 1)))) | |
215 (increase-buffer-face-height (- dec))) | 202 (increase-buffer-face-height (- dec))) |
203 | |
204 ;;;###autoload (define-key ctl-x-map [(control ?+)] 'adjust-buffer-face-height) | |
205 ;;;###autoload (define-key ctl-x-map [(control ?-)] 'adjust-buffer-face-height) | |
206 ;;;###autoload (define-key ctl-x-map [(control ?=)] 'adjust-buffer-face-height) | |
207 ;;;###autoload (define-key ctl-x-map [(control ?0)] 'adjust-buffer-face-height) | |
208 ;;;###autoload | |
209 (defun adjust-buffer-face-height (&optional inc) | |
210 "Increase or decrease the height of the default face in the current buffer. | |
211 | |
212 The actual adjustment made depends on the final component of the | |
213 key-binding used to invoke the command, with all modifiers | |
214 removed: | |
215 | |
216 +, = Increase the default face height by one step | |
217 - Decrease the default face height by one step | |
218 0 Reset the default face height to the global default | |
219 | |
220 Then, continue to read input events and further adjust the face | |
221 height as long as the input event read (with all modifiers | |
222 removed) is one the above. | |
223 | |
224 Each step scales the height of the default face by the variable | |
225 `text-scale-mode-step' (a negative number of steps decreases the | |
226 height by the same amount). As a special case, an argument of 0 | |
227 will remove any scaling currently active. | |
228 | |
229 This command is a special-purpose wrapper around the | |
230 `increase-buffer-face-height' command which makes repetition | |
231 convenient even when it is bound in a non-top-level keymap. For | |
232 binding in a top-level keymap, `increase-buffer-face-height' or | |
233 `decrease-default-face-height' may be more appropriate." | |
234 (interactive "p") | |
235 (let ((first t) | |
236 (step t) | |
237 (ev last-command-event)) | |
238 (while step | |
239 (let ((base (event-basic-type ev))) | |
240 (cond ((or (eq base ?+) (eq base ?=)) | |
241 (setq step inc)) | |
242 ((eq base ?-) | |
243 (setq step (- inc))) | |
244 ((eq base ?0) | |
245 (setq step 0)) | |
246 (first | |
247 (setq step inc)) | |
248 (t | |
249 (setq step nil)))) | |
250 (when step | |
251 (increase-buffer-face-height step) | |
252 (setq inc 1 first nil) | |
253 (setq ev (read-event)))) | |
254 (push ev unread-command-events))) | |
216 | 255 |
217 | 256 |
218 ;; ---------------------------------------------------------------- | 257 ;; ---------------------------------------------------------------- |
219 ;; variable-pitch-mode | 258 ;; variable-pitch-mode |
220 | 259 |