Well lambdas can have regular docstrings just like any other function definition:
"I'm a docstring!"
(+ foo bar))
So you could use:
(let ((foo 1)
,(format "Function which sums foo=%s and bar=%s" foo bar)
(+ foo bar)))
Why you want a docstring on an anonymous function is another question, which might ...
If the goal is to get information about functions and variables already in the environment:
For docstrings of functions and macros, see the documentation function.
For variable docstrings, use documentation-property; for example:
For function arity and the argument list, see this Emacs.SE ...
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G directly follows the double quote " there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation ...
I use the package called yasnippet for something similar to this. After some minor changes I adapted it to use the the Google docstring style instead:
Do note however that it requires some setup:
The snippet itself needs to execute some utility elisp code to generate the text. This is typically solved by creating a file called .yas-setup.el with the code ...
Of course a my-defun macro is the easy way out.
But a simpler solution would be
(advice-add 'eval-when-compile :filter-return
(if (and (eq 'quote (car-safe exp))
(stringp (cadr exp)))
Which should make your trick work, at least in all the ...
In addition to @Tobias's answer, refer to C-hig (elisp)Accessing Documentation
The other notable aspect of dynamic documentation via the function-documentation symbol property (amongst others), is that it can be generated on-demand.
If FUNCTION is a symbol, this function first looks for the
‘function-documentation’ property of that symbol; if that has ...
You can access the raw documentation string of a function foo with (documentation 'foo t).
You can set the documentation string of foo with
(put 'foo 'function-documentation "My new docstring.").
The following example shows you how you can exchange the first line of the documentation string:
(defun change-description-line (symbol new-description)
Basil's answer covers the needs of the end-user.
If you're writing elisp docstrings for other people, however, you (unfortunately) can't rely on everyone configuring text-quoting-style to grave, so when you need to ensure that quotes are not converted, you have to use an escaping syntax:
(defun foo ()
"Something about \\='foo")
Will ensure that, ...
(setq text-quoting-style 'grave)
and see the answer by phils.
Is it possible to have them displayed in their original form?
Yes, see (elisp) Text Quoting Style, specifically the description of the user option text-quoting-style:
text-quoting-style is a variable defined in ‘doc.c’.
Its value is nil
Probably introduced at or before Emacs ...
As with the comment, pos-tip-show works fine for me too.
I did hack together a better (but not perfect) version of the momentary-string-display version. I just rewrote the display function so that it deleted the overlay passively through a hook instead of waiting for an exit-char, which doesn't seem appropriate for what you are trying to do. The display ...
There are two issues here.
On the one hand, when a function is called, the arguments are evaluated first. But when you evaluate a macro, the arguments are not evaluated. Instead, they are used to expand the macro into a form, which is subsequently evaluated.
On the other hand, a form is just a single lisp object that is going to be evaluated, while a body ...
As lunaryorn mentioned that style is not popular and there aren't any packages.
However there is a package called sphinx-doc which will generate doc string in sphinx format(demo).
You can modify that package to generate strings as per your requirement.
I think, you can do one of two things:
Define your own type to search for via find-func.el. This is how it's done in ert.el (Search for current-load-list and find-function-regexp-alist.) But I don't think that this will work with help-mode buffers, i.e. no linkage.
Or extend find-function-regexp: Ordinarily this variable evaluates to a regexp to search ...
Is there any way I can advise python-mode to ignore indentation rules within docstrings?
Yes, in Emacs 25.1 or greater (before that python-indent-context didn't distinguish string from docstring). Indentation works by setting indent-line-function to a mode-specific value:
indent-line-function is a variable defined in ‘indent.el’.
Its value is ‘python-...
I finally figured out the culprit: company-quickhelp-mode was enabled in my setup which evidently triggered the doc-buffer all the time to reload. After disabling, everything works as expected. I'll try to solve this issue also with company-quickhelp and add my results here later.
If you use Icicles then you have key completion.
This is similar to which-key behavior, but there are differences.
You can use key completion anytime, whether you have already pressed a prefix key or not. To initiate key completion just hit S-TAB (or M-S-TAB if in the minibuffer) when you are not otherwise in the middle of completing something. (When you ...
AFAIU fixing this would require a hack around of SPECPDL_INDEX in C-source.
However, ar-backward-defun,ar-forward-defun jumps to start and end of a defun also in these cases: https://github.com/andreas-roehler/thingatpt-utils-core/blob/master/ar-subr.el
Wherefrom a command to escape opening parens in column 0 might be provided:
(defun ar-auto-escape ()
The use of (fn ARGS) syntax is described in (elisp) Function Documentation:
The last line of the documentation string can specify calling
conventions different from the actual function arguments. Write text
following a blank line, at the beginning of the line, with no newline
following it inside the documentation string. ...
One way to disambiguate:
(defun foo-all-the-bars ()
"Foo all the bars.
Starts by fooing some bars by enabling the command `prettify-symbols-mode',
then manually foos any remaining bars."
Instead of command, you can use function, variable, option, or symbol as the checkdoc string suggests. In any case, this is not a lisp ...