Function: mc--cache-input-function
mc--cache-input-function is a macro defined in
multiple-cursors-core.el.
Signature
(mc--cache-input-function FN-NAME ARGS-CACHE-KEY-FN)
Documentation
Advise FN-NAME to cache its value in a private variable. Cache is to be used by mc/execute-command-for-all-fake-cursors and caches will be reset by mc--reset-read-prompts. ARGS-CACHE-KEY-FN should transform FN-NAME's args to a unique cache-key so that different calls to FN-NAME during a command can return multiple values.
Source Code
;; Defined in /nix/store/5q7a78ihkz25lf4xmxaa9m7b2ym63m36-emacs-packages-deps/share/emacs/site-lisp/elpa/multiple-cursors-20260419.931/multiple-cursors-core.el
(defmacro mc--cache-input-function (fn-name args-cache-key-fn)
"Advise FN-NAME to cache its value in a private variable. Cache
is to be used by mc/execute-command-for-all-fake-cursors and
caches will be reset by mc--reset-read-prompts. ARGS-CACHE-KEY-FN
should transform FN-NAME's args to a unique cache-key so that
different calls to FN-NAME during a command can return multiple
values."
(let ((mc-name (intern (concat "mc--" (symbol-name fn-name)))))
`(progn
(defun ,mc-name (orig-fun &rest args)
(if (not (bound-and-true-p multiple-cursors-mode))
(apply orig-fun args)
(let* ((cache-key (cons ,(symbol-name fn-name) (,args-cache-key-fn args)))
(cached-value (assoc cache-key mc--input-function-cache))
(return-value (if cached-value (cdr cached-value) (apply orig-fun args))))
(unless cached-value
(push (cons cache-key return-value) mc--input-function-cache))
return-value)))
(advice-add ',fn-name :around #',mc-name))))