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

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

Re: same data appears twice, interactive then function body


From: Stefan Monnier
Subject: Re: same data appears twice, interactive then function body
Date: Tue, 15 Dec 2020 21:44:34 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Check out this code, how do you avoid having 80 appear twice?

> (defun insert-string-centered (string &optional width)
>   (interactive
>    (list (read-from-minibuffer "string: ")
>          (string-to-number (read-from-minibuffer "width [80]: "))) )
>   (let*((max         (if (< 0 width) width 80))
> [...]

Here's my take on it:

    (defun insert-string-centered (string &optional width)
      (interactive
       (list (read-from-minibuffer "string: ")
             (string-to-number (read-from-minibuffer "width [80]: "))) )
      (let*((max         (if (< 0 width) width (+ 42 42 -4)))
    [...]

Now the question is how to avoid having 42 appear twice, I guess,


        Stefan




reply via email to

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