53
53
54
54
(defvar-local mldoc-returns-string t
55
55
" When not-NIL, MLDoc functions return ElDoc complatible string." )
56
+
57
+ (defvar-local mldoc-propertizer* nil
58
+ " Dynamic bound list of propertizers." )
56
59
57
60
; ; Utility functions
58
61
(defsubst mldoc-in-string ()
@@ -80,31 +83,47 @@ The definition is (lambda ARGLIST [DOCSTRING] BODY...)."
80
83
(mapconcat #'identity (apply #'mldoc--build-list doc) " " )
81
84
doc))))
82
85
83
- (defun mldoc--propertize-args (args current-arg arg-separator )
84
- " Return propertized string by `ARGS' list, `CURRENT-ARG' and `ARG-SEPARATOR' ."
86
+ (defun mldoc--propertize-arg (arg is-current-arg arg-spec )
87
+ " Propertize `ARG' by `IS-CURRENT-ARG' and `ARG-SPEC' ."
88
+ (cl-loop
89
+ for spec in arg-spec
90
+ collect
91
+ (if (stringp spec)
92
+ spec
93
+ (let ((v (plist-get arg spec)))
94
+ (if (null v)
95
+ " "
96
+ (if (and is-current-arg (eq :name spec))
97
+ (propertize v 'face '(:weight bold ))
98
+ (mldoc--propertize-keyword arg spec)))))))
99
+
100
+ (defun mldoc--propertize-args (args current-arg arg-separator &optional arg-spec )
101
+ " Return propertized string by `ARGS' list, `CURRENT-ARG' , `ARG-SEPARATOR' and `ARG-SPEC' ."
85
102
(mapconcat
86
103
#'identity
87
104
(cl-loop for arg in args
88
105
for n = 0 then (1+ n)
89
- collect (if (not (and current-arg (eq n current-arg)))
90
- arg
91
- (propertize arg 'face '(:weight bold ))))
106
+ append
107
+ (mldoc--propertize-arg
108
+ (if (stringp arg) (list :name arg) arg)
109
+ (eq current-arg n)
110
+ (or arg-spec (list :name ))))
92
111
(or arg-separator " , " )))
93
112
94
113
(defun mldoc--propertizers-to-list (propertizer )
95
114
" Return list for function `propertize' by `PROPERTIZER' alist."
96
115
(cl-loop for (p . sym) in propertizer
97
116
append (list p (symbol-value sym))))
98
117
99
- (defun mldoc--propertize-keyword (values key propertizers )
118
+ (defun mldoc--propertize-keyword (values key )
100
119
" Return propertized string `KEY' in `VALUES' plist, by `FACES' ."
101
120
(let* ((val (plist-get values key))
102
- (str (if (stringp val)
103
- val
104
- ( funcall val) ))
105
- (prop (cdr-safe (assq key propertizers ))))
121
+ (str (if (functionp val)
122
+ ( funcall val)
123
+ val))
124
+ (prop (cdr-safe (assq key mldoc-propertizer* ))))
106
125
(if (null prop)
107
- str
126
+ ( or str " " )
108
127
(apply #'propertize str (mldoc--propertizers-to-list prop)))))
109
128
110
129
(cl-defmacro mldoc-list (spec &key function propertizers args current-arg values )
@@ -126,20 +145,20 @@ plist `values'
126
145
"
127
146
(setq values (plist-put values :function function))
128
147
(setq values (plist-put values :args args))
129
- (setq propertizers ( append propertizers mldoc-default-eldoc-propertizers))
130
-
131
- (cl-loop
132
- for s in spec collect
133
- (cond
134
- ((stringp s) s)
135
- ((symbolp s)
136
- (if (not (keywordp s))
137
- (symbol-value s)
138
- (mldoc--propertize-keyword values s propertizers )))
139
- ((listp s)
140
- (if (eq 'args (car s))
141
- (mldoc--propertize-args args current-arg (nth 1 s))
142
- (apply (car s) (cdr s)))))))
148
+ (let (( mldoc-propertizer*
149
+ ( append propertizers mldoc-default-eldoc-propertizers)))
150
+ (cl-loop
151
+ for s in spec collect
152
+ (cond
153
+ ((stringp s) s)
154
+ ((symbolp s)
155
+ (if (not (keywordp s))
156
+ (symbol-value s)
157
+ (mldoc--propertize-keyword values s)))
158
+ ((listp s)
159
+ (if (eq 'args (car s))
160
+ (mldoc--propertize-args args current-arg (nth 1 s) ( cddr s))
161
+ (apply (car s) (cdr s) )))))))
143
162
144
163
(defun mldoc-eldoc-function ()
145
164
" ElDoc backend function by MLDoc package."
0 commit comments