dwim: make dwim feature optional

pull/2948/head^2
leizhe 2021-10-18 18:23:21 +08:00 committed by Tienson Qin
parent 3366d45337
commit f9c77d8300
2 changed files with 26 additions and 6 deletions

View File

@ -2326,12 +2326,18 @@
has-right? (-> (tree/-get-right current-node)
(tree/satisfied-inode?))
thing-at-point ;intern is not supported in cljs, need a more elegant solution
(or (thingatpt/admonition&src-at-point input)
(thingatpt/markup-at-point input)
(thingatpt/block-ref-at-point input)
(thingatpt/page-ref-at-point input)
(thingatpt/properties-at-point input)
(thingatpt/list-item-at-point input))]
(or (when (thingatpt/get-setting :admonition&src?)
(thingatpt/admonition&src-at-point input))
(when (thingatpt/get-setting :markup?)
(thingatpt/markup-at-point input))
(when (thingatpt/get-setting :block-ref?)
(thingatpt/block-ref-at-point input))
(when (thingatpt/get-setting :page-ref?)
(thingatpt/page-ref-at-point input))
(when (thingatpt/get-setting :properties?)
(thingatpt/properties-at-point input))
(when (thingatpt/get-setting :list?)
(thingatpt/list-item-at-point input)))]
(cond
thing-at-point
(case (:type thing-at-point)

View File

@ -1,5 +1,6 @@
(ns frontend.util.thingatpt
(:require [clojure.string :as string]
[frontend.handler.config :as config-handler]
[frontend.state :as state]
[frontend.util.property :as property-util]
[frontend.util.cursor :as cursor]
@ -157,3 +158,16 @@
(defn admonition&src-at-point [& [input]]
(or (org-admonition&src-at-point input)
(markdown-src-at-point input)))
(def default-settings
{:admonition&src? true
:markup? false
:block-ref? true
:page-ref? true
:properties? true
:list? true})
(defn get-setting [setting]
(get-in (state/get-config) [:dwim/settings setting] default-settings))