aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el11
-rw-r--r--lisp/emacs-lisp/cl-macs.el42
-rw-r--r--lisp/help-fns.el21
-rw-r--r--lisp/help-mode.el4
5 files changed, 52 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ff4c2fb4444..f3ea1419873 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,15 @@
12013-06-12 Stefan Monnier <monnier@iro.umontreal.ca> 12013-06-12 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * help-fns.el (help-fns--compiler-macro): If the handler function is
4 named, then put a link to it.
5 * help-mode.el (help-function-cmacro): Adjust regexp for cl-lib names.
6 * emacs-lisp/cl-macs.el (cl--compiler-macro-typep): New function.
7 (cl-typep): Use it.
8 (cl-eval-when): Simplify debug spec.
9 (cl-define-compiler-macro): Use eval-and-compile. Give a name to the
10 compiler-macro function instead of setting `compiler-macro-file'.
11
122013-06-12 Stefan Monnier <monnier@iro.umontreal.ca>
2 Daniel Hackney <dan@haxney.org> 13 Daniel Hackney <dan@haxney.org>
3 14
4 First part of Daniel Hackney's patch to package.el. 15 First part of Daniel Hackney's patch to package.el.
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index 33ee7c0bbd2..a06abb03b95 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -267,7 +267,7 @@ including `cl-block' and `cl-eval-when'.
267;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when 267;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
268;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp 268;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
269;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) 269;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*)
270;;;;;; "cl-macs" "cl-macs.el" "80cb53f97b21adb6069c43c38a2e094d") 270;;;;;; "cl-macs" "cl-macs.el" "fd824d987086eafec0b1cb2efa8312f4")
271;;; Generated autoloads from cl-macs.el 271;;; Generated autoloads from cl-macs.el
272 272
273(autoload 'cl--compiler-macro-list* "cl-macs" "\ 273(autoload 'cl--compiler-macro-list* "cl-macs" "\
@@ -699,9 +699,10 @@ OPTION is either a single keyword or (KEYWORD VALUE) where
699KEYWORD can be one of :conc-name, :constructor, :copier, :predicate, 699KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
700:type, :named, :initial-offset, :print-function, or :include. 700:type, :named, :initial-offset, :print-function, or :include.
701 701
702Each SLOT may instead take the form (SLOT SLOT-OPTS...), where 702Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
703SLOT-OPTS are keyword-value pairs for that slot. Currently, only 703SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
704one keyword is supported, `:read-only'. If this has a non-nil 704pairs for that slot.
705Currently, only one keyword is supported, `:read-only'. If this has a non-nil
705value, that slot cannot be set via `setf'. 706value, that slot cannot be set via `setf'.
706 707
707\(fn NAME SLOTS...)" nil t) 708\(fn NAME SLOTS...)" nil t)
@@ -724,6 +725,8 @@ TYPE is a Common Lisp-style type specifier.
724 725
725\(fn OBJECT TYPE)" nil nil) 726\(fn OBJECT TYPE)" nil nil)
726 727
728(eval-and-compile (put 'cl-typep 'compiler-macro #'cl--compiler-macro-typep))
729
727(autoload 'cl-check-type "cl-macs" "\ 730(autoload 'cl-check-type "cl-macs" "\
728Verify that FORM is of type TYPE; signal an error if not. 731Verify that FORM is of type TYPE; signal an error if not.
729STRING is an optional description of the desired type. 732STRING is an optional description of the desired type.
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 66ad8e769b5..34957d86796 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -584,7 +584,7 @@ If `load' is in WHEN, BODY is evaluated when loaded after top-level compile.
584If `eval' is in WHEN, BODY is evaluated when interpreted or at non-top-level. 584If `eval' is in WHEN, BODY is evaluated when interpreted or at non-top-level.
585 585
586\(fn (WHEN...) BODY...)" 586\(fn (WHEN...) BODY...)"
587 (declare (indent 1) (debug ((&rest &or "compile" "load" "eval") body))) 587 (declare (indent 1) (debug (sexp body)))
588 (if (and (fboundp 'cl--compiling-file) (cl--compiling-file) 588 (if (and (fboundp 'cl--compiling-file) (cl--compiling-file)
589 (not cl--not-toplevel) (not (boundp 'for-effect))) ;Horrible kludge. 589 (not cl--not-toplevel) (not (boundp 'for-effect))) ;Horrible kludge.
590 (let ((comp (or (memq 'compile when) (memq :compile-toplevel when))) 590 (let ((comp (or (memq 'compile when) (memq :compile-toplevel when)))
@@ -2276,9 +2276,10 @@ OPTION is either a single keyword or (KEYWORD VALUE) where
2276KEYWORD can be one of :conc-name, :constructor, :copier, :predicate, 2276KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
2277:type, :named, :initial-offset, :print-function, or :include. 2277:type, :named, :initial-offset, :print-function, or :include.
2278 2278
2279Each SLOT may instead take the form (SLOT SLOT-OPTS...), where 2279Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
2280SLOT-OPTS are keyword-value pairs for that slot. Currently, only 2280SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
2281one keyword is supported, `:read-only'. If this has a non-nil 2281pairs for that slot.
2282Currently, only one keyword is supported, `:read-only'. If this has a non-nil
2282value, that slot cannot be set via `setf'. 2283value, that slot cannot be set via `setf'.
2283 2284
2284\(fn NAME SLOTS...)" 2285\(fn NAME SLOTS...)"
@@ -2574,9 +2575,16 @@ The type name can then be used in `cl-typecase', `cl-check-type', etc."
2574(defun cl-typep (object type) ; See compiler macro below. 2575(defun cl-typep (object type) ; See compiler macro below.
2575 "Check that OBJECT is of type TYPE. 2576 "Check that OBJECT is of type TYPE.
2576TYPE is a Common Lisp-style type specifier." 2577TYPE is a Common Lisp-style type specifier."
2578 (declare (compiler-macro cl--compiler-macro-typep))
2577 (let ((cl--object object)) ;; Yuck!! 2579 (let ((cl--object object)) ;; Yuck!!
2578 (eval (cl--make-type-test 'cl--object type)))) 2580 (eval (cl--make-type-test 'cl--object type))))
2579 2581
2582(defun cl--compiler-macro-typep (form val type)
2583 (if (macroexp-const-p type)
2584 (macroexp-let2 macroexp-copyable-p temp val
2585 (cl--make-type-test temp (cl--const-expr-val type)))
2586 form))
2587
2580;;;###autoload 2588;;;###autoload
2581(defmacro cl-check-type (form type &optional string) 2589(defmacro cl-check-type (form type &optional string)
2582 "Verify that FORM is of type TYPE; signal an error if not. 2590 "Verify that FORM is of type TYPE; signal an error if not.
@@ -2635,19 +2643,13 @@ and then returning foo."
2635 (let ((p args) (res nil)) 2643 (let ((p args) (res nil))
2636 (while (consp p) (push (pop p) res)) 2644 (while (consp p) (push (pop p) res))
2637 (setq args (nconc (nreverse res) (and p (list '&rest p))))) 2645 (setq args (nconc (nreverse res) (and p (list '&rest p)))))
2638 `(cl-eval-when (compile load eval) 2646 (let ((fname (make-symbol (concat (symbol-name func) "--cmacro"))))
2639 (put ',func 'compiler-macro 2647 `(eval-and-compile
2640 (cl-function (lambda ,(if (memq '&whole args) (delq '&whole args) 2648 ;; Name the compiler-macro function, so that `symbol-file' can find it.
2641 (cons '_cl-whole-arg args)) 2649 (cl-defun ,fname ,(if (memq '&whole args) (delq '&whole args)
2642 ,@body))) 2650 (cons '_cl-whole-arg args))
2643 ;; This is so that describe-function can locate 2651 ,@body)
2644 ;; the macro definition. 2652 (put ',func 'compiler-macro #',fname))))
2645 (let ((file ,(or buffer-file-name
2646 (and (boundp 'byte-compile-current-file)
2647 (stringp byte-compile-current-file)
2648 byte-compile-current-file))))
2649 (if file (put ',func 'compiler-macro-file
2650 (purecopy (file-name-nondirectory file)))))))
2651 2653
2652;;;###autoload 2654;;;###autoload
2653(defun cl-compiler-macroexpand (form) 2655(defun cl-compiler-macroexpand (form)
@@ -2773,12 +2775,6 @@ surrounded by (cl-block NAME ...).
2773 `(cl-getf (symbol-plist ,sym) ,prop ,def) 2775 `(cl-getf (symbol-plist ,sym) ,prop ,def)
2774 `(get ,sym ,prop))) 2776 `(get ,sym ,prop)))
2775 2777
2776(cl-define-compiler-macro cl-typep (&whole form val type)
2777 (if (macroexp-const-p type)
2778 (macroexp-let2 macroexp-copyable-p temp val
2779 (cl--make-type-test temp (cl--const-expr-val type)))
2780 form))
2781
2782(dolist (y '(cl-first cl-second cl-third cl-fourth 2778(dolist (y '(cl-first cl-second cl-third cl-fourth
2783 cl-fifth cl-sixth cl-seventh 2779 cl-fifth cl-sixth cl-seventh
2784 cl-eighth cl-ninth cl-tenth 2780 cl-eighth cl-ninth cl-tenth
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index bdf86016844..86bb67e87c2 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -435,14 +435,19 @@ suitable file is found, return nil."
435 (let ((handler (function-get function 'compiler-macro))) 435 (let ((handler (function-get function 'compiler-macro)))
436 (when handler 436 (when handler
437 (insert "\nThis function has a compiler macro") 437 (insert "\nThis function has a compiler macro")
438 (let ((lib (get function 'compiler-macro-file))) 438 (if (symbolp handler)
439 ;; FIXME: rather than look at the compiler-macro-file property, 439 (progn
440 ;; just look at `handler' itself. 440 (insert (format " `%s'" handler))
441 (when (stringp lib) 441 (save-excursion
442 (insert (format " in `%s'" lib)) 442 (re-search-backward "`\\([^`']+\\)'" nil t)
443 (save-excursion 443 (help-xref-button 1 'help-function handler)))
444 (re-search-backward "`\\([^`']+\\)'" nil t) 444 ;; FIXME: Obsolete since 24.4.
445 (help-xref-button 1 'help-function-cmacro function lib)))) 445 (let ((lib (get function 'compiler-macro-file)))
446 (when (stringp lib)
447 (insert (format " in `%s'" lib))
448 (save-excursion
449 (re-search-backward "`\\([^`']+\\)'" nil t)
450 (help-xref-button 1 'help-function-cmacro function lib)))))
446 (insert ".\n")))) 451 (insert ".\n"))))
447 452
448(defun help-fns--signature (function doc real-def real-function) 453(defun help-fns--signature (function doc real-def real-function)
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index b5aca1a4445..b56adc2a4a9 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -204,7 +204,7 @@ The format is (FUNCTION ARGS...).")
204 (message "Unable to find location in file")))) 204 (message "Unable to find location in file"))))
205 'help-echo (purecopy "mouse-2, RET: find function's definition")) 205 'help-echo (purecopy "mouse-2, RET: find function's definition"))
206 206
207(define-button-type 'help-function-cmacro 207(define-button-type 'help-function-cmacro ; FIXME: Obsolete since 24.4.
208 :supertype 'help-xref 208 :supertype 'help-xref
209 'help-function (lambda (fun file) 209 'help-function (lambda (fun file)
210 (setq file (locate-library file t)) 210 (setq file (locate-library file t))
@@ -213,7 +213,7 @@ The format is (FUNCTION ARGS...).")
213 (pop-to-buffer (find-file-noselect file)) 213 (pop-to-buffer (find-file-noselect file))
214 (goto-char (point-min)) 214 (goto-char (point-min))
215 (if (re-search-forward 215 (if (re-search-forward
216 (format "^[ \t]*(define-compiler-macro[ \t]+%s" 216 (format "^[ \t]*(\\(cl-\\)?define-compiler-macro[ \t]+%s"
217 (regexp-quote (symbol-name fun))) nil t) 217 (regexp-quote (symbol-name fun))) nil t)
218 (forward-line 0) 218 (forward-line 0)
219 (message "Unable to find location in file"))) 219 (message "Unable to find location in file")))