漂亮的列印

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"}}