elisp函数单步调试,fac可以单步调试,eglot-alternatives无法单步调试,原因是什么?

eglot-alternatives无法进行单步调试

(defun eglot-alternatives (alternatives)
  (lambda (&optional interactive)
    (let* ((listified (cl-loop for a in alternatives
                               collect (if (listp a) a (list a))))
           (err (lambda ()
                  (error "None of '%s' are valid executables"
                         (mapconcat #'car listified ", ")))))
      (cond (interactive
             (let* ((augmented (mapcar (lambda (a)
                                         (let ((found (eglot--executable-find
                                                       (car a) t)))
                                           (and found
                                                (cons (car a) (cons found (cdr a))))))
                                       listified))
                    (available (remove nil augmented)))
               (cond ((cdr available)
                      (cdr (assoc
                            (completing-read
                             "[eglot] More than one server executable available: "
                             (mapcar #'car available)
                             nil t nil nil (car (car available)))
                            available #'equal)))
                     ((cdr (car available)))
                     (t nil))))
            (t
             (cl-loop for (p . args) in listified
                      for probe = (eglot--executable-find p t)
                      when probe return (cons probe args)
                      finally (funcall err)))))))

fac可以进行单步调试

(defun fac (n)
  (if (< 0 n)
      (* n (fac (1- n)))
    1))

eglot-alternatives 没法直接调试是因为他是返回一个 lambda 的高阶函数

只有返回的函数被执行时才会进入调试状态,如

(funcall (eglot-alternatives '()))
1 个赞

感谢你的回复哈,这个认识是从哪里获得的?为何只有返回的函数被执行时才会进入调试状态?