aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2012-07-25 21:27:33 -0400
committerStefan Monnier <[email protected]>2012-07-25 21:27:33 -0400
commit7abaf5ccc9f11e657b6671e7a6d5a7533bba5f31 (patch)
tree26a250aef4c762d2128fb99c7442d01cedbd208b /lisp/emacs-lisp
parentb1364986cb927ca113b0447a66a5274221ad9100 (diff)
Autoload more carefully from Lisp. Follow aliases for function properties.
* lisp/subr.el (autoloadp): New function. (symbol-file): Use it. (function-get): New function. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Use function-get and autoload-do-load. * lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-syntactic-face-function) (lisp-indent-function): * lisp/emacs-lisp/gv.el (gv-get): * lisp/emacs-lisp/edebug.el (get-edebug-spec, edebug-basic-spec): * lisp/emacs-lisp/byte-opt.el (byte-optimize-form): * lisp/emacs-lisp/bytecomp.el (byte-compile-arglist-warn): * lisp/emacs-lisp/autoload.el (make-autoload, autoload-print-form): Use function-get. * lisp/emacs-lisp/cl.el: Don't propagate function properties any more. * src/eval.c (Fautoload_do_load): Rename from do_autoload, export to Lisp, add argument, tune behavior, and adjust all callers. * lisp/speedbar.el (speedbar-add-localized-speedbar-support): * lisp/emacs-lisp/disass.el (disassemble-internal): * lisp/desktop.el (desktop-load-file): * lisp/help-fns.el (help-function-arglist, find-lisp-object-file-name) (describe-function-1): * lisp/emacs-lisp/find-func.el (find-function-noselect): * lisp/emacs-lisp/elp.el (elp-instrument-function): * lisp/emacs-lisp/advice.el (ad-has-proper-definition): * lisp/apropos.el (apropos-safe-documentation, apropos-macrop): * lisp/emacs-lisp/debug.el (debug-on-entry): * lisp/emacs-lisp/cl-macs.el (cl-compiler-macroexpand): * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): * lisp/calc/calc.el (name): Use autoloadp & autoload-do-load.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/advice.el2
-rw-r--r--lisp/emacs-lisp/autoload.el28
-rw-r--r--lisp/emacs-lisp/byte-opt.el13
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/emacs-lisp/cl-macs.el4
-rw-r--r--lisp/emacs-lisp/cl.el11
-rw-r--r--lisp/emacs-lisp/debug.el4
-rw-r--r--lisp/emacs-lisp/disass.el8
-rw-r--r--lisp/emacs-lisp/edebug.el13
-rw-r--r--lisp/emacs-lisp/elp.el2
-rw-r--r--lisp/emacs-lisp/find-func.el3
-rw-r--r--lisp/emacs-lisp/gv.el9
-rw-r--r--lisp/emacs-lisp/lisp-mode.el6
-rw-r--r--lisp/emacs-lisp/macroexp.el14
-rw-r--r--lisp/emacs-lisp/pcase.el3
15 files changed, 50 insertions, 72 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 09dde2c1c1..cac76d2bce 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -2542,7 +2542,7 @@ definition (see the code for `documentation')."
For that it has to be fbound with a non-autoload definition."
(and (symbolp function)
(fboundp function)
- (not (eq (car-safe (symbol-function function)) 'autoload))))
+ (not (autoloadp (symbol-function function)))))
;; The following two are necessary for the sake of packages such as
;; ange-ftp which redefine functions via fcell indirection:
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 1bdd6d8fc4..3fc185dda2 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -163,23 +163,23 @@ expression, in which case we want to handle forms differently."
((or `define-generic-mode `define-derived-mode
`define-compilation-mode) nil)
(_ t)))
- (body (nthcdr (or (get car 'doc-string-elt) 3) form))
+ (body (nthcdr (or (function-get car 'doc-string-elt) 3) form))
(doc (if (stringp (car body)) (pop body))))
;; Add the usage form at the end where describe-function-1
;; can recover it.
(when (listp args) (setq doc (help-add-fundoc-usage doc args)))
;; `define-generic-mode' quotes the name, so take care of that
- (list 'autoload (if (listp name) name (list 'quote name))
- file doc
- (or (and (memq car '(define-skeleton define-derived-mode
- define-generic-mode
- easy-mmode-define-global-mode
- define-global-minor-mode
- define-globalized-minor-mode
- easy-mmode-define-minor-mode
- define-minor-mode)) t)
- (eq (car-safe (car body)) 'interactive))
- (if macrop (list 'quote 'macro) nil))))
+ `(autoload ,(if (listp name) name (list 'quote name))
+ ,file ,doc
+ ,(or (and (memq car '(define-skeleton define-derived-mode
+ define-generic-mode
+ easy-mmode-define-global-mode
+ define-global-minor-mode
+ define-globalized-minor-mode
+ easy-mmode-define-minor-mode
+ define-minor-mode)) t)
+ (eq (car-safe (car body)) 'interactive))
+ ,(if macrop ''macro nil))))
;; For defclass forms, use `eieio-defclass-autoload'.
((eq car 'defclass)
@@ -277,7 +277,7 @@ put the output in."
;; Symbols at the toplevel are meaningless.
((symbolp form) nil)
(t
- (let ((doc-string-elt (get (car-safe form) 'doc-string-elt))
+ (let ((doc-string-elt (function-get (car-safe form) 'doc-string-elt))
(outbuf autoload-print-form-outbuf))
(if (and doc-string-elt (stringp (nth doc-string-elt form)))
;; We need to hack the printing because the
@@ -356,7 +356,7 @@ not be relied upon."
"Insert the section-header line,
which lists the file name and which functions are in it, etc."
(insert generate-autoload-section-header)
- (prin1 (list 'autoloads autoloads load-name file time)
+ (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
outbuf)
(terpri outbuf)
;; Break that line at spaces, to avoid very long lines.
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 5a3fd7dddb..a4c3e8aac4 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -249,8 +249,8 @@
(let* ((name (car form))
(localfn (cdr (assq name byte-compile-function-environment)))
(fn (or localfn (and (fboundp name) (symbol-function name)))))
- (when (and (consp fn) (eq (car fn) 'autoload))
- (load (nth 1 fn))
+ (when (autoloadp fn)
+ (autoload-do-load fn)
(setq fn (or (and (fboundp name) (symbol-function name))
(cdr (assq name byte-compile-function-environment)))))
(pcase fn
@@ -586,10 +586,11 @@
(let (opt new)
(if (and (consp form)
(symbolp (car form))
- (or (and for-effect
- ;; we don't have any of these yet, but we might.
- (setq opt (get (car form) 'byte-for-effect-optimizer)))
- (setq opt (get (car form) 'byte-optimizer)))
+ (or ;; (and for-effect
+ ;; ;; We don't have any of these yet, but we might.
+ ;; (setq opt (get (car form)
+ ;; 'byte-for-effect-optimizer)))
+ (setq opt (function-get (car form) 'byte-optimizer)))
(not (eq form (setq new (funcall opt form)))))
(progn
;; (if (equal form new) (error "bogus optimizer -- %s" opt))
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 97d7ab924e..e5df8dd112 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1355,7 +1355,7 @@ extra args."
nums sig min max)
(when calls
(when (and (symbolp name)
- (eq (get name 'byte-optimizer)
+ (eq (function-get name 'byte-optimizer)
'byte-compile-inline-expand))
(byte-compile-warn "defsubst `%s' was used before it was defined"
name))
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 70d907a14c..00ba6b9e0d 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2420,8 +2420,8 @@ and then returning foo."
(while (and (symbolp func)
(not (setq handler (get func 'compiler-macro)))
(fboundp func)
- (or (not (eq (car-safe (symbol-function func)) 'autoload))
- (load (nth 1 (symbol-function func)))))
+ (or (not (autoloadp (symbol-function func)))
+ (autoload-do-load (symbol-function func) func)))
(setq func (symbol-function func)))
(and handler
(not (eq form (setq form (apply handler form (cdr form))))))))
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index 32cf167074..8174de786c 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -320,16 +320,7 @@
))
(let ((new (if (consp fun) (prog1 (cdr fun) (setq fun (car fun)))
(intern (format "cl-%s" fun)))))
- (defalias fun new)
- ;; If `cl-foo' is declare inline, then make `foo' inline as well, and
- ;; similarly. Same for edebug specifications, indent rules and
- ;; doc-string position.
- ;; FIXME: For most of them, we should instead follow aliases
- ;; where applicable.
- (dolist (prop '(byte-optimizer doc-string-elt edebug-form-spec
- lisp-indent-function))
- (if (get new prop)
- (put fun prop (get new prop))))))
+ (defalias fun new)))
;;; Features provided a bit differently in Elisp.
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index b0813aebef..7bc93a19d1 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -805,9 +805,9 @@ Redefining FUNCTION also cancels it."
,(interactive-form (symbol-function function))
(apply ',(symbol-function function)
debug-on-entry-args)))
- (when (eq (car-safe (symbol-function function)) 'autoload)
+ (when (autoloadp (symbol-function function))
;; The function is autoloaded. Load its real definition.
- (load (cadr (symbol-function function)) nil noninteractive nil t))
+ (autoload-do-load (symbol-function function) function))
(when (or (not (consp (symbol-function function)))
(and (eq (car (symbol-function function)) 'macro)
(not (consp (cdr (symbol-function function))))))
diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index ba720b4286..206166bc77 100644
--- a/lisp/emacs-lisp/disass.el
+++ b/lisp/emacs-lisp/disass.el
@@ -80,14 +80,10 @@ redefine OBJECT if it is a symbol."
obj (symbol-function obj)))
(if (subrp obj)
(error "Can't disassemble #<subr %s>" name))
- (when (and (listp obj) (eq (car obj) 'autoload))
- (load (nth 1 obj))
- (setq obj (symbol-function name)))
- (if (eq (car-safe obj) 'macro) ;handle macros
+ (setq obj (autoload-do-load obj name))
+ (if (eq (car-safe obj) 'macro) ;Handle macros.
(setq macro t
obj (cdr obj)))
- (when (and (listp obj) (eq (car obj) 'closure))
- (error "Don't know how to compile an interpreted closure"))
(if (and (listp obj) (eq (car obj) 'byte-code))
(setq obj (list 'lambda nil obj)))
(if (and (listp obj) (not (eq (car obj) 'lambda)))
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index c1c65b6f66..bbf0757c3b 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -242,10 +242,13 @@ If the result is non-nil, then break. Errors are ignored."
(defun get-edebug-spec (symbol)
;; Get the spec of symbol resolving all indirection.
- (let ((edebug-form-spec (get symbol 'edebug-form-spec))
- indirect)
- (while (and (symbolp edebug-form-spec)
- (setq indirect (get edebug-form-spec 'edebug-form-spec)))
+ (let ((edebug-form-spec nil)
+ (indirect symbol))
+ (while
+ (progn
+ (and (symbolp indirect)
+ (setq indirect
+ (function-get indirect 'edebug-form-spec 'autoload))))
;; (edebug-trace "indirection: %s" edebug-form-spec)
(setq edebug-form-spec indirect))
edebug-form-spec
@@ -263,7 +266,7 @@ An extant spec symbol is a symbol that is not a function and has a
(setq spec (cdr spec)))
t))
((symbolp spec)
- (unless (functionp spec) (get spec 'edebug-form-spec)))))
+ (unless (functionp spec) (function-get spec 'edebug-form-spec)))))
;;; Utilities
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index 0839032741..b94817cdb0 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -258,7 +258,7 @@ FUNSYM must be a symbol of a defined function."
;; the autoload here, since that could have side effects, and
;; elp-instrument-function is similar (in my mind) to defun-ish
;; type functionality (i.e. it shouldn't execute the function).
- (and (eq (car-safe funguts) 'autoload)
+ (and (autoloadp funguts)
(error "ELP cannot profile autoloaded function: %s" funsym))
;; We cannot profile functions used internally during profiling.
(unless (elp-profilable-p funsym)
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index d64281d0e8..e1e153d911 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -347,8 +347,7 @@ in `load-path'."
(if aliases
(message "%s" aliases))
(let ((library
- (cond ((eq (car-safe def) 'autoload)
- (nth 1 def))
+ (cond ((autoloadp def) (nth 1 def))
((subrp def)
(if lisp-only
(error "%s is a built-in function" function))
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index eb0e64e22b..d1f997c99c 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -84,14 +84,7 @@ DO must return an Elisp expression."
(if (symbolp place)
(funcall do place (lambda (v) `(setq ,place ,v)))
(let* ((head (car place))
- (gf (get head 'gv-expander)))
- ;; Autoload the head, if applicable, since that might define
- ;; `gv-expander'.
- (when (and (null gf) (fboundp head)
- (eq 'autoload (car-safe (symbol-function head))))
- (with-demoted-errors
- (load (nth 1 (symbol-function head)) 'noerror 'nomsg)
- (setq gf (get head 'gv-expander))))
+ (gf (function-get head 'gv-expander 'autoload)))
(if gf (apply gf do (cdr place))
(let ((me (macroexpand place ;FIXME: expand one step at a time!
;; (append macroexpand-all-environment
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 350b0bd949..e29407f5a8 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -158,7 +158,8 @@ It has `lisp-mode-abbrev-table' as its parent."
(goto-char listbeg)
(and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)")
(match-string 1)))))
- (docelt (and firstsym (get (intern-soft firstsym)
+ (docelt (and firstsym
+ (function-get (intern-soft firstsym)
lisp-doc-string-elt-property))))
(if (and docelt
;; It's a string in a form that can have a docstring.
@@ -1135,7 +1136,8 @@ Lisp function does not specify a special indentation."
(let ((function (buffer-substring (point)
(progn (forward-sexp 1) (point))))
method)
- (setq method (or (get (intern-soft function) 'lisp-indent-function)
+ (setq method (or (function-get (intern-soft function)
+ 'lisp-indent-function)
(get (intern-soft function) 'lisp-indent-hook)))
(cond ((or (eq method 'defun)
(and (null method)
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 65a72aa531..70eab14983 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -185,12 +185,7 @@ Assumes the caller has bound `macroexpand-all-environment'."
;; Macro expand compiler macros. This cannot be delayed to
;; byte-optimize-form because the output of the compiler-macro can
;; use macros.
- (let ((handler nil))
- (while (and (symbolp func)
- (not (setq handler (get func 'compiler-macro)))
- (fboundp func))
- ;; Follow the sequence of aliases.
- (setq func (symbol-function func)))
+ (let ((handler (function-get func 'compiler-macro)))
(if (null handler)
;; No compiler macro. We just expand each argument (for
;; setq/setq-default this works alright because the variable names
@@ -198,12 +193,9 @@ Assumes the caller has bound `macroexpand-all-environment'."
(macroexp--all-forms form 1)
;; If the handler is not loaded yet, try (auto)loading the
;; function itself, which may in turn load the handler.
- (when (and (not (functionp handler))
- (fboundp func) (eq (car-safe (symbol-function func))
- 'autoload))
+ (unless (functionp handler)
(ignore-errors
- (load (nth 1 (symbol-function func))
- 'noerror 'nomsg)))
+ (autoload-do-load (indirect-function func) func)))
(let ((newform (macroexp--compiler-macro handler form)))
(if (eq form newform)
;; The compiler macro did not find anything to do.
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index 3f4ce605cb..4aeed7e4d0 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -114,7 +114,8 @@ QPatterns for vectors are not implemented yet.
PRED can take the form
FUNCTION in which case it gets called with one argument.
- (FUN ARG1 .. ARGN) in which case it gets called with N+1 arguments.
+ (FUN ARG1 .. ARGN) in which case it gets called with an N+1'th argument
+ which is the value being matched.
A PRED of the form FUNCTION is equivalent to one of the form (FUNCTION).
PRED patterns can refer to variables bound earlier in the pattern.
E.g. you can match pairs where the cdr is larger than the car with a pattern