Function: projection-multi--cache-command-helpers
projection-multi--cache-command-helpers is a macro defined in
projection-multi.el.
Signature
(projection-multi--cache-command-helpers TARGET-FUNCTIONS &rest BODY)
Documentation
Setup memoisation for each function in TARGET-FUNCTIONS.
Within the body of this macro every invocation of TARGET-FUNCTIONS is cached. If a previous invocation with the same arguments is already in the cache it will be returned directly. This function as a simple optimiser. All the functions in TARGET-FUNCTIONS must be defined when BODY is invoked and the result of each function should be deterministic.
Source Code
;; Defined in /nix/store/p352vg5hx7hmw07f7hjwfyrih9p75bzv-emacs-packages-deps/share/emacs/site-lisp/elpa/projection-multi-20260614.1822/projection-multi.el
(defmacro projection-multi--cache-command-helpers (target-functions &rest body)
"Setup memoisation for each function in TARGET-FUNCTIONS.
Within the body of this macro every invocation of TARGET-FUNCTIONS is cached.
If a previous invocation with the same arguments is already in the cache it
will be returned directly. This function as a simple optimiser. All the
functions in TARGET-FUNCTIONS must be defined when BODY is invoked and the
result of each function should be deterministic."
(declare (indent 2))
`(let ((--projection-multi-helper-cache nil))
(let* ((target-functions (quote (list ,@target-functions)))
(loaded-target-functions
(seq-filter #'symbol-function (quote (list ,@target-functions))))
(missing-target-functions
(seq-difference target-functions loaded-target-functions)))
(cl-assert
(not missing-target-functions)
'show-args
"Command helper caching requires all cached helpers to be loaded %s"
missing-target-functions))
(cl-letf*
(,@(cl-loop for function in target-functions
with cached-function = nil
do (setq cached-function
(intern (concat "--project-multi-cached-"
(symbol-name function))))
collect
`(,cached-function (symbol-function ',function))
collect
`((symbol-function ',function)
(lambda (&rest args)
(let ((key (append (list ',function) args)))
(if-let* ((cached
(assoc key --projection-multi-helper-cache #'equal)))
(cdr cached)
(let ((value (apply ,cached-function args)))
(push (cons key value) --projection-multi-helper-cache)
value)))))))
,@body)))