美文网首页初见
emacs的cider-debug-defun-point

emacs的cider-debug-defun-point

作者: 小马将过河 | 来源:发表于2020-06-08 23:02 被阅读0次

    演示代码

    ;; 1. Call M-x cider-debug-init-connectiong(only needed once),
    ;; 2. Call M-x cider-debug-defun-at-ponit with point inside this defn.
    ;; 3. Run the function, and using key word
    ;; 4. link:https://docs.cider.mx/cider/debugging/debugger.html
    (defn foo [n]
      (map (partial * 2)
           (filter even?
                   (range 0 n))))
    
    ;; break out when reaching a condition
    (defn foo2 []
      (dotimes [i 10]
        #dbg ^{:break/when (= i 7)}
        (prn i)))
    
    
    (defn eval-msg [{:keys [inspect] :as msg}]
      (if inspect
        #break (clojure.inspector/inspect msg)
        msg))
    
    

    进入debug
    M-x cider-debug-defun-at-point

    常见的操作:

    j Inject a value into running code

    e C-c M-: 表达式求值

    enlighten模式:查看最后一次表达式的值
    M-x cider-enlighten-mode
    C-M-x 或者 C-x C-e 开始执行。 C-c C-k取消操作。
    M-x cider-enlighten-mode关闭enlighten模式

    (defn foo2 [x]
      (let [y (* 3 x)]
        (+ x y)))
    
    (defn bar [x]
      (dotimes [i x]
        (foo2 i)))
    
    (bar 5)
    
    

    参考

    debugger
    Enlighten

    相关文章

      网友评论

        本文标题:emacs的cider-debug-defun-point

        本文链接:https://www.haomeiwen.com/subject/vwvpwhtx.html