summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-03-29 14:08:34 +0000
committerGerd Moellmann <gerd@gnu.org>2001-03-29 14:08:34 +0000
commitf65fab598e808cec9a3ed5b8be01368ea8e38864 (patch)
tree37f4f5bd737af78ae5032978d60c6dec5e64fa1f /lisp/subr.el
parentcc515226efa8cc9c7827bf3edb940325ee2b13ec (diff)
downloademacs-f65fab598e808cec9a3ed5b8be01368ea8e38864.tar.gz
(interactive-form): New function.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el40
1 files changed, 21 insertions, 19 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index eb55b416a92..eb476c65753 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1449,25 +1449,27 @@ configuration."
(eq (car-safe object) 'lambda)
(and (symbolp object) (fboundp object))))
-;; now in fns.c
-;(defun nth (n list)
-; "Returns the Nth element of LIST.
-;N counts from zero. If LIST is not that long, nil is returned."
-; (car (nthcdr n list)))
-;
-;(defun copy-alist (alist)
-; "Return a copy of ALIST.
-;This is a new alist which represents the same mapping
-;from objects to objects, but does not share the alist structure with ALIST.
-;The objects mapped (cars and cdrs of elements of the alist)
-;are shared, however."
-; (setq alist (copy-sequence alist))
-; (let ((tail alist))
-; (while tail
-; (if (consp (car tail))
-; (setcar tail (cons (car (car tail)) (cdr (car tail)))))
-; (setq tail (cdr tail))))
-; alist)
+(defun interactive-form (function)
+ "Return the interactive form of FUNCTION.
+If function is a command (see `commandp'), value is a list of the form
+\(interactive SPEC). If function is not a command,return nil."
+ (setq function (indirect-function function))
+ (when (commandp function)
+ (cond ((byte-code-function-p function)
+ (when (> (length function) 5)
+ (let ((spec (aref function 5)))
+ (if spec
+ (list 'interactive spec)
+ (list 'interactive)))))
+ ((subrp function)
+ (subr-interactive-form function))
+ ((eq (car-safe function) 'lambda)
+ (setq function (cddr function))
+ (when (stringp (car function))
+ (setq function (cdr function)))
+ (let ((form (car function)))
+ (when (eq (car-safe form 'interactive))
+ (copy-sequence form)))))))
(defun assq-delete-all (key alist)
"Delete from ALIST all elements whose car is KEY.