+2014-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * emacs-lisp/macroexp.el (macroexpand-1): New function (bug#18821).
+ (macroexp--expand-all): Unrelated tweaks.
+
+ * emacs-lisp/gv.el (gv-get): Use macroexpand-1.
+
2014-10-30 Glenn Morris <rgm@gnu.org>
* startup.el (command-line): Remove pointless attempt to avoid
Add "enum classs" support to C++ mode.
* progmodes/cc-langs.el (c-after-brace-list-decl-kwds)
(c-after-brace-list-key): New language consts/variables.
- * progmodes/cc-engine.el (c-looking-at-decl-block): Exclude
- spurious match of "enum struct" from decl-block recognition.
+ * progmodes/cc-engine.el (c-looking-at-decl-block):
+ Exclude spurious match of "enum struct" from decl-block recognition.
(c-backward-colon-prefixed-type): New function.
(c-backward-over-enum-header): Call above function to extend
recognition of enum structure.
2014-10-25 Vincent Belaïche <vincentb1@users.sourceforge.net>
- * ses.el (macroexp): add require for this package, so that
+ * ses.el (macroexp): Add require for this package, so that
function `ses--cell' gets macroexp-quote --- this change was
supposed to be in my previous commit, but left out by mistake.
(ses--cell): Do not make formula a macroexp-quote of value when
2014-10-24 Vincent Belaïche <vincentb1@users.sourceforge.net>
- * ses.el (macroexp): add require for this package, so that function
+ * ses.el (macroexp): Add require for this package, so that function
`ses--cell gets macroexp-quote.
- (ses--cell): makes formula a macroexp-quote of value when formula
+ (ses--cell): Makes formula a macroexp-quote of value when formula
is nil. The rationale of this changr is to allow in the future
shorter SES files, e.g. we could have only `(ses-cell A1 1.0)'
instead of `(ses-cell A1 1.0 1.0 nil REFLIST)'. In such a case
reference list REFLIST would be re-computed after load --- thus
trading off load time against file size.
- * emacs-lisp/package.el (package--alist-to-plist-args): use
- macroexp-quote instead of a lambda expression which has the same
+ * emacs-lisp/package.el (package--alist-to-plist-args):
+ Use macroexp-quote instead of a lambda expression which has the same
content as macroexp-quote.
- (macroexp): add require for this package, so that function
+ (macroexp): Add require for this package, so that function
`package--alist-to-plist-args' gets macroexp-quote.
- * emacs-lisp/macroexp.el (macroexp-quote): new defun.
+ * emacs-lisp/macroexp.el (macroexp-quote): New defun.
2014-10-24 Stefan Monnier <monnier@iro.umontreal.ca>
* net/newst-reader.el (newsticker-html-renderer): Whitespace.
(newsticker--print-extra-elements)
- (newsticker--do-print-extra-element): Documentation
- (newsticker--image-read): Optionally limit image height.
+ (newsticker--do-print-extra-element):
+ Documentation (newsticker--image-read): Optionally limit image height.
Use imagemagick if possible.
(newsticker--icon-read): New.
(let* ((head (car place))
(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
- ;; gv--macro-environment)
- macroexpand-all-environment)))
+ (let ((me (macroexpand-1 place
+ ;; (append macroexpand-all-environment
+ ;; gv--macro-environment)
+ macroexpand-all-environment)))
(if (and (eq me place) (get head 'compiler-macro))
;; Expand compiler macros: this takes care of all the accessors
;; defined via cl-defsubst, such as cXXXr and defstruct slots.
;; This file contains macro-expansions functions that are not defined in
;; the Lisp core, namely `macroexpand-all', which expands all macros in
;; a form, not just a top-level one.
-;;
;;; Code:
(instead (format "; use `%s' instead." instead))
(t ".")))))
+(defun macroexpand-1 (form &optional environment)
+ "Perform (at most) one step of macroexpansion."
+ (cond
+ ((consp form)
+ (let* ((head (car form))
+ (env-expander (assq head environment)))
+ (if env-expander
+ (if (cdr env-expander)
+ (apply (cdr env-expander) (cdr form))
+ form)
+ (if (not (and (symbolp head) (fboundp head)))
+ form
+ (let ((def (autoload-do-load (symbol-function head) head 'macro)))
+ (cond
+ ;; Follow alias, but only for macros, otherwise we may end up
+ ;; skipping an important compiler-macro (e.g. cl--block-wrapper).
+ ((and (symbolp def) (macrop def)) (cons def (cdr form)))
+ ((not (consp def)) form)
+ (t
+ (if (eq 'macro (car def))
+ (apply (cdr def) (cdr form))
+ form))))))))
+ (t form)))
+
(defun macroexp--expand-all (form)
"Expand all macros in FORM.
This is an internal version of `macroexpand-all'.
Assumes the caller has bound `macroexpand-all-environment'."
- (if (and (listp form) (eq (car form) 'backquote-list*))
+ (if (eq (car-safe form) 'backquote-list*)
;; Special-case `backquote-list*', as it is normally a macro that
;; generates exceedingly deep expansions from relatively shallow input
;; forms. We just process it `in reverse' -- first we expand all the
;; If the handler is not loaded yet, try (auto)loading the
;; function itself, which may in turn load the handler.
(unless (functionp handler)
- (ignore-errors
+ (with-demoted-errors "macroexp--expand-all: %S"
(autoload-do-load (indirect-function func) func)))
(let ((newform (macroexp--compiler-macro handler form)))
(if (eq form newform)