diff options
| author | Bastien | 2012-10-26 13:07:35 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-10-26 13:07:35 -0400 |
| commit | c577256946cde9d0558a4395cc15cf6a0119adce (patch) | |
| tree | 450371df733b45e17fa9ab950bbf7b337a3df00d | |
| parent | 63314e573028a6b8b75566b05193e34117221d03 (diff) | |
| download | emacs-c577256946cde9d0558a4395cc15cf6a0119adce.tar.gz emacs-c577256946cde9d0558a4395cc15cf6a0119adce.zip | |
* lisp/face-remap.el: Use lexical-binding.
(text-scale-adjust): Improve docstring. Use itself for the temporary
overlay-map bindings, so as to repeat the "Use..." message each time.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/face-remap.el | 33 |
2 files changed, 23 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3473dbf6233..bda9ac0d4aa 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-10-26 Bastien <bzg@altern.org> | ||
| 2 | Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 3 | |||
| 4 | * face-remap.el: Use lexical-binding. | ||
| 5 | (text-scale-adjust): Improve docstring. Use itself for the temporary | ||
| 6 | overlay-map bindings, so as to repeat the "Use..." message each time. | ||
| 7 | |||
| 1 | 2012-10-26 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2012-10-26 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * emacs-lisp/macroexp.el (macroexp--expand-all): | 10 | * emacs-lisp/macroexp.el (macroexp--expand-all): |
diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 09503d7c154..baf1eeb389d 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; face-remap.el --- Functions for managing `face-remapping-alist' | 1 | ;;; face-remap.el --- Functions for managing `face-remapping-alist' -*- lexical-binding: t -*- |
| 2 | ;; | 2 | ;; |
| 3 | ;; Copyright (C) 2008-2012 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| @@ -285,7 +285,9 @@ See `text-scale-increase' for more details." | |||
| 285 | ;;;###autoload (define-key ctl-x-map [(control ?0)] 'text-scale-adjust) | 285 | ;;;###autoload (define-key ctl-x-map [(control ?0)] 'text-scale-adjust) |
| 286 | ;;;###autoload | 286 | ;;;###autoload |
| 287 | (defun text-scale-adjust (inc) | 287 | (defun text-scale-adjust (inc) |
| 288 | "Increase or decrease the height of the default face in the current buffer. | 288 | "Adjust the height of the default face by INC. |
| 289 | |||
| 290 | INC may be passed as a numeric prefix argument. | ||
| 289 | 291 | ||
| 290 | The actual adjustment made depends on the final component of the | 292 | The actual adjustment made depends on the final component of the |
| 291 | key-binding used to invoke the command, with all modifiers removed: | 293 | key-binding used to invoke the command, with all modifiers removed: |
| @@ -294,9 +296,11 @@ key-binding used to invoke the command, with all modifiers removed: | |||
| 294 | - Decrease the default face height by one step | 296 | - Decrease the default face height by one step |
| 295 | 0 Reset the default face height to the global default | 297 | 0 Reset the default face height to the global default |
| 296 | 298 | ||
| 297 | Then, continue to read input events and further adjust the face | 299 | When adjusting with `+' or `-', continue to read input events and |
| 298 | height as long as the input event read (with all modifiers removed) | 300 | further adjust the face height as long as the input event read |
| 299 | is one of the above. | 301 | \(with all modifiers removed) is `+' or `-'. |
| 302 | |||
| 303 | When adjusting with `0', immediately finish. | ||
| 300 | 304 | ||
| 301 | Each step scales the height of the default face by the variable | 305 | Each step scales the height of the default face by the variable |
| 302 | `text-scale-mode-step' (a negative number of steps decreases the | 306 | `text-scale-mode-step' (a negative number of steps decreases the |
| @@ -309,8 +313,7 @@ even when it is bound in a non-top-level keymap. For binding in | |||
| 309 | a top-level keymap, `text-scale-increase' or | 313 | a top-level keymap, `text-scale-increase' or |
| 310 | `text-scale-decrease' may be more appropriate." | 314 | `text-scale-decrease' may be more appropriate." |
| 311 | (interactive "p") | 315 | (interactive "p") |
| 312 | (let ((first t) | 316 | (let ((ev last-command-event) |
| 313 | (ev last-command-event) | ||
| 314 | (echo-keystrokes nil)) | 317 | (echo-keystrokes nil)) |
| 315 | (let* ((base (event-basic-type ev)) | 318 | (let* ((base (event-basic-type ev)) |
| 316 | (step | 319 | (step |
| @@ -320,19 +323,15 @@ a top-level keymap, `text-scale-increase' or | |||
| 320 | (?0 0) | 323 | (?0 0) |
| 321 | (t inc)))) | 324 | (t inc)))) |
| 322 | (text-scale-increase step) | 325 | (text-scale-increase step) |
| 323 | ;; FIXME: do it after every "iteration of the loop". | 326 | ;; (unless (zerop step) |
| 324 | (message "+,-,0 for further adjustment: ") | 327 | (message "Use +,-,0 for further adjustment") |
| 325 | (set-temporary-overlay-map | 328 | (set-temporary-overlay-map |
| 326 | (let ((map (make-sparse-keymap))) | 329 | (let ((map (make-sparse-keymap))) |
| 327 | (dolist (mods '(() (control))) | 330 | (dolist (mods '(() (control))) |
| 328 | (define-key map (vector (append mods '(?-))) 'text-scale-decrease) | 331 | (dolist (key '(?- ?+ ?= ?0)) ;; = is often unshifted +. |
| 329 | (define-key map (vector (append mods '(?+))) 'text-scale-increase) | 332 | (define-key map (vector (append mods (list key))) |
| 330 | ;; = is unshifted + on most keyboards. | 333 | (lambda () (interactive) (text-scale-adjust (abs inc)))))) |
| 331 | (define-key map (vector (append mods '(?=))) 'text-scale-increase) | 334 | map))))) ;; ) |
| 332 | (define-key map (vector (append mods '(?0))) | ||
| 333 | (lambda () (interactive) (text-scale-increase 0)))) | ||
| 334 | map) | ||
| 335 | t)))) | ||
| 336 | 335 | ||
| 337 | 336 | ||
| 338 | ;; ---------------------------------------------------------------- | 337 | ;; ---------------------------------------------------------------- |