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

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

Re: avoid global variables by using closures


From: Jude DaShiell
Subject: Re: avoid global variables by using closures
Date: Wed, 8 Sep 2021 16:58:29 -0400

I've had similar errors happen while building dismal no idea why though
since I didn't do source code diving.


On Wed, 8 Sep 2021, Emanuel Berg via Users list for the GNU Emacs text
editor wrote:

> I don't know what I've been smoking, this gave me a warning
> from the byte-compiler saying the function wasn't known to be
> defined, but now it seems to work all of a sudden?
>
> (require 'cl-lib)
>
> (let ((times 0))
>   (defun time (&optional reset)
>     (interactive)
>     (let ((res (or reset current-prefix-arg)))
>       (if res
>           (setq times 0)
>         (cl-incf times) ))
>     (if (called-interactively-p 'interactive)
>         (message "times: %d" times)
>       times) ))
> ;; test:
> ;;   (call-interactively 'time)
> ;;   (let ((current-prefix-arg t)) (call-interactively 'time))
> ;;   (time)
> ;;   (time t)
>
>



reply via email to

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