summaryrefslogtreecommitdiff
path: root/lisp/help-fns.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2014-03-22 15:36:29 -0700
committerGlenn Morris <rgm@gnu.org>2014-03-22 15:36:29 -0700
commitf9c81e7b487ec0c7e9ff1dbd5f1959cba4433f4c (patch)
treed495c678a854371767390e62d40e3f178435c0f0 /lisp/help-fns.el
parent5076d275135c9cbcf1f57182b6294e83b6fd4785 (diff)
downloademacs-f9c81e7b487ec0c7e9ff1dbd5f1959cba4433f4c.tar.gz
Include interactive-only information in describe-function output
* lisp/help-fns.el (help-fns--interactive-only): New function. (help-fns-describe-function-functions): Add the above function. * lisp/simple.el (beginning-of-buffer, end-of-buffer, insert-buffer) (next-line, previous-line): Remove hand-written interactive-only information from doc strings, it is auto-generated now. * lisp/bookmark.el (bookmark-write): * lisp/epa-mail.el (epa-mail-decrypt, epa-mail-verify, epa-mail-sign) (epa-mail-import-keys): Mark interactive-only, and remove hand-written interactive-only information from doc strings. * lisp/epa.el (epa-decrypt-armor-in-region, epa-verify-region) (epa-verify-cleartext-in-region, epa-sign-region, epa-encrypt-region): * lisp/files.el (not-modified): * lisp/simple.el (mark-whole-buffer): Mark interactive-only. * doc/lispref/commands.texi (Defining Commands): Mention that interactive-only also affects describe-function. * etc/NEWS: Mention this.
Diffstat (limited to 'lisp/help-fns.el')
-rw-r--r--lisp/help-fns.el27
1 files changed, 25 insertions, 2 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a186254123d..da4a230468c 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1,7 +1,7 @@
;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*-
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2014 Free Software
-;; Foundation, Inc.
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2014
+;; Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: help, internal
@@ -430,6 +430,28 @@ FILE is the file where FUNCTION was probably defined."
(setq load-hist (cdr load-hist)))
found))
+(defun help-fns--interactive-only (function)
+ "Insert some help blurb if FUNCTION should only be used interactively."
+ ;; Ignore lambda constructs, keyboard macros, etc.
+ (and (symbolp function)
+ (not (eq (car-safe (symbol-function function)) 'macro))
+ (let* ((interactive-only
+ (or (get function 'interactive-only)
+ (if (boundp 'byte-compile-interactive-only-functions)
+ (memq function
+ byte-compile-interactive-only-functions)))))
+ (when interactive-only
+ (insert "\nThis function is for interactive use only"
+ ;; Cf byte-compile-form.
+ (cond ((stringp interactive-only)
+ (format ";\nin Lisp code %s" interactive-only))
+ ((and (symbolp 'interactive-only)
+ (not (eq interactive-only t)))
+ (format ";\nin Lisp code use `%s' instead."
+ interactive-only))
+ (t "."))
+ "\n")))))
+
;;;###autoload
(defun describe-function-1 (function)
(let* ((advised (and (symbolp function)
@@ -554,6 +576,7 @@ FILE is the file where FUNCTION was probably defined."
;; Add defaults to `help-fns-describe-function-functions'.
(add-hook 'help-fns-describe-function-functions #'help-fns--obsolete)
+(add-hook 'help-fns-describe-function-functions #'help-fns--interactive-only)
(add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode)
(add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro)