diff options
Diffstat (limited to 'doc/lispref/tips.texi')
| -rw-r--r-- | doc/lispref/tips.texi | 84 |
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 | |||
| 934 | versions, there is no need for this work-around. | 935 | versions, 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 | ||
| 945 | functions of Lisp packages based on various groupings | ||
| 946 | (@pxref{Documentation Groups}). This section gives some tips on how you | ||
| 947 | can define documentation groups in your Lisp package in a way such that | ||
| 948 | users of different Emacs versions can equally well use these groups. | ||
| 949 | |||
| 950 | @itemize @bullet | ||
| 951 | @item | ||
| 952 | To define documentation groups for your own Lisp package across | ||
| 953 | different Emacs versions, you can use a boilerplate template along the | ||
| 954 | lines of the following to make your package compile and load without | ||
| 955 | errors: | ||
| 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 | ||
| 992 | If you do not intend to support some of the Emacs versions mentioned | ||
| 993 | above, you can safely omit the corresponding forms from the template. | ||
| 994 | If you intend to support only Emacs 31 and newer, you do not need any | ||
| 995 | of the above and can just use @code{define-short-documentation-group}. | ||
| 996 | |||
| 997 | @item | ||
| 998 | @cindex documentation group keywords, compatibility | ||
| 999 | Newer Emacs versions might introduce newer documentation group features | ||
| 1000 | and keywords. However, these features or keywords will never break the | ||
| 1001 | display of a documentation group in older Emacs versions. Suppose you | ||
| 1002 | use a hypothetical group keyword @code{:super-pretty-print}, available | ||
| 1003 | in 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 | |||
| 1015 | That future Emacs version will then supposedly super-pretty-print the | ||
| 1016 | example for function @code{well-doc-foo}. Older Emacs versions will | ||
| 1017 | silently ignore keyword @code{:super-pretty-print} and show the example | ||
| 1018 | according 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 |