aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/tips.texi
diff options
context:
space:
mode:
authorHelmut Eller2026-04-04 20:59:46 +0200
committerHelmut Eller2026-04-04 20:59:46 +0200
commit6eec001187e8551f32b6498e6dc60cdc58c2e515 (patch)
tree13233de9f0a05ef86a51500e8b1870b75ff20c81 /doc/lispref/tips.texi
parente4ea27119e79012f9d651cb61d1115589d91ef39 (diff)
parent01a9d78a7e4c7d7fa5b799e4fdc2caf77a012734 (diff)
downloademacs-feature/igc3.tar.gz
emacs-feature/igc3.zip
Merge branch 'master' into feature/igc3feature/igc3
Diffstat (limited to 'doc/lispref/tips.texi')
-rw-r--r--doc/lispref/tips.texi84
1 files changed, 84 insertions, 0 deletions
diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index 7f22dc06ef2..2fbac9508d6 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -35,6 +35,7 @@ in batch mode, e.g., with a command run by @kbd{@w{M-x compile
35* Compilation Tips:: Making compiled code run fast. 35* Compilation Tips:: Making compiled code run fast.
36* Warning Tips:: Turning off compiler warnings. 36* Warning Tips:: Turning off compiler warnings.
37* Documentation Tips:: Writing readable documentation strings. 37* Documentation Tips:: Writing readable documentation strings.
38* Documentation Group Tips:: Writing useful documentation groups.
38* Comment Tips:: Conventions for writing comments. 39* Comment Tips:: Conventions for writing comments.
39* Library Headers:: Standard headers for library packages. 40* Library Headers:: Standard headers for library packages.
40@end menu 41@end menu
@@ -934,6 +935,89 @@ If you do not anticipate anyone editing your code with older Emacs
934versions, there is no need for this work-around. 935versions, there is no need for this work-around.
935@end itemize 936@end itemize
936 937
938@node Documentation Group Tips
939@section Tips for Documentation Groups
940@cindex documentation groups, tips
941@cindex tips for documentation groups
942
943@cindex documentation groups, compatibility
944 Documentation groups, available since Emacs 28, are useful to document
945functions of Lisp packages based on various groupings
946(@pxref{Documentation Groups}). This section gives some tips on how you
947can define documentation groups in your Lisp package in a way such that
948users of different Emacs versions can equally well use these groups.
949
950@itemize @bullet
951@item
952To define documentation groups for your own Lisp package across
953different Emacs versions, you can use a boilerplate template along the
954lines of the following to make your package compile and load without
955errors:
956
957@smallexample
958@group
959;;; well-doc.el --- a well-documented package -*- lexical-binding: t; -*-
960
961@dots{} package header and contents @dots{}
962@end group
963
964@group
965;; Explicitly require shortdoc for Emacs 28, which does not have an
966;; autoload for macro `define-short-documentation-group'. And for
967;; Emacs 30, so that we can redefine `shortdoc--check' later.
968(require 'shortdoc nil t)
969
970(eval-when-compile
971
972 ;; Default macro `define-short-documentation-group' for Emacs 27
973 ;; and older, which do not have the shortdoc feature at all.
974 (unless (fboundp 'define-short-documentation-group)
975 (defmacro define-short-documentation-group (&rest _)))
976
977 ;; Disable too rigid shortdoc checks for Emacs 30, which let it
978 ;; error out on newer shortdoc keywords.
979 (when (eq emacs-major-version 30)
980 (fset 'shortdoc--check #'ignore)))
981@end group
982
983@group
984(define-short-documentation-group well-doc
985 @dots{})
986
987;;; well-doc.el ends here
988@end group
989@end smallexample
990
991@findex define-short-documentation-group
992If you do not intend to support some of the Emacs versions mentioned
993above, you can safely omit the corresponding forms from the template.
994If you intend to support only Emacs 31 and newer, you do not need any
995of the above and can just use @code{define-short-documentation-group}.
996
997@item
998@cindex documentation group keywords, compatibility
999Newer Emacs versions might introduce newer documentation group features
1000and keywords. However, these features or keywords will never break the
1001display of a documentation group in older Emacs versions. Suppose you
1002use a hypothetical group keyword @code{:super-pretty-print}, available
1003in some future Emacs version, like this in your Lisp package
1004@file{well-doc.el}:
1005
1006@smallexample
1007@group
1008(define-short-documentation-group well-doc
1009 (well-doc-foo
1010 :eval (well-doc-foo)
1011 :super-pretty-print t))
1012@end group
1013@end smallexample
1014
1015That future Emacs version will then supposedly super-pretty-print the
1016example for function @code{well-doc-foo}. Older Emacs versions will
1017silently ignore keyword @code{:super-pretty-print} and show the example
1018according to their regular display rules.
1019@end itemize
1020
937@node Comment Tips 1021@node Comment Tips
938@section Tips on Writing Comments 1022@section Tips on Writing Comments
939@cindex comments, Lisp convention for 1023@cindex comments, Lisp convention for