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)
"Change first line of doc string for SYMBOL to NEW-DESCRIPTION."
(put symbol 'function-documentation
(concat new-description
(let* ((doc (documentation symbol t))
(pos (cl-position ?\n doc)))
(and pos (substring doc pos))))))
;;; Usage example:
(unintern 'foo obarray)
(defun foo ()
"Greetings from function foo.
The real info often is on the second line:-(."
)
(change-description-line 'foo "New description of foo.")
Note that the symbol property function-documentation
overrides the documentation stored in the function object.
To restore the documentation from the function object you can use
(put 'foo 'function-documentation nil)
Alternatively, if you want to re-define foo
anyway you can just remove the symbol foo
from the global obarray:
(unintern 'foo obarray)