Next: , Previous: , Up: Documentation   [Contents][Index]

34.2 Access to Documentation Strings

Function: documentation-property symbol property &optional verbatim

This function returns the documentation string that is recorded in symbol’s property list under property property. It retrieves the text from a file if necessary, and runs substitute-command-keys to substitute actual key bindings. (This substitution is not done if verbatim is non-nil; the verbatim argument exists only as of Emacs 19.)

(documentation-property 'command-line-processed
     ⇒ "t once command line has been processed"
(symbol-plist 'command-line-processed)
     ⇒ (variable-documentation 188902)
Function: documentation function &optional verbatim

This function returns the documentation string of function. It reads the text from a file if necessary. Then (unless verbatim is non-nil) it calls substitute-command-keys, to return a value containing the actual (current) key bindings.

The function documentation signals a void-function error if function has no function definition. However, it is ok if the function definition has no documentation string. In that case, documentation returns nil.

Here is an example of using the two functions, documentation and documentation-property, to display the documentation strings for several symbols in a ‘*Help*’ buffer.

(defun describe-symbols (pattern)
  "Describe the SXEmacs Lisp symbols matching PATTERN.
All symbols that have PATTERN in their name are described
in the `*Help*' buffer."
  (interactive "sDescribe symbols matching: ")
  (let ((describe-func
          (lambda (s)
            ;; Print description of symbol.
            (if (fboundp s)             ; It is a function.
                 (format "%s\t%s\n%s\n\n" s
                   (if (commandp s)
                       (let ((keys (where-is-internal s)))
                         (if keys
                              "Keys: "
                              (mapconcat 'key-description
                                         keys " "))
                           "Keys: none"))
                   (or (documentation s)
                       "not documented"))))

            (if (boundp s)              ; It is a variable.
                 (format "%s\t%s\n%s\n\n" s
                   (if (user-variable-p s)
                       "Option " "Variable")
                   (or (documentation-property
                         s 'variable-documentation)
                       "not documented")))))))
    ;; Build a list of symbols that match pattern.
    (mapatoms (function
               (lambda (sym)
                 (if (string-match pattern (symbol-name sym))
                     (setq sym-list (cons sym sym-list))))))
    ;; Display the data.
    (with-output-to-temp-buffer "*Help*"
      (mapcar describe-func (sort sym-list 'string<))

The describe-symbols function works like apropos, but provides more information.

(describe-symbols "goal")

---------- Buffer: *Help* ----------
goal-column     Option
*Semipermanent goal column for vertical motion, as set by C-x C-n, or nil.
set-goal-column Command: C-x C-n
Set the current horizontal position as a goal for C-n and C-p.
Those commands will move to this position in the line moved to
rather than trying to keep the same horizontal position.
With a non-nil argument, clears out the goal column
so that C-n and C-p resume vertical motion.
The goal column is stored in the variable `goal-column'.
temporary-goal-column   Variable
Current goal column for vertical motion.
It is the column where point was
at the start of current run of vertical motion commands.
When the `track-eol' feature is doing its job, the value is 9999.
---------- Buffer: *Help* ----------
Function: Snarf-documentation filename

This function is used only during SXEmacs initialization, just before the runnable SXEmacs is dumped. It finds the file offsets of the documentation strings stored in the file filename, and records them in the in-core function definitions and variable property lists in place of the actual strings. See Building SXEmacs.

SXEmacs finds the file filename in the lib-src directory. When the dumped SXEmacs is later executed, the same file is found in the directory doc-directory. The usual value for filename is DOC, but this can be changed by modifying the variable internal-doc-file-name.

Variable: internal-doc-file-name

This variable holds the name of the file containing documentation strings of built-in symbols, usually DOC. The full pathname of the internal doc file is ‘(concat doc-directory internal-doc-file-name)’.

Variable: doc-directory

This variable holds the name of the directory which contains the internal doc file that contains documentation strings for built-in and preloaded functions and variables.

In most cases, this is the same as exec-directory. They may be different when you run SXEmacs from the directory where you built it, without actually installing it. See exec-directory in Help Functions.

In older Emacs versions, exec-directory was used for this.

Variable: data-directory

This variable holds the name of the directory in which SXEmacs finds certain system independent documentation and text files that come with SXEmacs. In older Emacs versions, exec-directory was used for this.

Next: , Previous: , Up: Documentation   [Contents][Index]