[<<][rai][>>][..]
Wed Dec 3 22:16:50 EST 2014

emacs

Live coding in emacs:
- Make saving simpler
- add up/down arrow editing


;; logarithmic number editing
(require 'thingatpt)
(defun my-m-up ()
  (interactive)
  (my-scale-number-at-point 1.1))
(defun my-m-down ()
  (interactive)
  (my-scale-number-at-point 0.9))
(defun my-scale-number-at-point (factor)
  (let*
      ((word (thing-at-point 'symbol))
       (num (string-to-number word)))
    (when (not (zerop num)) ;; Only operate on numbers
      (let* 
          ((updated (* num factor))
           ;; Round digits through exponential notation.
           (snum (format "%.1e" updated))
           ;; But keep ordinary number format
           (snum (number-to-string (string-to-number snum)))
           (bounds (bounds-of-thing-at-point 'symbol))
           (start (car bounds))
           (stop  (cdr bounds)))
        (delete-region start stop)
        (insert snum)))))
(global-set-key (kbd "<M-up>")   'my-m-up)
(global-set-key (kbd "<M-down>") 'my-m-down)


Combine this with M-F3 as save.


http://www.emacswiki.org/emacs/ThingAtPoint



[Reply][About]
[<<][rai][>>][..]