mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
fix docstring extraction for "fancy" docs
The docstrings for yas-expand and yas-expand-from-keymap are generated on the fly, depending on how they are called ("context"). Add a context argument to the synthesizing functions and pass it nil when extracting docstrings for the manual.
This commit is contained in:
parent
8d7c9a63a2
commit
eaa3141402
@ -49,7 +49,10 @@
|
|||||||
(body (or (cond ((boundp symbol)
|
(body (or (cond ((boundp symbol)
|
||||||
(documentation-property symbol 'variable-documentation t))
|
(documentation-property symbol 'variable-documentation t))
|
||||||
((fboundp symbol)
|
((fboundp symbol)
|
||||||
(documentation symbol t))
|
(let ((doc-synth (car-safe (get symbol 'function-documentation))))
|
||||||
|
(if (functionp doc-synth)
|
||||||
|
(funcall doc-synth nil)
|
||||||
|
(documentation symbol t))))
|
||||||
(t
|
(t
|
||||||
(format "*WARNING*: no symbol named =%s=" symbol)))
|
(format "*WARNING*: no symbol named =%s=" symbol)))
|
||||||
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
||||||
|
34
yasnippet.el
34
yasnippet.el
@ -4298,31 +4298,33 @@ When multiple expressions are found, only the last one counts."
|
|||||||
;; depending on the context.
|
;; depending on the context.
|
||||||
;;
|
;;
|
||||||
(put 'yas-expand 'function-documentation
|
(put 'yas-expand 'function-documentation
|
||||||
'(yas--expand-from-trigger-key-doc))
|
'(yas--expand-from-trigger-key-doc t))
|
||||||
(defun yas--expand-from-trigger-key-doc ()
|
(defun yas--expand-from-trigger-key-doc (context)
|
||||||
"A doc synthesizer for `yas--expand-from-trigger-key-doc'."
|
"A doc synthesizer for `yas--expand-from-trigger-key-doc'."
|
||||||
(let ((fallback-description
|
(let* ((yas-fallback-behavior (and context yas-fallback-behavior))
|
||||||
(cond ((eq yas-fallback-behavior 'call-other-command)
|
(fallback-description
|
||||||
(let* ((fallback (yas--keybinding-beyond-yasnippet)))
|
(cond ((eq yas-fallback-behavior 'call-other-command)
|
||||||
(or (and fallback
|
(let* ((fallback (yas--keybinding-beyond-yasnippet)))
|
||||||
(format " call command `%s'." (pp-to-string fallback)))
|
(or (and fallback
|
||||||
" do nothing (`yas-expand' doesn't shadow\nanything)")))
|
(format "call command `%s'."
|
||||||
((eq yas-fallback-behavior 'return-nil)
|
(pp-to-string fallback)))
|
||||||
", do nothing.")
|
"do nothing (`yas-expand' doesn't shadow\nanything).")))
|
||||||
(t
|
((eq yas-fallback-behavior 'return-nil)
|
||||||
", defer to `yas-fallback-behaviour' (which see)"))))
|
"do nothing.")
|
||||||
|
(t "defer to `yas-fallback-behaviour' (which see)."))))
|
||||||
(concat "Expand a snippet before point. If no snippet
|
(concat "Expand a snippet before point. If no snippet
|
||||||
expansion is possible,"
|
expansion is possible, "
|
||||||
fallback-description
|
fallback-description
|
||||||
"\n\nOptional argument FIELD is for non-interactive use and is an
|
"\n\nOptional argument FIELD is for non-interactive use and is an
|
||||||
object satisfying `yas--field-p' to restrict the expansion to.")))
|
object satisfying `yas--field-p' to restrict the expansion to.")))
|
||||||
|
|
||||||
(put 'yas-expand-from-keymap 'function-documentation '(yas--expand-from-keymap-doc))
|
(put 'yas-expand-from-keymap 'function-documentation
|
||||||
(defun yas--expand-from-keymap-doc ()
|
'(yas--expand-from-keymap-doc t))
|
||||||
|
(defun yas--expand-from-keymap-doc (context)
|
||||||
"A doc synthesizer for `yas--expand-from-keymap-doc'."
|
"A doc synthesizer for `yas--expand-from-keymap-doc'."
|
||||||
(add-hook 'temp-buffer-show-hook 'yas--snippet-description-finish-runonce)
|
(add-hook 'temp-buffer-show-hook 'yas--snippet-description-finish-runonce)
|
||||||
(concat "Expand/run snippets from keymaps, possibly falling back to original binding.\n"
|
(concat "Expand/run snippets from keymaps, possibly falling back to original binding.\n"
|
||||||
(when (eq this-command 'describe-key)
|
(when (and context (eq this-command 'describe-key))
|
||||||
(let* ((vec (this-single-command-keys))
|
(let* ((vec (this-single-command-keys))
|
||||||
(templates (mapcan #'(lambda (table)
|
(templates (mapcan #'(lambda (table)
|
||||||
(yas--fetch table vec))
|
(yas--fetch table vec))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user