mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-29 19:48:19 +00:00
* lisp/emacs-lisp/macroexp.el (macroexpand-1): New function.
(macroexp--expand-all): Unrelated tweaks. * lisp/emacs-lisp/gv.el (gv-get): Use macroexpand-1. Fixes: debbugs:18821
This commit is contained in:
parent
b645a03e5c
commit
d5262b384e
2
etc/NEWS
2
etc/NEWS
@ -296,6 +296,8 @@ Emacs-21.
|
||||
|
||||
* Lisp Changes in Emacs 25.1
|
||||
|
||||
** New function macroexpand-1 to perform a single step of macroexpansion.
|
||||
|
||||
** Some "x-*" were obsoleted:
|
||||
*** x-select-text is renamed gui-select-text.
|
||||
*** x-selection-value is renamed gui-selection-value.
|
||||
|
@ -1,3 +1,10 @@
|
||||
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
|
||||
@ -8,8 +15,8 @@
|
||||
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.
|
||||
@ -125,7 +132,7 @@
|
||||
|
||||
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
|
||||
@ -133,22 +140,22 @@
|
||||
|
||||
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>
|
||||
|
||||
@ -452,8 +459,8 @@
|
||||
|
||||
* 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.
|
||||
|
||||
|
@ -89,10 +89,10 @@ DO must return an Elisp expression."
|
||||
(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.
|
||||
|
@ -25,7 +25,6 @@
|
||||
;; 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:
|
||||
|
||||
@ -147,11 +146,35 @@ and also to avoid outputting the warning during normal execution."
|
||||
(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
|
||||
@ -241,7 +264,7 @@ Assumes the caller has bound `macroexpand-all-environment'."
|
||||
;; 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)
|
||||
|
Loading…
Reference in New Issue
Block a user