diff options
| author | Stefan Monnier | 2011-03-10 14:40:48 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-03-10 14:40:48 -0500 |
| commit | 9ace101ce2e22c85a4298f20702e9b79ae03ad1f (patch) | |
| tree | 9369a3f2d03819f0c7adab56ea7ee715005456ae | |
| parent | bba752f83152f36bfc2a24b212fb5cba3aad9188 (diff) | |
| download | emacs-9ace101ce2e22c85a4298f20702e9b79ae03ad1f.tar.gz emacs-9ace101ce2e22c85a4298f20702e9b79ae03ad1f.zip | |
* lisp/emacs-lisp/bytecomp.el: Use lexical-binding.
(byte-recompile-directory): Remove unused var `bytecomp-dest'.
(byte-recompile-file): Use derived-mode-p.
(byte-compile-from-buffer): Remove arg `bytecomp-filename'.
Use byte-compile-current-file instead.
(byte-compile-file): Adjust call accordingly.
(bytecomp-outbuffer): Move declaration before first use.
(for-effect): Declare dynamic.
(byte-compile-file-form-defmumble): Use byte-compile-current-file.
(byte-compile-top-level, byte-compile-out-toplevel, byte-compile-form):
Move dyn-binding of for-effect from function argument to let binding.
(byte-compile-out-toplevel): Don't both passing for-effect to
byte-optimize-lapcode.
(byte-compile-top-level-body, byte-compile-body):
Rename for-effect -> for-effect-arg so it's lexical.
* lisp/subr.el (functionp): Remove, now that it's in src/eval.c.
| -rw-r--r-- | lisp/ChangeLog | 20 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 157 | ||||
| -rw-r--r-- | lisp/subr.el | 14 |
3 files changed, 99 insertions, 92 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 26661bf6df7..fd00cf70f40 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,24 @@ | |||
| 1 | 2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/byte-opt.el: Use lexical binding. | 3 | * emacs-lisp/bytecomp.el: Use lexical-binding. |
| 4 | (byte-recompile-directory): Remove unused var `bytecomp-dest'. | ||
| 5 | (byte-recompile-file): Use derived-mode-p. | ||
| 6 | (byte-compile-from-buffer): Remove arg `bytecomp-filename'. | ||
| 7 | Use byte-compile-current-file instead. | ||
| 8 | (byte-compile-file): Adjust call accordingly. | ||
| 9 | (bytecomp-outbuffer): Move declaration before first use. | ||
| 10 | (for-effect): Declare dynamic. | ||
| 11 | (byte-compile-file-form-defmumble): Use byte-compile-current-file. | ||
| 12 | (byte-compile-top-level, byte-compile-out-toplevel, byte-compile-form): | ||
| 13 | Move dyn-binding of for-effect from function argument to let binding. | ||
| 14 | (byte-compile-out-toplevel): Don't both passing for-effect to | ||
| 15 | byte-optimize-lapcode. | ||
| 16 | (byte-compile-top-level-body, byte-compile-body): | ||
| 17 | Rename for-effect -> for-effect-arg so it's lexical. | ||
| 18 | |||
| 19 | * subr.el (functionp): Remove, now that it's in src/eval.c. | ||
| 20 | |||
| 21 | * emacs-lisp/byte-opt.el: Use lexical-binding. | ||
| 4 | (for-effectm byte-compile-tag-number): Declare dynamic. | 22 | (for-effectm byte-compile-tag-number): Declare dynamic. |
| 5 | (byte-optimize-form-code-walker, byte-optimize-form): Move dynamic | 23 | (byte-optimize-form-code-walker, byte-optimize-form): Move dynamic |
| 6 | binding of for-effect from function argument to let binding. | 24 | binding of for-effect from function argument to let binding. |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 7b785c9ace6..77dd3408219 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; bytecomp.el --- compilation of Lisp code into byte code | 1 | ;;; bytecomp.el --- compilation of Lisp code into byte code -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2011 | 3 | ;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2011 |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| @@ -1063,7 +1063,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." | |||
| 1063 | ;; This no-op function is used as the value of warning-series | 1063 | ;; This no-op function is used as the value of warning-series |
| 1064 | ;; to tell inner calls to displaying-byte-compile-warnings | 1064 | ;; to tell inner calls to displaying-byte-compile-warnings |
| 1065 | ;; not to bind warning-series. | 1065 | ;; not to bind warning-series. |
| 1066 | (defun byte-compile-warning-series (&rest ignore) | 1066 | (defun byte-compile-warning-series (&rest _ignore) |
| 1067 | nil) | 1067 | nil) |
| 1068 | 1068 | ||
| 1069 | ;; (compile-mode) will cause this to be loaded. | 1069 | ;; (compile-mode) will cause this to be loaded. |
| @@ -1606,7 +1606,7 @@ that already has a `.elc' file." | |||
| 1606 | (setq bytecomp-directory (car bytecomp-directories)) | 1606 | (setq bytecomp-directory (car bytecomp-directories)) |
| 1607 | (message "Checking %s..." bytecomp-directory) | 1607 | (message "Checking %s..." bytecomp-directory) |
| 1608 | (let ((bytecomp-files (directory-files bytecomp-directory)) | 1608 | (let ((bytecomp-files (directory-files bytecomp-directory)) |
| 1609 | bytecomp-source bytecomp-dest) | 1609 | bytecomp-source) |
| 1610 | (dolist (bytecomp-file bytecomp-files) | 1610 | (dolist (bytecomp-file bytecomp-files) |
| 1611 | (setq bytecomp-source | 1611 | (setq bytecomp-source |
| 1612 | (expand-file-name bytecomp-file bytecomp-directory)) | 1612 | (expand-file-name bytecomp-file bytecomp-directory)) |
| @@ -1724,8 +1724,7 @@ The value is non-nil if there were no errors, nil if errors." | |||
| 1724 | (bytecomp-file-name nil) | 1724 | (bytecomp-file-name nil) |
| 1725 | (bytecomp-file-dir nil)) | 1725 | (bytecomp-file-dir nil)) |
| 1726 | (and bytecomp-file | 1726 | (and bytecomp-file |
| 1727 | (eq (cdr (assq 'major-mode (buffer-local-variables))) | 1727 | (derived-mode-p 'emacs-lisp-mode) |
| 1728 | 'emacs-lisp-mode) | ||
| 1729 | (setq bytecomp-file-name (file-name-nondirectory bytecomp-file) | 1728 | (setq bytecomp-file-name (file-name-nondirectory bytecomp-file) |
| 1730 | bytecomp-file-dir (file-name-directory bytecomp-file))) | 1729 | bytecomp-file-dir (file-name-directory bytecomp-file))) |
| 1731 | (list (read-file-name (if current-prefix-arg | 1730 | (list (read-file-name (if current-prefix-arg |
| @@ -1803,7 +1802,7 @@ The value is non-nil if there were no errors, nil if errors." | |||
| 1803 | ;; within byte-compile-from-buffer lingers in that buffer. | 1802 | ;; within byte-compile-from-buffer lingers in that buffer. |
| 1804 | (setq output-buffer | 1803 | (setq output-buffer |
| 1805 | (save-current-buffer | 1804 | (save-current-buffer |
| 1806 | (byte-compile-from-buffer input-buffer bytecomp-filename))) | 1805 | (byte-compile-from-buffer input-buffer))) |
| 1807 | (if byte-compiler-error-flag | 1806 | (if byte-compiler-error-flag |
| 1808 | nil | 1807 | nil |
| 1809 | (when byte-compile-verbose | 1808 | (when byte-compile-verbose |
| @@ -1880,9 +1879,11 @@ With argument ARG, insert value in current buffer after the form." | |||
| 1880 | (insert "\n")) | 1879 | (insert "\n")) |
| 1881 | ((message "%s" (prin1-to-string value))))))) | 1880 | ((message "%s" (prin1-to-string value))))))) |
| 1882 | 1881 | ||
| 1882 | ;; Dynamically bound in byte-compile-from-buffer. | ||
| 1883 | ;; NB also used in cl.el and cl-macs.el. | ||
| 1884 | (defvar bytecomp-outbuffer) | ||
| 1883 | 1885 | ||
| 1884 | (defun byte-compile-from-buffer (bytecomp-inbuffer &optional bytecomp-filename) | 1886 | (defun byte-compile-from-buffer (bytecomp-inbuffer) |
| 1885 | ;; Filename is used for the loading-into-Emacs-18 error message. | ||
| 1886 | (let (bytecomp-outbuffer | 1887 | (let (bytecomp-outbuffer |
| 1887 | (byte-compile-current-buffer bytecomp-inbuffer) | 1888 | (byte-compile-current-buffer bytecomp-inbuffer) |
| 1888 | (byte-compile-read-position nil) | 1889 | (byte-compile-read-position nil) |
| @@ -1919,8 +1920,9 @@ With argument ARG, insert value in current buffer after the form." | |||
| 1919 | (setq case-fold-search nil)) | 1920 | (setq case-fold-search nil)) |
| 1920 | (displaying-byte-compile-warnings | 1921 | (displaying-byte-compile-warnings |
| 1921 | (with-current-buffer bytecomp-inbuffer | 1922 | (with-current-buffer bytecomp-inbuffer |
| 1922 | (and bytecomp-filename | 1923 | (and byte-compile-current-file |
| 1923 | (byte-compile-insert-header bytecomp-filename bytecomp-outbuffer)) | 1924 | (byte-compile-insert-header byte-compile-current-file |
| 1925 | bytecomp-outbuffer)) | ||
| 1924 | (goto-char (point-min)) | 1926 | (goto-char (point-min)) |
| 1925 | ;; Should we always do this? When calling multiple files, it | 1927 | ;; Should we always do this? When calling multiple files, it |
| 1926 | ;; would be useful to delay this warning until all have been | 1928 | ;; would be useful to delay this warning until all have been |
| @@ -1952,9 +1954,9 @@ and will be removed soon. See (elisp)Backquote in the manual.")) | |||
| 1952 | (byte-compile-warn-about-unresolved-functions)) | 1954 | (byte-compile-warn-about-unresolved-functions)) |
| 1953 | ;; Fix up the header at the front of the output | 1955 | ;; Fix up the header at the front of the output |
| 1954 | ;; if the buffer contains multibyte characters. | 1956 | ;; if the buffer contains multibyte characters. |
| 1955 | (and bytecomp-filename | 1957 | (and byte-compile-current-file |
| 1956 | (with-current-buffer bytecomp-outbuffer | 1958 | (with-current-buffer bytecomp-outbuffer |
| 1957 | (byte-compile-fix-header bytecomp-filename))))) | 1959 | (byte-compile-fix-header byte-compile-current-file))))) |
| 1958 | bytecomp-outbuffer)) | 1960 | bytecomp-outbuffer)) |
| 1959 | 1961 | ||
| 1960 | (defun byte-compile-fix-header (filename) | 1962 | (defun byte-compile-fix-header (filename) |
| @@ -2043,10 +2045,6 @@ Call from the source buffer." | |||
| 2043 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" | 2045 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" |
| 2044 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")))) | 2046 | ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")))) |
| 2045 | 2047 | ||
| 2046 | ;; Dynamically bound in byte-compile-from-buffer. | ||
| 2047 | ;; NB also used in cl.el and cl-macs.el. | ||
| 2048 | (defvar bytecomp-outbuffer) | ||
| 2049 | |||
| 2050 | (defun byte-compile-output-file-form (form) | 2048 | (defun byte-compile-output-file-form (form) |
| 2051 | ;; writes the given form to the output buffer, being careful of docstrings | 2049 | ;; writes the given form to the output buffer, being careful of docstrings |
| 2052 | ;; in defun, defmacro, defvar, defvaralias, defconst, autoload and | 2050 | ;; in defun, defmacro, defvar, defvaralias, defconst, autoload and |
| @@ -2073,6 +2071,7 @@ Call from the source buffer." | |||
| 2073 | nil))) | 2071 | nil))) |
| 2074 | 2072 | ||
| 2075 | (defvar print-gensym-alist) ;Used before print-circle existed. | 2073 | (defvar print-gensym-alist) ;Used before print-circle existed. |
| 2074 | (defvar for-effect) | ||
| 2076 | 2075 | ||
| 2077 | (defun byte-compile-output-docform (preface name info form specindex quoted) | 2076 | (defun byte-compile-output-docform (preface name info form specindex quoted) |
| 2078 | "Print a form with a doc string. INFO is (prefix doc-index postfix). | 2077 | "Print a form with a doc string. INFO is (prefix doc-index postfix). |
| @@ -2138,7 +2137,7 @@ list that represents a doc string reference. | |||
| 2138 | ;; (for instance, gensyms in the arg list). | 2137 | ;; (for instance, gensyms in the arg list). |
| 2139 | (let (non-nil) | 2138 | (let (non-nil) |
| 2140 | (when (hash-table-p print-number-table) | 2139 | (when (hash-table-p print-number-table) |
| 2141 | (maphash (lambda (k v) (if v (setq non-nil t))) | 2140 | (maphash (lambda (_k v) (if v (setq non-nil t))) |
| 2142 | print-number-table)) | 2141 | print-number-table)) |
| 2143 | (not non-nil))) | 2142 | (not non-nil))) |
| 2144 | ;; Output the byte code and constants specially | 2143 | ;; Output the byte code and constants specially |
| @@ -2393,8 +2392,8 @@ by side-effects." | |||
| 2393 | (if (byte-compile-warning-enabled-p 'redefine) | 2392 | (if (byte-compile-warning-enabled-p 'redefine) |
| 2394 | (byte-compile-arglist-warn form macrop)) | 2393 | (byte-compile-arglist-warn form macrop)) |
| 2395 | (if byte-compile-verbose | 2394 | (if byte-compile-verbose |
| 2396 | ;; bytecomp-filename is from byte-compile-from-buffer. | 2395 | (message "Compiling %s... (%s)" |
| 2397 | (message "Compiling %s... (%s)" (or bytecomp-filename "") (nth 1 form))) | 2396 | (or byte-compile-current-file "") (nth 1 form))) |
| 2398 | (cond (bytecomp-that-one | 2397 | (cond (bytecomp-that-one |
| 2399 | (if (and (byte-compile-warning-enabled-p 'redefine) | 2398 | (if (and (byte-compile-warning-enabled-p 'redefine) |
| 2400 | ;; don't warn when compiling the stubs in byte-run... | 2399 | ;; don't warn when compiling the stubs in byte-run... |
| @@ -2815,14 +2814,15 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2815 | 2814 | ||
| 2816 | ;; Given an expression FORM, compile it and return an equivalent byte-code | 2815 | ;; Given an expression FORM, compile it and return an equivalent byte-code |
| 2817 | ;; expression (a call to the function byte-code). | 2816 | ;; expression (a call to the function byte-code). |
| 2818 | (defun byte-compile-top-level (form &optional for-effect output-type | 2817 | (defun byte-compile-top-level (form &optional for-effect-arg output-type |
| 2819 | lexenv reserved-csts) | 2818 | lexenv reserved-csts) |
| 2820 | ;; OUTPUT-TYPE advises about how form is expected to be used: | 2819 | ;; OUTPUT-TYPE advises about how form is expected to be used: |
| 2821 | ;; 'eval or nil -> a single form, | 2820 | ;; 'eval or nil -> a single form, |
| 2822 | ;; 'progn or t -> a list of forms, | 2821 | ;; 'progn or t -> a list of forms, |
| 2823 | ;; 'lambda -> body of a lambda, | 2822 | ;; 'lambda -> body of a lambda, |
| 2824 | ;; 'file -> used at file-level. | 2823 | ;; 'file -> used at file-level. |
| 2825 | (let ((byte-compile-constants nil) | 2824 | (let ((for-effect for-effect-arg) |
| 2825 | (byte-compile-constants nil) | ||
| 2826 | (byte-compile-variables nil) | 2826 | (byte-compile-variables nil) |
| 2827 | (byte-compile-tag-number 0) | 2827 | (byte-compile-tag-number 0) |
| 2828 | (byte-compile-depth 0) | 2828 | (byte-compile-depth 0) |
| @@ -2852,8 +2852,8 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2852 | (byte-compile-form form for-effect) | 2852 | (byte-compile-form form for-effect) |
| 2853 | (byte-compile-out-toplevel for-effect output-type)))) | 2853 | (byte-compile-out-toplevel for-effect output-type)))) |
| 2854 | 2854 | ||
| 2855 | (defun byte-compile-out-toplevel (&optional for-effect output-type) | 2855 | (defun byte-compile-out-toplevel (&optional for-effect-arg output-type) |
| 2856 | (if for-effect | 2856 | (if for-effect-arg |
| 2857 | ;; The stack is empty. Push a value to be returned from (byte-code ..). | 2857 | ;; The stack is empty. Push a value to be returned from (byte-code ..). |
| 2858 | (if (eq (car (car byte-compile-output)) 'byte-discard) | 2858 | (if (eq (car (car byte-compile-output)) 'byte-discard) |
| 2859 | (setq byte-compile-output (cdr byte-compile-output)) | 2859 | (setq byte-compile-output (cdr byte-compile-output)) |
| @@ -2872,7 +2872,7 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2872 | (setq byte-compile-output (nreverse byte-compile-output)) | 2872 | (setq byte-compile-output (nreverse byte-compile-output)) |
| 2873 | (if (memq byte-optimize '(t byte)) | 2873 | (if (memq byte-optimize '(t byte)) |
| 2874 | (setq byte-compile-output | 2874 | (setq byte-compile-output |
| 2875 | (byte-optimize-lapcode byte-compile-output for-effect))) | 2875 | (byte-optimize-lapcode byte-compile-output))) |
| 2876 | 2876 | ||
| 2877 | ;; Decompile trivial functions: | 2877 | ;; Decompile trivial functions: |
| 2878 | ;; only constants and variables, or a single funcall except in lambdas. | 2878 | ;; only constants and variables, or a single funcall except in lambdas. |
| @@ -2889,6 +2889,7 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2889 | ;; progn -> as <<same-as-eval>> or (progn <<same-as-eval>> atom) | 2889 | ;; progn -> as <<same-as-eval>> or (progn <<same-as-eval>> atom) |
| 2890 | ;; file -> as progn, but takes both quotes and atoms, and longer forms. | 2890 | ;; file -> as progn, but takes both quotes and atoms, and longer forms. |
| 2891 | (let (rest | 2891 | (let (rest |
| 2892 | (for-effect for-effect-arg) | ||
| 2892 | (maycall (not (eq output-type 'lambda))) ; t if we may make a funcall. | 2893 | (maycall (not (eq output-type 'lambda))) ; t if we may make a funcall. |
| 2893 | tmp body) | 2894 | tmp body) |
| 2894 | (cond | 2895 | (cond |
| @@ -2938,9 +2939,9 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2938 | ((car body))))) | 2939 | ((car body))))) |
| 2939 | 2940 | ||
| 2940 | ;; Given BYTECOMP-BODY, compile it and return a new body. | 2941 | ;; Given BYTECOMP-BODY, compile it and return a new body. |
| 2941 | (defun byte-compile-top-level-body (bytecomp-body &optional for-effect) | 2942 | (defun byte-compile-top-level-body (bytecomp-body &optional for-effect-arg) |
| 2942 | (setq bytecomp-body | 2943 | (setq bytecomp-body |
| 2943 | (byte-compile-top-level (cons 'progn bytecomp-body) for-effect t)) | 2944 | (byte-compile-top-level (cons 'progn bytecomp-body) for-effect-arg t)) |
| 2944 | (cond ((eq (car-safe bytecomp-body) 'progn) | 2945 | (cond ((eq (car-safe bytecomp-body) 'progn) |
| 2945 | (cdr bytecomp-body)) | 2946 | (cdr bytecomp-body)) |
| 2946 | (bytecomp-body | 2947 | (bytecomp-body |
| @@ -2971,54 +2972,56 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2971 | ;; byte-compile-form, or take extreme care to handle for-effect correctly. | 2972 | ;; byte-compile-form, or take extreme care to handle for-effect correctly. |
| 2972 | ;; (Use byte-compile-form-do-effect to reset the for-effect flag too.) | 2973 | ;; (Use byte-compile-form-do-effect to reset the for-effect flag too.) |
| 2973 | ;; | 2974 | ;; |
| 2974 | (defun byte-compile-form (form &optional for-effect) | 2975 | (defun byte-compile-form (form &optional for-effect-arg) |
| 2975 | (cond ((not (consp form)) | 2976 | (let ((for-effect for-effect-arg)) |
| 2976 | (cond ((or (not (symbolp form)) (byte-compile-const-symbol-p form)) | 2977 | (cond |
| 2977 | (when (symbolp form) | 2978 | ((not (consp form)) |
| 2978 | (byte-compile-set-symbol-position form)) | 2979 | (cond ((or (not (symbolp form)) (byte-compile-const-symbol-p form)) |
| 2979 | (byte-compile-constant form)) | 2980 | (when (symbolp form) |
| 2980 | ((and for-effect byte-compile-delete-errors) | 2981 | (byte-compile-set-symbol-position form)) |
| 2981 | (when (symbolp form) | 2982 | (byte-compile-constant form)) |
| 2982 | (byte-compile-set-symbol-position form)) | 2983 | ((and for-effect byte-compile-delete-errors) |
| 2983 | (setq for-effect nil)) | 2984 | (when (symbolp form) |
| 2984 | (t | 2985 | (byte-compile-set-symbol-position form)) |
| 2985 | (byte-compile-variable-ref form)))) | 2986 | (setq for-effect nil)) |
| 2986 | ((symbolp (car form)) | 2987 | (t |
| 2987 | (let* ((bytecomp-fn (car form)) | 2988 | (byte-compile-variable-ref form)))) |
| 2988 | (bytecomp-handler (get bytecomp-fn 'byte-compile))) | 2989 | ((symbolp (car form)) |
| 2989 | (when (byte-compile-const-symbol-p bytecomp-fn) | 2990 | (let* ((bytecomp-fn (car form)) |
| 2990 | (byte-compile-warn "`%s' called as a function" bytecomp-fn)) | 2991 | (bytecomp-handler (get bytecomp-fn 'byte-compile))) |
| 2991 | (and (byte-compile-warning-enabled-p 'interactive-only) | 2992 | (when (byte-compile-const-symbol-p bytecomp-fn) |
| 2992 | (memq bytecomp-fn byte-compile-interactive-only-functions) | 2993 | (byte-compile-warn "`%s' called as a function" bytecomp-fn)) |
| 2993 | (byte-compile-warn "`%s' used from Lisp code\n\ | 2994 | (and (byte-compile-warning-enabled-p 'interactive-only) |
| 2995 | (memq bytecomp-fn byte-compile-interactive-only-functions) | ||
| 2996 | (byte-compile-warn "`%s' used from Lisp code\n\ | ||
| 2994 | That command is designed for interactive use only" bytecomp-fn)) | 2997 | That command is designed for interactive use only" bytecomp-fn)) |
| 2995 | (if (and (fboundp (car form)) | 2998 | (if (and (fboundp (car form)) |
| 2996 | (eq (car-safe (symbol-function (car form))) 'macro)) | 2999 | (eq (car-safe (symbol-function (car form))) 'macro)) |
| 2997 | (byte-compile-report-error | 3000 | (byte-compile-report-error |
| 2998 | (format "Forgot to expand macro %s" (car form)))) | 3001 | (format "Forgot to expand macro %s" (car form)))) |
| 2999 | (if (and bytecomp-handler | 3002 | (if (and bytecomp-handler |
| 3000 | ;; Make sure that function exists. This is important | 3003 | ;; Make sure that function exists. This is important |
| 3001 | ;; for CL compiler macros since the symbol may be | 3004 | ;; for CL compiler macros since the symbol may be |
| 3002 | ;; `cl-byte-compile-compiler-macro' but if CL isn't | 3005 | ;; `cl-byte-compile-compiler-macro' but if CL isn't |
| 3003 | ;; loaded, this function doesn't exist. | 3006 | ;; loaded, this function doesn't exist. |
| 3004 | (and (not (eq bytecomp-handler | 3007 | (and (not (eq bytecomp-handler |
| 3005 | ;; Already handled by macroexpand-all. | 3008 | ;; Already handled by macroexpand-all. |
| 3006 | 'cl-byte-compile-compiler-macro)) | 3009 | 'cl-byte-compile-compiler-macro)) |
| 3007 | (functionp bytecomp-handler))) | 3010 | (functionp bytecomp-handler))) |
| 3008 | (funcall bytecomp-handler form) | 3011 | (funcall bytecomp-handler form) |
| 3009 | (byte-compile-normal-call form)) | 3012 | (byte-compile-normal-call form)) |
| 3010 | (if (byte-compile-warning-enabled-p 'cl-functions) | 3013 | (if (byte-compile-warning-enabled-p 'cl-functions) |
| 3011 | (byte-compile-cl-warn form)))) | 3014 | (byte-compile-cl-warn form)))) |
| 3012 | ((and (or (byte-code-function-p (car form)) | 3015 | ((and (or (byte-code-function-p (car form)) |
| 3013 | (eq (car-safe (car form)) 'lambda)) | 3016 | (eq (car-safe (car form)) 'lambda)) |
| 3014 | ;; if the form comes out the same way it went in, that's | 3017 | ;; if the form comes out the same way it went in, that's |
| 3015 | ;; because it was malformed, and we couldn't unfold it. | 3018 | ;; because it was malformed, and we couldn't unfold it. |
| 3016 | (not (eq form (setq form (byte-compile-unfold-lambda form))))) | 3019 | (not (eq form (setq form (byte-compile-unfold-lambda form))))) |
| 3017 | (byte-compile-form form for-effect) | 3020 | (byte-compile-form form for-effect) |
| 3018 | (setq for-effect nil)) | 3021 | (setq for-effect nil)) |
| 3019 | ((byte-compile-normal-call form))) | 3022 | ((byte-compile-normal-call form))) |
| 3020 | (if for-effect | 3023 | (if for-effect |
| 3021 | (byte-compile-discard))) | 3024 | (byte-compile-discard)))) |
| 3022 | 3025 | ||
| 3023 | (defun byte-compile-normal-call (form) | 3026 | (defun byte-compile-normal-call (form) |
| 3024 | (when (and (byte-compile-warning-enabled-p 'callargs) | 3027 | (when (and (byte-compile-warning-enabled-p 'callargs) |
| @@ -3326,7 +3329,7 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\"" | |||
| 3326 | ((= len 4) (byte-compile-three-args form)) | 3329 | ((= len 4) (byte-compile-three-args form)) |
| 3327 | (t (byte-compile-subr-wrong-args form "2-3"))))) | 3330 | (t (byte-compile-subr-wrong-args form "2-3"))))) |
| 3328 | 3331 | ||
| 3329 | (defun byte-compile-noop (form) | 3332 | (defun byte-compile-noop (_form) |
| 3330 | (byte-compile-constant nil)) | 3333 | (byte-compile-constant nil)) |
| 3331 | 3334 | ||
| 3332 | (defun byte-compile-discard (&optional num preserve-tos) | 3335 | (defun byte-compile-discard (&optional num preserve-tos) |
| @@ -3632,11 +3635,11 @@ discarding." | |||
| 3632 | 3635 | ||
| 3633 | ;;; control structures | 3636 | ;;; control structures |
| 3634 | 3637 | ||
| 3635 | (defun byte-compile-body (bytecomp-body &optional for-effect) | 3638 | (defun byte-compile-body (bytecomp-body &optional for-effect-arg) |
| 3636 | (while (cdr bytecomp-body) | 3639 | (while (cdr bytecomp-body) |
| 3637 | (byte-compile-form (car bytecomp-body) t) | 3640 | (byte-compile-form (car bytecomp-body) t) |
| 3638 | (setq bytecomp-body (cdr bytecomp-body))) | 3641 | (setq bytecomp-body (cdr bytecomp-body))) |
| 3639 | (byte-compile-form (car bytecomp-body) for-effect)) | 3642 | (byte-compile-form (car bytecomp-body) for-effect-arg)) |
| 3640 | 3643 | ||
| 3641 | (defsubst byte-compile-body-do-effect (bytecomp-body) | 3644 | (defsubst byte-compile-body-do-effect (bytecomp-body) |
| 3642 | (byte-compile-body bytecomp-body for-effect) | 3645 | (byte-compile-body bytecomp-body for-effect) |
| @@ -4190,7 +4193,7 @@ binding slots have been popped." | |||
| 4190 | 4193 | ||
| 4191 | ;; Lambdas in valid places are handled as special cases by various code. | 4194 | ;; Lambdas in valid places are handled as special cases by various code. |
| 4192 | ;; The ones that remain are errors. | 4195 | ;; The ones that remain are errors. |
| 4193 | (defun byte-compile-lambda-form (form) | 4196 | (defun byte-compile-lambda-form (_form) |
| 4194 | (byte-compile-set-symbol-position 'lambda) | 4197 | (byte-compile-set-symbol-position 'lambda) |
| 4195 | (error "`lambda' used as function name is invalid")) | 4198 | (error "`lambda' used as function name is invalid")) |
| 4196 | 4199 | ||
diff --git a/lisp/subr.el b/lisp/subr.el index a493c31b254..b7b5bec1249 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -249,20 +249,6 @@ Any list whose car is `frame-configuration' is assumed to be a frame | |||
| 249 | configuration." | 249 | configuration." |
| 250 | (and (consp object) | 250 | (and (consp object) |
| 251 | (eq (car object) 'frame-configuration))) | 251 | (eq (car object) 'frame-configuration))) |
| 252 | |||
| 253 | (defun functionp (object) | ||
| 254 | "Non-nil if OBJECT is a function." | ||
| 255 | (or (and (symbolp object) (fboundp object) | ||
| 256 | (condition-case nil | ||
| 257 | (setq object (indirect-function object)) | ||
| 258 | (error nil)) | ||
| 259 | (eq (car-safe object) 'autoload) | ||
| 260 | (not (car-safe (cdr-safe (cdr-safe (cdr-safe (cdr-safe object))))))) | ||
| 261 | (and (subrp object) | ||
| 262 | ;; Filter out special forms. | ||
| 263 | (not (eq 'unevalled (cdr (subr-arity object))))) | ||
| 264 | (byte-code-function-p object) | ||
| 265 | (eq (car-safe object) 'lambda))) | ||
| 266 | 252 | ||
| 267 | ;;;; List functions. | 253 | ;;;; List functions. |
| 268 | 254 | ||