diff options
-rw-r--r-- | doc/emacs/ChangeLog | 7 | ||||
-rw-r--r-- | doc/emacs/display.texi | 46 | ||||
-rw-r--r-- | lisp/ChangeLog | 7 | ||||
-rw-r--r-- | lisp/face-remap.el | 69 |
4 files changed, 103 insertions, 26 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 314c42d4dff..41c3e3225bf 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog @@ -1,3 +1,10 @@ +2008-06-04 Miles Bader <miles@gnu.org> + + * display.texi (Temporary Face Changes): Add + `adjust-buffer-face-height'. Rewrite description of + `increase-buffer-face-height' and `decrease-default-face-height' now + that they aren't bound by default. + 2008-06-03 Miles Bader <miles@gnu.org> * display.texi (Temporary Face Changes): New node. diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 9cf8c986d4a..47650ec5601 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -1178,24 +1178,48 @@ fringe when positioned on that newline. These are commands which temporarily change the default face used to display text in a buffer. +@cindex adjust buffer face height +@findex adjust-buffer-face-height +@kindex C-x C-+ +@kindex C-x C-- +@kindex C-x C-= +@kindex C-x C-0 +To increase the height of the default face in the current buffer one +step, type @kbd{C-x C-+} or @kbd{C-x C-=}. To decrease it one step, +type @kbd{C-x C--}. To restore the default (global) face height, type +@kbd{C-x C-0}. These keys are all bound to the same command, +@code{adjust-buffer-face-height}, which looks at the last key typed to +determine the adjustment to make. + +The final key of these commands may be repeated without the leading +@kbd{C-x} -- for instance, @kbd{C-x C-= C-= C-=} increases the face +height by three steps. + +Each step scales the height of the default face by the value of the +variable @code{text-scale-mode-step} (a negative number of steps +decreases the height by the same amount). As a special case, an +argument of 0 will remove any scaling currently active. + +This command is a special-purpose wrapper around the +@code{increase-buffer-face-height} command which makes repetition +convenient even when it is bound in a non-top-level keymap. For +binding in a top-level keymap, @code{increase-buffer-face-height} or +@code{decrease-default-face-height} may be more appropriate." + @cindex increase buffer face height @findex increase-buffer-face-height @cindex decrease buffer face height @findex decrease-buffer-face-height -@findex text-scale-mode -To increase the size of the font used to display text in the current -buffer, type @kbd{C-=} or @kbd{C-+} -(@code{increase-buffer-face-height}). With a numeric prefix argument, -the size will be increased by that many steps (the default is 1 step); -each step scales the font height by the value of the variable -@code{text-scale-mode-step}. If repeated, this command has a +The @code{increase-buffer-face-height} and +@code{decrease-buffer-face-height} commands increase or decrease the +height of the default face in the current buffer by one step. With a +numeric prefix argument, the size will be increased/decreased by that +many steps; each step scales the font height by the value of the +variable @code{text-scale-mode-step}. If repeated, this command has a cumulative effect. As a special case, a prefix argument of 0 will remove any scaling currently active. -To decrease the size of the text, type @kbd{C--} -(@code{decrease-buffer-face-height}). The behavior is similar to that -of @code{increase-buffer-face-height}, but in reverse. - +@findex text-scale-mode These commands automatically enable or disable the @code{text-scale-mode} minor-mode, depending on whether the current font scaling is other than 1 or not. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7416318744f..9cd7a630cf4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2008-06-04 Miles Bader <miles@gnu.org> + + * face-remap.el (adjust-buffer-face-height): New function. + Add autoloaded keybindings in ctl-x-map. + (increase-buffer-face-height, decrease-buffer-face-height): + Simplify interactive spec to just "p". Remove autoloaded keybindings. + 2008-06-03 Chong Yidong <cyd@stupidchicken.com> * simple.el (line-move-1): If we did not move as far as desired, diff --git a/lisp/face-remap.el b/lisp/face-remap.el index fe517a77a33..f53e37e969e 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -181,8 +181,6 @@ also enable or disable `text-scale-mode' as necessary." text-scale-mode-amount)))) (force-window-update (current-buffer))) -;;;###autoload (global-set-key [(control =)] 'increase-buffer-face-height) -;;;###autoload (global-set-key [(control +)] 'increase-buffer-face-height) ;;;###autoload (defun increase-buffer-face-height (&optional inc) "Increase the height of the default face in the current buffer by INC steps. @@ -192,28 +190,69 @@ Each step scales the height of the default face by the variable `text-scale-mode-step' (a negative number of steps decreases the height by the same amount). As a special case, an argument of 0 will remove any scaling currently active." - (interactive - (list - (cond ((eq current-prefix-arg '-) -1) - ((numberp current-prefix-arg) current-prefix-arg) - ((consp current-prefix-arg) -1) - (t 1)))) + (interactive "p") (setq text-scale-mode-amount (if (= inc 0) 0 (+ text-scale-mode-amount inc))) (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))) -;;;###autoload (global-set-key [(control -)] 'decrease-buffer-face-height) ;;;###autoload (defun decrease-buffer-face-height (&optional dec) "Decrease the height of the default face in the current buffer by DEC steps. See `increase-buffer-face-height' for more details." - (interactive - (list - (cond ((eq current-prefix-arg '-) -1) - ((numberp current-prefix-arg) current-prefix-arg) - ((consp current-prefix-arg) -1) - (t 1)))) + (interactive "p") (increase-buffer-face-height (- dec))) +;;;###autoload (define-key ctl-x-map [(control ?+)] 'adjust-buffer-face-height) +;;;###autoload (define-key ctl-x-map [(control ?-)] 'adjust-buffer-face-height) +;;;###autoload (define-key ctl-x-map [(control ?=)] 'adjust-buffer-face-height) +;;;###autoload (define-key ctl-x-map [(control ?0)] 'adjust-buffer-face-height) +;;;###autoload +(defun adjust-buffer-face-height (&optional inc) + "Increase or decrease the height of the default face in the current buffer. + +The actual adjustment made depends on the final component of the +key-binding used to invoke the command, with all modifiers +removed: + + +, = Increase the default face height by one step + - Decrease the default face height by one step + 0 Reset the default face height to the global default + +Then, continue to read input events and further adjust the face +height as long as the input event read (with all modifiers +removed) is one the above. + +Each step scales the height of the default face by the variable +`text-scale-mode-step' (a negative number of steps decreases the +height by the same amount). As a special case, an argument of 0 +will remove any scaling currently active. + +This command is a special-purpose wrapper around the +`increase-buffer-face-height' command which makes repetition +convenient even when it is bound in a non-top-level keymap. For +binding in a top-level keymap, `increase-buffer-face-height' or +`decrease-default-face-height' may be more appropriate." + (interactive "p") + (let ((first t) + (step t) + (ev last-command-event)) + (while step + (let ((base (event-basic-type ev))) + (cond ((or (eq base ?+) (eq base ?=)) + (setq step inc)) + ((eq base ?-) + (setq step (- inc))) + ((eq base ?0) + (setq step 0)) + (first + (setq step inc)) + (t + (setq step nil)))) + (when step + (increase-buffer-face-height step) + (setq inc 1 first nil) + (setq ev (read-event)))) + (push ev unread-command-events))) + ;; ---------------------------------------------------------------- ;; variable-pitch-mode |