diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2017-12-31 00:33:24 +0000 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2017-12-31 00:33:24 +0000 |
| commit | c1fa68fa092201353d3666040c1e89bd31720227 (patch) | |
| tree | d75fc25d9c38add35db2d46ada187b42ba90441e | |
| parent | 4ab9da8f434b0d0c17e80e29f7d56e02ae43f8bd (diff) | |
Highlight keywords in docstrings
See defface for an example.
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | helpful.el | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0c04e..4537037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Added disassemble buttons to byte-code functions in symbol properties. Fixed an issue with the prompt when setting variables to symbol values. +Quoted keywords in docstrings are now highlighted. + # v0.5 Allow function tracing to be enabled/disabled from Helpful buffers. @@ -542,6 +542,19 @@ blank line afterwards." (-cons* first-line "" (cdr lines))) docstring))) +(defun helpful--propertize-keywords (docstring) + "Propertize quoted keywords in docstrings." + (replace-regexp-in-string + ;; Replace all text of the form `foo'. + (rx "`" + (group ":" symbol-start (+? anything) symbol-end) + "'") + (lambda (it) + (propertize (match-string 1 it) + 'face 'font-lock-builtin-face)) + docstring + t t)) + (defun helpful--propertize-symbols (docstring) "Convert symbol references in docstrings to buttons." (replace-regexp-in-string @@ -640,6 +653,7 @@ unescaping too." (helpful--split-first-line) (helpful--propertize-info) (helpful--propertize-symbols) + (helpful--propertize-keywords) (s-trim))) (helpful--format-docstring "(apply '+ 1 '(1 2))") |
