aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-03-22 15:36:29 -0700
committerGlenn Morris2014-03-22 15:36:29 -0700
commitf9c81e7b487ec0c7e9ff1dbd5f1959cba4433f4c (patch)
treed495c678a854371767390e62d40e3f178435c0f0
parent5076d275135c9cbcf1f57182b6294e83b6fd4785 (diff)
downloademacs-f9c81e7b487ec0c7e9ff1dbd5f1959cba4433f4c.tar.gz
emacs-f9c81e7b487ec0c7e9ff1dbd5f1959cba4433f4c.zip
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.
-rw-r--r--doc/lispref/ChangeLog3
-rw-r--r--doc/lispref/commands.texi13
-rw-r--r--etc/NEWS1
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/bookmark.el4
-rw-r--r--lisp/epa-mail.el20
-rw-r--r--lisp/epa.el6
-rw-r--r--lisp/files.el1
-rw-r--r--lisp/help-fns.el27
-rw-r--r--lisp/simple.el28
10 files changed, 73 insertions, 44 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index becce3eea60..870d2dd5d37 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,8 @@
12014-03-22 Glenn Morris <rgm@gnu.org> 12014-03-22 Glenn Morris <rgm@gnu.org>
2 2
3 * commands.texi (Defining Commands):
4 Mention that interactive-only also affects describe-function.
5
3 * functions.texi (Declare Form): Add interactive-only. 6 * functions.texi (Declare Form): Add interactive-only.
4 * commands.texi (Defining Commands) Mention declare. 7 * commands.texi (Defining Commands) Mention declare.
5 8
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 2b1423101a7..721a485382e 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -128,12 +128,13 @@ form in the function body itself. This feature is seldom used.
128never directly from Lisp. In that case, give the function a 128never directly from Lisp. In that case, give the function a
129non-@code{nil} @code{interactive-only} property, either directly 129non-@code{nil} @code{interactive-only} property, either directly
130or via @code{declare} (@pxref{Declare Form}). This causes the 130or via @code{declare} (@pxref{Declare Form}). This causes the
131byte compiler to warn if the command is called from Lisp. The value 131byte compiler to warn if the command is called from Lisp. The output
132of the property can be: a string, which the byte-compiler will 132of @code{describe-function} will include similar information.
133use directly in its warning (it should end with a period, 133The value of the property can be: a string, which the byte-compiler
134and not start with a capital, e.g. ``use @dots{} instead.''); @code{t}; 134will use directly in its warning (it should end with a period, and not
135any other symbol, which should be an alternative function to use in 135start with a capital, e.g. ``use @dots{} instead.''); @code{t}; any
136Lisp code. 136other symbol, which should be an alternative function to use in Lisp
137code.
137 138
138@menu 139@menu
139* Using Interactive:: General rules for @code{interactive}. 140* Using Interactive:: General rules for @code{interactive}.
diff --git a/etc/NEWS b/etc/NEWS
index d01fde1c697..b0a19726936 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -54,6 +54,7 @@ to delete or undelete multiple messages.
54 54
55+++ 55+++
56** You can specify a function's interactive-only property via `declare'. 56** You can specify a function's interactive-only property via `declare'.
57However you specify it, the property affects `describe-function' output.
57 58
58 59
59* Changes in Emacs 24.5 on Non-Free Operating Systems 60* Changes in Emacs 24.5 on Non-Free Operating Systems
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0854e9d3e57..554f1df5884 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,19 @@
12014-03-22 Glenn Morris <rgm@gnu.org> 12014-03-22 Glenn Morris <rgm@gnu.org>
2 2
3 * help-fns.el (help-fns--interactive-only): New function.
4 (help-fns-describe-function-functions): Add the above function.
5 * simple.el (beginning-of-buffer, end-of-buffer, insert-buffer)
6 (next-line, previous-line): Remove hand-written interactive-only
7 information from doc strings, it is auto-generated now.
8 * bookmark.el (bookmark-write):
9 * epa-mail.el (epa-mail-decrypt, epa-mail-verify, epa-mail-sign)
10 (epa-mail-import-keys): Mark interactive-only,
11 and remove hand-written interactive-only information from doc strings.
12 * epa.el (epa-decrypt-armor-in-region, epa-verify-region)
13 (epa-verify-cleartext-in-region, epa-sign-region, epa-encrypt-region):
14 * files.el (not-modified):
15 * simple.el (mark-whole-buffer): Mark interactive-only.
16
3 * emacs-lisp/byte-run.el (defun-declarations-alist): 17 * emacs-lisp/byte-run.el (defun-declarations-alist):
4 Add interactive-only. Doc tweak. 18 Add interactive-only. Doc tweak.
5 (macro-declarations-alist): Doc tweak. 19 (macro-declarations-alist): Doc tweak.
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 5307cada0ac..e4e4ed9afcb 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1298,8 +1298,8 @@ is greater than `bookmark-alist-modification-count'."
1298 1298
1299;;;###autoload 1299;;;###autoload
1300(defun bookmark-write () 1300(defun bookmark-write ()
1301 "Write bookmarks to a file (reading the file name with the minibuffer). 1301 "Write bookmarks to a file (reading the file name with the minibuffer)."
1302Don't use this in Lisp programs; use `bookmark-save' instead." 1302 (declare (interactive-only bookmark-save))
1303 (interactive) 1303 (interactive)
1304 (bookmark-maybe-load-default-file) 1304 (bookmark-maybe-load-default-file)
1305 (bookmark-save t)) 1305 (bookmark-save t))
diff --git a/lisp/epa-mail.el b/lisp/epa-mail.el
index 9a096a0a709..d1ed679c0f1 100644
--- a/lisp/epa-mail.el
+++ b/lisp/epa-mail.el
@@ -70,27 +70,24 @@ USAGE would be `sign' or `encrypt'."
70;;;###autoload 70;;;###autoload
71(defun epa-mail-decrypt () 71(defun epa-mail-decrypt ()
72 "Decrypt OpenPGP armors in the current buffer. 72 "Decrypt OpenPGP armors in the current buffer.
73The buffer is expected to contain a mail message. 73The buffer is expected to contain a mail message."
74 74 (declare (interactive-only t))
75Don't use this command in Lisp programs!"
76 (interactive) 75 (interactive)
77 (epa-decrypt-armor-in-region (point-min) (point-max))) 76 (epa-decrypt-armor-in-region (point-min) (point-max)))
78 77
79;;;###autoload 78;;;###autoload
80(defun epa-mail-verify () 79(defun epa-mail-verify ()
81 "Verify OpenPGP cleartext signed messages in the current buffer. 80 "Verify OpenPGP cleartext signed messages in the current buffer.
82The buffer is expected to contain a mail message. 81The buffer is expected to contain a mail message."
83 82 (declare (interactive-only t))
84Don't use this command in Lisp programs!"
85 (interactive) 83 (interactive)
86 (epa-verify-cleartext-in-region (point-min) (point-max))) 84 (epa-verify-cleartext-in-region (point-min) (point-max)))
87 85
88;;;###autoload 86;;;###autoload
89(defun epa-mail-sign (start end signers mode) 87(defun epa-mail-sign (start end signers mode)
90 "Sign the current buffer. 88 "Sign the current buffer.
91The buffer is expected to contain a mail message. 89The buffer is expected to contain a mail message."
92 90 (declare (interactive-only t))
93Don't use this command in Lisp programs!"
94 (interactive 91 (interactive
95 (save-excursion 92 (save-excursion
96 (goto-char (point-min)) 93 (goto-char (point-min))
@@ -234,9 +231,8 @@ If no one is selected, symmetric encryption will be performed. "
234;;;###autoload 231;;;###autoload
235(defun epa-mail-import-keys () 232(defun epa-mail-import-keys ()
236 "Import keys in the OpenPGP armor format in the current buffer. 233 "Import keys in the OpenPGP armor format in the current buffer.
237The buffer is expected to contain a mail message. 234The buffer is expected to contain a mail message."
238 235 (declare (interactive-only t))
239Don't use this command in Lisp programs!"
240 (interactive) 236 (interactive)
241 (epa-import-armor-in-region (point-min) (point-max))) 237 (epa-import-armor-in-region (point-min) (point-max)))
242 238
diff --git a/lisp/epa.el b/lisp/epa.el
index be439ef241d..0c833ab84d6 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -834,6 +834,7 @@ For example:
834 834
835Don't use this command in Lisp programs! 835Don't use this command in Lisp programs!
836See the reason described in the `epa-decrypt-region' documentation." 836See the reason described in the `epa-decrypt-region' documentation."
837 (declare (interactive-only t))
837 (interactive "r") 838 (interactive "r")
838 (save-excursion 839 (save-excursion
839 (save-restriction 840 (save-restriction
@@ -873,6 +874,7 @@ For example:
873 (decode-coding-string 874 (decode-coding-string
874 (epg-verify-string context (buffer-substring start end)) 875 (epg-verify-string context (buffer-substring start end))
875 'utf-8))" 876 'utf-8))"
877 (declare (interactive-only t))
876 (interactive "r") 878 (interactive "r")
877 (let ((context (epg-make-context epa-protocol)) 879 (let ((context (epg-make-context epa-protocol))
878 plain) 880 plain)
@@ -914,6 +916,7 @@ between START and END.
914 916
915Don't use this command in Lisp programs! 917Don't use this command in Lisp programs!
916See the reason described in the `epa-verify-region' documentation." 918See the reason described in the `epa-verify-region' documentation."
919 (declare (interactive-only t))
917 (interactive "r") 920 (interactive "r")
918 (save-excursion 921 (save-excursion
919 (save-restriction 922 (save-restriction
@@ -956,6 +959,7 @@ For example:
956 (epg-sign-string 959 (epg-sign-string
957 context 960 context
958 (encode-coding-string (buffer-substring start end) 'utf-8)))" 961 (encode-coding-string (buffer-substring start end) 'utf-8)))"
962 (declare (interactive-only t))
959 (interactive 963 (interactive
960 (let ((verbose current-prefix-arg)) 964 (let ((verbose current-prefix-arg))
961 (setq epa-last-coding-system-specified 965 (setq epa-last-coding-system-specified
@@ -1037,6 +1041,7 @@ For example:
1037 context 1041 context
1038 (encode-coding-string (buffer-substring start end) 'utf-8) 1042 (encode-coding-string (buffer-substring start end) 'utf-8)
1039 nil))" 1043 nil))"
1044 (declare (interactive-only t))
1040 (interactive 1045 (interactive
1041 (let ((verbose current-prefix-arg) 1046 (let ((verbose current-prefix-arg)
1042 (context (epg-make-context epa-protocol)) 1047 (context (epg-make-context epa-protocol))
@@ -1205,6 +1210,7 @@ If no one is selected, default public key is exported. ")))
1205;; If a prefix-arg is specified, the signature is marked as non exportable. 1210;; If a prefix-arg is specified, the signature is marked as non exportable.
1206 1211
1207;; Don't use this command in Lisp programs!" 1212;; Don't use this command in Lisp programs!"
1213;; (declare (interactive-only t))
1208;; (interactive 1214;; (interactive
1209;; (let ((keys (epa--marked-keys))) 1215;; (let ((keys (epa--marked-keys)))
1210;; (unless keys 1216;; (unless keys
diff --git a/lisp/files.el b/lisp/files.el
index 0bb670bf384..a17677b564d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4999,6 +4999,7 @@ With prefix ARG, mark buffer as modified, so \\[save-buffer] will save.
4999 4999
5000It is not a good idea to use this function in Lisp programs, because it 5000It is not a good idea to use this function in Lisp programs, because it
5001prints a message in the minibuffer. Instead, use `set-buffer-modified-p'." 5001prints a message in the minibuffer. Instead, use `set-buffer-modified-p'."
5002 (declare (interactive-only set-buffer-modified-p))
5002 (interactive "P") 5003 (interactive "P")
5003 (message (if arg "Modification-flag set" 5004 (message (if arg "Modification-flag set"
5004 "Modification-flag cleared")) 5005 "Modification-flag cleared"))
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 @@
1;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*- 1;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1985-1986, 1993-1994, 1998-2014 Free Software 3;; Copyright (C) 1985-1986, 1993-1994, 1998-2014
4;; Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Maintainer: emacs-devel@gnu.org 6;; Maintainer: emacs-devel@gnu.org
7;; Keywords: help, internal 7;; Keywords: help, internal
@@ -430,6 +430,28 @@ FILE is the file where FUNCTION was probably defined."
430 (setq load-hist (cdr load-hist))) 430 (setq load-hist (cdr load-hist)))
431 found)) 431 found))
432 432
433(defun help-fns--interactive-only (function)
434 "Insert some help blurb if FUNCTION should only be used interactively."
435 ;; Ignore lambda constructs, keyboard macros, etc.
436 (and (symbolp function)
437 (not (eq (car-safe (symbol-function function)) 'macro))
438 (let* ((interactive-only
439 (or (get function 'interactive-only)
440 (if (boundp 'byte-compile-interactive-only-functions)
441 (memq function
442 byte-compile-interactive-only-functions)))))
443 (when interactive-only
444 (insert "\nThis function is for interactive use only"
445 ;; Cf byte-compile-form.
446 (cond ((stringp interactive-only)
447 (format ";\nin Lisp code %s" interactive-only))
448 ((and (symbolp 'interactive-only)
449 (not (eq interactive-only t)))
450 (format ";\nin Lisp code use `%s' instead."
451 interactive-only))
452 (t "."))
453 "\n")))))
454
433;;;###autoload 455;;;###autoload
434(defun describe-function-1 (function) 456(defun describe-function-1 (function)
435 (let* ((advised (and (symbolp function) 457 (let* ((advised (and (symbolp function)
@@ -554,6 +576,7 @@ FILE is the file where FUNCTION was probably defined."
554 576
555;; Add defaults to `help-fns-describe-function-functions'. 577;; Add defaults to `help-fns-describe-function-functions'.
556(add-hook 'help-fns-describe-function-functions #'help-fns--obsolete) 578(add-hook 'help-fns-describe-function-functions #'help-fns--obsolete)
579(add-hook 'help-fns-describe-function-functions #'help-fns--interactive-only)
557(add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode) 580(add-hook 'help-fns-describe-function-functions #'help-fns--parent-mode)
558(add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro) 581(add-hook 'help-fns-describe-function-functions #'help-fns--compiler-macro)
559 582
diff --git a/lisp/simple.el b/lisp/simple.el
index a41133bada2..453259475f6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -870,10 +870,7 @@ If the buffer is narrowed, this command uses the beginning of the
870accessible part of the buffer. 870accessible part of the buffer.
871 871
872If Transient Mark mode is disabled, leave mark at previous 872If Transient Mark mode is disabled, leave mark at previous
873position, unless a \\[universal-argument] prefix is supplied. 873position, unless a \\[universal-argument] prefix is supplied."
874
875Don't use this command in Lisp programs!
876\(goto-char (point-min)) is faster."
877 (declare (interactive-only "use `(goto-char (point-min))' instead.")) 874 (declare (interactive-only "use `(goto-char (point-min))' instead."))
878 (interactive "^P") 875 (interactive "^P")
879 (or (consp arg) 876 (or (consp arg)
@@ -897,10 +894,7 @@ If the buffer is narrowed, this command uses the end of the
897accessible part of the buffer. 894accessible part of the buffer.
898 895
899If Transient Mark mode is disabled, leave mark at previous 896If Transient Mark mode is disabled, leave mark at previous
900position, unless a \\[universal-argument] prefix is supplied. 897position, unless a \\[universal-argument] prefix is supplied."
901
902Don't use this command in Lisp programs!
903\(goto-char (point-max)) is faster."
904 (declare (interactive-only "use `(goto-char (point-max))' instead.")) 898 (declare (interactive-only "use `(goto-char (point-max))' instead."))
905 (interactive "^P") 899 (interactive "^P")
906 (or (consp arg) (region-active-p) (push-mark)) 900 (or (consp arg) (region-active-p) (push-mark))
@@ -1016,6 +1010,7 @@ If narrowing is in effect, only uses the accessible part of the buffer.
1016You probably should not use this function in Lisp programs; 1010You probably should not use this function in Lisp programs;
1017it is usually a mistake for a Lisp function to use any subroutine 1011it is usually a mistake for a Lisp function to use any subroutine
1018that uses or sets the mark." 1012that uses or sets the mark."
1013 (declare (interactive-only t))
1019 (interactive) 1014 (interactive)
1020 (push-mark (point)) 1015 (push-mark (point))
1021 (push-mark (point-max) nil t) 1016 (push-mark (point-max) nil t)
@@ -4240,10 +4235,7 @@ If ARG is zero, move to the beginning of the current line."
4240(defun insert-buffer (buffer) 4235(defun insert-buffer (buffer)
4241 "Insert after point the contents of BUFFER. 4236 "Insert after point the contents of BUFFER.
4242Puts mark after the inserted text. 4237Puts mark after the inserted text.
4243BUFFER may be a buffer or a buffer name. 4238BUFFER may be a buffer or a buffer name."
4244
4245This function is meant for the user to run interactively.
4246Don't call it from programs: use `insert-buffer-substring' instead!"
4247 (declare (interactive-only insert-buffer-substring)) 4239 (declare (interactive-only insert-buffer-substring))
4248 (interactive 4240 (interactive
4249 (list 4241 (list
@@ -4841,11 +4833,7 @@ this command moves to the specified goal column (or as close as possible).
4841The goal column is stored in the variable `goal-column', which is nil 4833The goal column is stored in the variable `goal-column', which is nil
4842when there is no goal column. Note that setting `goal-column' 4834when there is no goal column. Note that setting `goal-column'
4843overrides `line-move-visual' and causes this command to move by buffer 4835overrides `line-move-visual' and causes this command to move by buffer
4844lines rather than by display lines. 4836lines rather than by display lines."
4845
4846If you are thinking of using this in a Lisp program, consider
4847using `forward-line' instead. It is usually easier to use
4848and more reliable (no dependence on goal column, etc.)."
4849 (declare (interactive-only forward-line)) 4837 (declare (interactive-only forward-line))
4850 (interactive "^p\np") 4838 (interactive "^p\np")
4851 (or arg (setq arg 1)) 4839 (or arg (setq arg 1))
@@ -4888,11 +4876,7 @@ this command moves to the specified goal column (or as close as possible).
4888The goal column is stored in the variable `goal-column', which is nil 4876The goal column is stored in the variable `goal-column', which is nil
4889when there is no goal column. Note that setting `goal-column' 4877when there is no goal column. Note that setting `goal-column'
4890overrides `line-move-visual' and causes this command to move by buffer 4878overrides `line-move-visual' and causes this command to move by buffer
4891lines rather than by display lines. 4879lines rather than by display lines."
4892
4893If you are thinking of using this in a Lisp program, consider using
4894`forward-line' with a negative argument instead. It is usually easier
4895to use and more reliable (no dependence on goal column, etc.)."
4896 (declare (interactive-only 4880 (declare (interactive-only
4897 "use `forward-line' with negative argument instead.")) 4881 "use `forward-line' with negative argument instead."))
4898 (interactive "^p\np") 4882 (interactive "^p\np")