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

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

Re: Emacs scale generator?


From: Dan Espen
Subject: Re: Emacs scale generator?
Date: Thu, 12 Mar 2015 22:30:39 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Emanuel Berg <address@hidden> writes:

> Emanuel Berg <address@hidden> writes:
>
>> Dan Espen <address@hidden> writes:
>>
>>> ... I'm actually looking for something that puts
>>> the text in the buffer.
>>
>> Try this ...
>
> I made a better version and an interactive interface.
> This was interesting. Especially the '(16) or
> `C-u C-u' case below (!).
>
> (defun scale (end step &optional current)
>   (unless current (setq current 0))
>   (if (<= current end)
>       (let*((digit-str (if (= (% current step) 0) (format "%s" current) "."))
>             (digit-str-len  (length digit-str)) )
>         (insert digit-str)
>         (scale end step (+ digit-str-len current)) )))
>
> (defun scale-simple (&optional end)
>   (interactive "p")
>   (let*((the-end  (if (= end 1) 30 end))
>         (the-step (max 1 (/ the-end 10))) )
>     (scale the-end the-step) ))
>
> ;; C-u       M-x scale-simple RET        01234
> ;; C-u C-u   M-x scale-simple RET        012345678910121416
> ;;           M-x scale-simple RET        0..3..6..9..12.15.18.21.24.27.30
> ;; C-u 1 0 0 M-x scale-simple RET        0.........10........20........30 ...

That's exactly what I was going to do.
(Add the interactive wrapper.)

So, I changed the last line:

    (scale the-end 5 1) ))

Then C-u 25 M-x scale-simple gives me:

....5....10...15...20...25

Thanks again!

-- 
Dan Espen


reply via email to

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