[slime-cvs] CVS slime
CVS User trittweiler
trittweiler at common-lisp.net
Sat Sep 18 08:54:02 UTC 2010
Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv18113
Modified Files:
ChangeLog slime.el swank.lisp
Log Message:
Make C-c C-m also expand compiler macros. (lp#638720)
* slime.el (slime-macro/compiler-macro-expand-1): New.
(slime-macro/compiler-macro-expand-1-inplace): New.
(slime-editing-keys): Map `C-c C-m' to first above.
(slime-compiler-macroexpand-1): Take prefix-arg like others.
(slime-compiler-macroexpand-1-inplace): Ditto.
(slime-compiler-macroexpand): Thus deleted.
(slime-compiler-macroexpand-inplace): Ditto.
* swank.lisp (swank-macro/compiler-macro-expand-1): New interface.
(swank-macro/compiler-macro-expand): New interface.
(macro/compiler-macro-expand-1): New.
(macro/compiler-macro-expand): New.
(expand-repeatedly): New helper.
--- /project/slime/cvsroot/slime/ChangeLog 2010/09/03 22:29:43 1.2138
+++ /project/slime/cvsroot/slime/ChangeLog 2010/09/18 08:54:01 1.2139
@@ -1,3 +1,21 @@
+2010-09-18 Tobias C. Rittweiler <tcr at freebits.de>
+
+ Make C-c C-m also expand compiler macros. (lp#638720)
+
+ * slime.el (slime-macro/compiler-macro-expand-1): New.
+ (slime-macro/compiler-macro-expand-1-inplace): New.
+ (slime-editing-keys): Map `C-c C-m' to first above.
+ (slime-compiler-macroexpand-1): Take prefix-arg like others.
+ (slime-compiler-macroexpand-1-inplace): Ditto.
+ (slime-compiler-macroexpand): Thus deleted.
+ (slime-compiler-macroexpand-inplace): Ditto.
+
+ * swank.lisp (swank-macro/compiler-macro-expand-1): New interface.
+ (swank-macro/compiler-macro-expand): New interface.
+ (macro/compiler-macro-expand-1): New.
+ (macro/compiler-macro-expand): New.
+ (expand-repeatedly): New helper.
+
2010-09-03 Stas Boukarev <stassats at gmail.com>
* slime.el (slime-forward-cruft): Use " \t\n" to match whitespaces
--- /project/slime/cvsroot/slime/slime.el 2010/09/03 22:29:43 1.1338
+++ /project/slime/cvsroot/slime/slime.el 2010/09/18 08:54:01 1.1339
@@ -550,7 +550,7 @@
;;("\C-x\M-e" slime-eval-last-expression-display-output :inferior t)
("\C-c\C-p" slime-pprint-eval-last-expression)
;; Macroexpand
- ("\C-c\C-m" slime-macroexpand-1)
+ ("\C-c\C-m" slime-macro/compiler-macro-expand-1)
("\C-c\M-m" slime-macroexpand-all)
;; Misc
("\C-c\C-u" slime-undefine-function)
@@ -4879,7 +4879,8 @@
(remap 'slime-macroexpand-1 'slime-macroexpand-1-inplace)
(remap 'slime-macroexpand-all 'slime-macroexpand-all-inplace)
(remap 'slime-compiler-macroexpand-1 'slime-compiler-macroexpand-1-inplace)
- (remap 'slime-compiler-macroexpand 'slime-compiler-macroexpand-inplace)
+ (remap 'slime-macro/compiler-macro-expand-1
+ 'slime-macro/compiler-macro-expand-1-inplace)
(remap 'advertised-undo 'slime-macroexpand-undo)
(remap 'undo 'slime-macroexpand-undo))
@@ -5002,25 +5003,41 @@
(interactive)
(slime-eval-macroexpand-inplace 'swank:swank-macroexpand-all))
-(defun slime-compiler-macroexpand ()
+(defun slime-compiler-macroexpand-1 (&optional repeatedly)
"Display the compiler-macro expansion of sexp at point."
- (interactive)
- (slime-eval-macroexpand 'swank:swank-compiler-macroexpand))
+ (interactive "P")
+ (slime-eval-macroexpand
+ (if repeatedly
+ 'swank:swank-compiler-macroexpand
+ 'swank:swank-compiler-macroexpand-1)))
-(defun slime-compiler-macroexpand-inplace ()
+(defun slime-compiler-macroexpand-1-inplace (&optional repeatedly)
"Display the compiler-macro expansion of sexp at point."
- (interactive)
- (slime-eval-macroexpand-inplace 'swank:swank-compiler-macroexpand))
+ (interactive "P")
+ (slime-eval-macroexpand-inplace
+ (if repeatedly
+ 'swank:swank-compiler-macroexpand
+ 'swank:swank-compiler-macroexpand-1)))
-(defun slime-compiler-macroexpand-1 ()
- "Display the compiler-macro expansion of sexp at point."
- (interactive)
- (slime-eval-macroexpand 'swank:swank-compiler-macroexpand-1))
+(defun slime-macro/compiler-macro-expand-1 (&optional repeatedly)
+ "Display the macro expansion of the form at point.
+The form is expanded with CL:MACROEXPAND-1 or, if a prefix
+argument is given, with CL:MACROEXPAND."
+ (interactive "P")
+ (slime-eval-macroexpand
+ (if repeatedly
+ 'swank:swank-macro/compiler-macro-expand
+ 'swank:swank-macro/compiler-macro-expand-1)))
-(defun slime-compiler-macroexpand-1-inplace ()
- "Display the compiler-macro expansion of sexp at point."
- (interactive)
- (slime-eval-macroexpand-inplace 'swank:swank-compiler-macroexpand-1))
+(defun slime-macro/compiler-macro-expand-1-inplace (&optional repeatedly)
+ "Display the macro expansion of the form at point.
+The form is expanded with CL:MACROEXPAND-1 or, if a prefix
+argument is given, with CL:MACROEXPAND."
+ (interactive "P")
+ (slime-eval-macroexpand-inplace
+ (if repeatedly
+ 'swank:swank-macro/compiler-macro-expand
+ 'swank:swank-macro/compiler-macro-expand-1)))
(defun slime-format-string-expand ()
"Expand the format-string at point and display it."
--- /project/slime/cvsroot/slime/swank.lisp 2010/09/03 07:25:19 1.726
+++ /project/slime/cvsroot/slime/swank.lisp 2010/09/18 08:54:01 1.727
@@ -2974,6 +2974,27 @@
(defslimefun swank-compiler-macroexpand (string)
(apply-macro-expander #'compiler-macroexpand string))
+(defslimefun swank-macro/compiler-macro-expand-1 (string)
+ (apply-macro-expander #'macro/compiler-macro-expand-1 string))
+
+(defslimefun swank-macro/compiler-macro-expand (string)
+ (apply-macro-expander #'macro/compiler-macro-expand string))
+
+(defun macro/compiler-macro-expand-1 (form)
+ (multiple-value-bind (expansion expanded?) (macroexpand-1 form)
+ (if expanded?
+ (values expansion t)
+ (compiler-macroexpand-1 form))))
+
+(defun macro/compiler-macro-expand (form)
+ (expand-repeatedly #'macro/compiler-macro-expand-1 form))
+
+(defun expand-repeatedly (expander form)
+ (loop
+ (multiple-value-bind (expansion expanded?) (funcall expander form)
+ (unless expanded? (return expansion))
+ (setq form expansion))))
+
(defslimefun swank-format-string-expand (string)
(apply-macro-expander #'format-string-expand string))
More information about the slime-cvs
mailing list