diff options
| author | Miles Bader | 2008-06-04 05:38:04 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-06-04 05:38:04 +0000 |
| commit | 56c73dec5cf9f392a3ddfa6472f8eb61ff1cbaf9 (patch) | |
| tree | 7a1b43cf57f200ee7ea98e68a123cd23f91c4ae4 /lisp | |
| parent | 2a1e0c92c318a2c0ba436b4435cd0fe2f7f75261 (diff) | |
| download | emacs-56c73dec5cf9f392a3ddfa6472f8eb61ff1cbaf9.tar.gz emacs-56c73dec5cf9f392a3ddfa6472f8eb61ff1cbaf9.zip | |
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
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/face-remap.el | 69 |
2 files changed, 61 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7416318744f..9cd7a630cf4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-06-04 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * face-remap.el (adjust-buffer-face-height): New function. | ||
| 4 | Add autoloaded keybindings in ctl-x-map. | ||
| 5 | (increase-buffer-face-height, decrease-buffer-face-height): | ||
| 6 | Simplify interactive spec to just "p". Remove autoloaded keybindings. | ||
| 7 | |||
| 1 | 2008-06-03 Chong Yidong <cyd@stupidchicken.com> | 8 | 2008-06-03 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 9 | ||
| 3 | * simple.el (line-move-1): If we did not move as far as desired, | 10 | * 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." | |||
| 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. |
| @@ -192,28 +190,69 @@ 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))) |
| 216 | 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))) | ||
| 255 | |||
| 217 | 256 | ||
| 218 | ;; ---------------------------------------------------------------- | 257 | ;; ---------------------------------------------------------------- |
| 219 | ;; variable-pitch-mode | 258 | ;; variable-pitch-mode |