漂亮的打印

CIDER 函数 cider-insert-last-sexp-in-repl 可用于在编辑缓冲区内的代码时执行代码,并将输出打印在不同的缓冲区中。默认情况下,此功能绑定到 C-c C-p

CIDER 手册说 C-c C-p

评估点之前的表单并在弹出缓冲区中漂亮打印结果。

例如

(def databases {:database1  {:password "password"
                             :database "test"
                             :port "5432"
                             :host "localhost"
                             :user "username"}
                  
                :database2 {:password "password"
                            :database "different_test_db"
                            :port "5432"
                            :host "localhost"
                            :user "vader"}})

(defn get-database-config
  []
  databases)

(get-database-config)

当光标位于 get-database-config 函数调用的结束位置之前时执行 C-c C-p 将在新的弹出缓冲区中输出漂亮的打印地图。

{:database1
 {:password "password",
  :database "test",
  :port "5432",
  :host "localhost",
  :user "username"},
 :database2
 {:password "password",
  :database "different_test_db",
  :port "5432",
  :host "localhost",
  :user "vader"}}