emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New global bindings


From: Miles Bader
Subject: Re: New global bindings
Date: Wed, 04 Jun 2008 11:50:42 +0900

M Jared Finder <address@hidden> writes:
> I would be happy with C-x C-+/C-x C-- bindings.

Please try the following:

(define-key ctl-x-map [(control ?+)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?-)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?=)] 'incdec-buffer-face-height)
(define-key ctl-x-map [(control ?0)] 'incdec-buffer-face-height)

(defun incdec-buffer-face-height (&optional inc)
  "Increase or decrease the height of the default face in the current buffer.

Then, continue to read input events and increase/decrease the
face height as long as the input events with all modifiers
removed are one of the following:

   +, =   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

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)))


Thanks,

-Miles

-- 
Education, n. That which discloses to the wise and disguises from the foolish
their lack of understanding.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]