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

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

Re: ~`symbol-function' to get code as list even when byte-compiled?


From: Emanuel Berg
Subject: Re: ~`symbol-function' to get code as list even when byte-compiled?
Date: Tue, 26 May 2015 02:12:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> so I made "use" of it to keep the compiler quiet.

Perhaps this is a better (safer) way to have it in but
still out of action. I never contemplated the Boolean
logic of Elisp but I take it it is short-circuited.
Of course, the byte-compiler's warnings aren't there so
you can come up with ways to code them away, but what
the...

(defun add-one-shot-hook (hook fun)
  (let ((name (cl-gensym)))
    (setf (symbol-function name)
          (lambda (&rest unused)
            (when (or t unused)
              (remove-hook hook name)
              (funcall fun) )))
    (add-hook hook name) ))

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

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