Function: majutsu-template--maybe-self-dispatch
majutsu-template--maybe-self-dispatch is a natively compiled function
defined in majutsu-template.el.
Signature
(majutsu-template--maybe-self-dispatch OP ARGS)
Documentation
Return method node if OP is a self keyword applicable in current context.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-template.el
(defun majutsu-template--maybe-self-dispatch (op args)
"Return method node if OP is a self keyword applicable in current context."
(let ((self-binding (majutsu-template--current-self)))
(when (and self-binding (or (symbolp op) (stringp op)))
(let* ((object (majutsu-template--self-binding-node self-binding))
(owner (majutsu-template--self-binding-type self-binding)))
(when object
(let* ((name (if (symbolp op)
(majutsu-template--symbol->template-name op)
op))
(meta (and owner
(majutsu-template--lookup-method-for-type owner name)))
(normalized-args (mapcar #'majutsu-template--rewrite args))
(deferred-self (majutsu-template--node-has-deferred-type-p object)))
(cond
((and meta (not (majutsu-template--fn-keyword meta)))
nil)
((and meta
normalized-args
(not (majutsu-template--method-name-node-p (car normalized-args))))
(user-error "majutsu-template: keyword %s on %S does not accept arguments"
name owner))
(meta
(let ((name-node (majutsu-template--rewrite op))
(dispatch-object (if owner
(majutsu-template--node-with-type object owner)
object)))
(apply #'majutsu-template-method dispatch-object name-node normalized-args)))
((and (null owner) deferred-self (keywordp op))
(let ((name-node (majutsu-template--rewrite op)))
(apply #'majutsu-template-method object name-node normalized-args))))))))))