0

One of my docstrings has became quite long and would like to write a shorter one, and append additional ones after it.

Have thought of linking with a defconst as below.

(defconst mycons-args "Here is further information about this and that." "Documentation of mycons arguments.") (defun mycons () "Generic launcher/dispatcher that executes zero-argument functions (ARMG-ZMAP, GO-ZMAP) which can be passed as function objects or lambdas, according to the symbols in the list ACTM-SEQR. For further information see `mycons-args'" 

But this includes the text

mycons-args a variable defined in ‘mycons.el’. Its value is shown below. Documentation of mycons arguments. This variable may be risky if used as a file-local variable. Value: "Here is further information about this and that." 

Is there a way to avoid the extra variable metadata at the start? Are there any alternatives to add to the documentation string, as I would like to avoid very long ones before the implementation code starts.

1 Answer 1

3

A different approach is modifying the function-documentation property of the function. You can concatenate the short value in the definition with a longer string with the supplementary information, see the manual for details.

(defun mycons () "Generic launcher/dispatcher that executes zero-argument functions (ARMG-ZMAP, GO-ZMAP) which can be passed as function objects or lambdas, according to the symbols in the list ACTM-SEQR. " (message "Here should go the implementation")) (put 'mycons 'function-documentation (concat (documentation (symbol-function 'mycons) 'raw) "Here is further information about this and that.")) 

The result includes all the documentation, so the user does not need to follow a link to access the supplementary information.

mycons is a interpreted-function. (mycons) Generic launcher/dispatcher that executes zero-argument functions (ARMG-ZMAP, GO-ZMAP) which can be passed as function objects or lambdas, according to the symbols in the list ACTM-SEQR. Here is further information about this and that. 

Keep in mind that long docstrings are fairly common in Emacs, see for example file-remote-p, this makes the same information available in the help buffer and when editing the implementation.

1
  • I could also make a defun and return nil. Then I can link to its documentation. Commented Aug 6 at 4:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.