Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [doc-strings]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
14 votes
1 answer
2k views

How to retrieve docstrings from functions and variables?

I'm trying to write a function that will retrieve the docstrings from any sexps in a file that match (def.*). I'd want to both be able to retrieve any functions/macros, as well as any variables ...
Jonathan Leech-Pepin's user avatar
12 votes
2 answers
960 views

Is it possible to attach generated doc string to a lambda?

Emacs docs say that when doc string is put inside of lambda or defun it's “stored directly in the function object”. However, we can change docs of named functions like this: (put 'my-function-name '...
Mark Karpov's user avatar
  • 4,963
12 votes
4 answers
10k views

Library for automatically inserting python docstring in Google style

I'm looking for an elisp package that automatically inserts Python docstring for a method. I found a package, which is very close to my purpose. But it's in reStructured text, not in Google style. ...
sy2's user avatar
  • 123
11 votes
4 answers
3k views

Is there a better way to handle multiline docstrings in elisp?

I hate the way that elisp (not sure if LISP in general) handles multiline docstrings. (defun foo () "This is a multi liner docstring" (do-stuff)) I sure do wish that I could do something like (...
Krazy Glew's user avatar
5 votes
2 answers
254 views

Change doc string summary of a function on the fly

Is it possible to change the first line of a docstring of a function, without editing the source code of this function? And if, how can I do this? Background: some packages come with a pretty useless ...
jue's user avatar
  • 4,576
5 votes
1 answer
333 views

What is \= in doc strings?

Bleeding edge Emacs is starting to complain about certain uses of ' in doc strings. I am trying to resolve these. As a typical example, in a doc string I might include an example: (defun my-mode-...
Greg Hendershott's user avatar
5 votes
1 answer
852 views

display eldoc help info behind point

I have the following code to replace default eldoc display function: (defun my-eldoc-display-message-momentary (format-string &rest args) "Display eldoc message near point." (when format-...
stardiviner's user avatar
  • 1,938
4 votes
1 answer
703 views

What is the logic behind the weird lisp docstring (left) indentation?

Why is the third line in this code indented "too much" to the left? It feels "off" to me. (defun hello-world nil "Greet the world. This function implements the canonical example program." (...
american-ninja-warrior's user avatar
4 votes
2 answers
2k views

Emacs 29 docstring single quote escaping rules, compiler level event?

I've seen the following warning from the Emacs 29 compiler: In s-format: s.el:614:2: Warning: docstring has wrong usage of unescaped single quotes (use \= or different quoting) I haven't been ...
ocodo's user avatar
  • 1,222
4 votes
2 answers
309 views

Disabling quote conversion in docstrings

(defun foo () "`bar'") The ASCII quotes in this docstring are displayed as typographical quotes by describe-function. Is it possible to have them displayed in their original form?
Toothrot's user avatar
  • 3,264
4 votes
2 answers
104 views

How can I record where a function is defined if it's done indirectly?

I've got a few functions in api-wrap.el that I'll refer to as 'macro code', here simplified to clarify the question: function (generate-form prefix kind &rest args) returns an unevaluated form ...
Sean Allred's user avatar
  • 6,941
4 votes
0 answers
120 views

"helm-documentation"? (search docstrings like apropos-documentation but with helm)

I just started using helm-apropos. It's great! Is there a helm equivalent for apropos-documentation or alternatively does helm-apropos have sources already available to narrow over docstrings?
ebpa's user avatar
  • 7,499
3 votes
1 answer
60 views

Documenting keyboard macros Can I have a doc string for fset the same way as defun

I often create and save elaborate keyboard macros that I wish to use later, and hope to be prompted for the proper context to use them. I note that if I manually write a function to use as a command ...
Chip Grandits's user avatar
3 votes
1 answer
203 views

FORM vs BODY in documentation?

Recently I was trapped by void-variable error on eval-after-load. That is not first time I forget to quote args like: (eval-after-load 'sql '(progn ...)) because eval-after-load docs say: ...
gavenkoa's user avatar
  • 3,452
3 votes
2 answers
125 views

How do I disambiguate mentions of a minor mode in a docstring?

The docstring of the following function doesn't make Emacs happy: (defun foo-all-the-bars () "Foo all the bars. Starts by fooing some bars by enabling `prettify-symbols-mode', then manually foos ...
Clément's user avatar
  • 3,995
3 votes
2 answers
2k views

How can I disable indentation rules within docstrings in python-mode?

When writing within docstrings in python-mode, I'm only able to tab/indent deeper than the leading edge of the string. For example: def foo(): """ | | << the only places I can "tab" to. ...
Phill Oldham's user avatar
2 votes
2 answers
232 views

Evaluate docstring in macros

Macros like defun (or defmacro itself) have an optional docstring argument, but since they are macros and not functions, docstring isn't evaluated, but is taken as-is. I need the docstring to be ...
nomad's user avatar
  • 257
2 votes
1 answer
71 views

Lisp Mode Documentation Syntax color change?

I use emacs for common lisp development. I noticed that the documentation string for functions is white and makes it hard for me to read. Is there a way for me to change the color of this string? ...
Vinn's user avatar
  • 293
2 votes
1 answer
42 views

Adding docstring outside function declaration

I have an emacs function with a long docstring. Could I make the docstring separate from the function, adding it before or after the function declaration? And is it possible to append to a docstring ...
Dilna's user avatar
  • 1
2 votes
1 answer
36 views

Minor Mode / Description

I'm using a minor mode for my key bindings. But I want to set the documentation string dynamically. Instead of: (define-minor-mode mesys-mode "Text" ...) I want something like ...
chris-tian's user avatar
2 votes
1 answer
130 views

(Company) Doc Buffer ignoring scroll-other-window

I'm trying to write my own backend for a certain tool language that has no repl. Hence, I thought it would be the best idea to parse the documentation and store it as a hash table (I'm open to other ...
knusprjg's user avatar
2 votes
1 answer
1k views

`which-key` or similar, to show doc strings of commands bound to keys?

which-key package is very useful to show the list of command names. Could it (or any other package) also show the doc string of those commands?
AhLeung's user avatar
  • 1,083
2 votes
0 answers
208 views

Optional docstring in defun

After taking a look at the definition of defun in byte-run.el, it seems that the macro does some very interesting things regarding checking for the existence of a docstring. First, it uses a declare ...
Tianxiang Xiong's user avatar
1 vote
1 answer
184 views

\\{ in a doc string: what does it mean/do?

What does this backslash syntax mean? (defun elfeed-search-mode () "Major mode for listing elfeed feed entries. \\{elfeed-search-mode-map}" (interactive)
american-ninja-warrior's user avatar
1 vote
1 answer
222 views

How to evaluate a defun with square brackets in column 0 of its docstring?

I have problems running eval-defun for a defun when there is a square bracket [ in column 0 of its doc string. For example: (defun test () "Test function. [Some text]" (message "Hello")) When I ...
Håkon Hægland's user avatar
1 vote
0 answers
74 views

auto intendation on newline doesn't stay at same indentation for python docstring

Ubuntu 19.10 emacs 26.3 from system repos I do use elpy and evil-mode In general when I am editing python code, indentation works just fine. However, when I am editing doc-strings, when I type enter ...
Vince W.'s user avatar
  • 415
1 vote
0 answers
92 views

Is there an existing function to add docstrings, relevant to the current major mode?

In emacs is there a function that I can invoke to add a docstring template based on the current major mode? eg: If I'm working on javascript, insert a javascript docstring template "here", like: /*...
pwalsh's user avatar
  • 245
0 votes
1 answer
145 views

Docstring - quotes or semicolons?

In the documentation I only see mention of using semicolons for comments and docstrings, but in elisp-documents I regularly see functions documented in double-quotes, such as in org.el: (defun org-...
xeruf's user avatar
  • 354
0 votes
1 answer
41 views

Appending to function documentation

Can one append to a function documentation by calling some function or string in the documentation part? With the following I do not get anything from get. (defun myfunc "Brief description&...
Dilna's user avatar
  • 1
0 votes
1 answer
191 views

python-docstring-fill does not align properly

I am using python-docstring-fill (function of https://github.com/glyph/python-docstring-mode) to wrap Python docstrings. I observe that it does not align based the Python-way. It should be as: "&...
alper's user avatar
  • 1,390
0 votes
1 answer
389 views

How can I define the syntax of a C-defined function with with module_make_function?

I've tried #define DEFUN(lsym, csym, amin, amax, doc, data) \ bind_function (env, lsym, env->make_function(env, amin, amax, csym, doc, data)) DEFUN("libgit2-core-status", Flibgit2_status, 1, 1, ...
Sean Allred's user avatar
  • 6,941
0 votes
0 answers
39 views

fill-paragraph for Google style docstrings

When editing an existing docstring in Google style you need to call a function like fill-paragraph to cut the long lines while preserving the proper indentation. However fill-paragraph will not work ...
olivaw's user avatar
  • 151
0 votes
0 answers
16 views

Non-filling of lines and paragraphs when using docstrings

I am having a problem with docstrings because everything is written as verbatim without paragraph or line filling. The following for instance puts Malicious and Functionalities on two separate lines. ...
Dilna's user avatar
  • 1
0 votes
0 answers
19 views

put function-documentation fails inside own function

How is it that (put 'workbench 'function-documentation does not work inside (defun workbench? (setq workbench-usage "Usage Information.") (defun workbench (&optional prefix name mode) ...
Dilna's user avatar
  • 1