bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#21634: 24.5; Suggested improvement


From: Eli Barzilay
Subject: bug#21634: 24.5; Suggested improvement
Date: Tue, 6 Oct 2015 08:04:03 -0400

Would it make sense to implement `text-scale-adjust' as follows?  One
minor change is using the `keep-pred' argument to avoid re-setting the
map repeatedly, but the important change is having it timeout after a
few seconds.  This avoids the kind of mode-ish interaction that feels
weird in Emacs.

In fact, I find this useful in other cases too (a command that allows
you to resize the current window with the arrow keys), so I think that
it's useful to either add an additional timeout argument -- or perhaps
an extension where `keep-pred' can be a number of seconds and will do
the timeout thing.

-------------------------------------------------------------------------------
(defun text-scale-adjust (inc)
  "..."
  (interactive "p")
  (let ((ev last-command-event)
        (echo-keystrokes nil))
    (let* ((base (event-basic-type ev))
           (step
            (pcase base
              ((or ?+ ?=) inc)
              (?- (- inc))
              (?0 0)
              (_ inc))))
      (text-scale-increase step)
      (message "Use +,-,0 for further adjustment")
      (run-with-idle-timer 2 nil
        (set-transient-map
         (let ((map (make-sparse-keymap)))
           (dolist (mods '(() (control)))
             (dolist (key '(?- ?+ ?= ?0)) ;; = is often unshifted +.
               (define-key map (vector (append mods (list key)))
                 (lambda () (interactive) (text-scale-adjust (abs inc))))))
           map)
         t (lambda () (message "done")))))))
-------------------------------------------------------------------------------

-- 
                    ((x=>x(x))(x=>x(x)))                   Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





reply via email to

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