emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/shortdoc 10556bc: Add a way to add shortdocs from "outside"


From: Lars Ingebrigtsen
Subject: scratch/shortdoc 10556bc: Add a way to add shortdocs from "outside"
Date: Sun, 27 Sep 2020 18:17:24 -0400 (EDT)

branch: scratch/shortdoc
commit 10556bc499ddfd9c343e07abb7f8fb22fa8686bf
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a way to add shortdocs from "outside"
    
    * lisp/emacs-lisp/shortdoc.el (shortdoc-add-function): Add
    function to allow external packages to register shortdocs.
---
 lisp/emacs-lisp/shortdoc.el | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index 8665c2d..eace779 100644
--- a/lisp/emacs-lisp/shortdoc.el
+++ b/lisp/emacs-lisp/shortdoc.el
@@ -704,6 +704,28 @@ There can be any number of :example/:result elements."
            when (assq function (cdr group))
            collect (car group)))
 
+(defun shortdoc-add-function (group section elem)
+  "Add ELEM to shortdoc GROUP in SECTION.
+If SECTION doesn't exist, it will be added.
+
+Example:
+
+  (shortdoc-add-function
+    'file \"Predicates\"
+    '(file-locked-p :example-no-eval (file-locked-p \"/tmp\")))"
+  (let ((glist (assq group shortdoc--groups)))
+    (unless glist
+      (setq glist (list group))
+      (setq shortdoc--groups (append shortdoc--groups (list glist))))
+    (let ((slist (member section glist)))
+      (unless slist
+        (setq slist (list section))
+        (append glist slist))
+      (while (and (cdr slist)
+                  (not (stringp (cadr slist))))
+        (setq slist (cdr slist)))
+      (setcdr slist (cons elem (cdr slist))))))
+
 (provide 'shortdoc)
 
 ;;; shortdoc.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]