[slime-cvs] CVS slime

CVS User trittweiler trittweiler at common-lisp.net
Sun Feb 22 14:18:48 UTC 2009


Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv16652

Modified Files:
	slime.el swank-backend.lisp swank.lisp 
Log Message:
	`M-x slime-format-string-expand' displays the expansion of a
	format string.

	* slime.el (slime-string-at-point) New.
	(slime-string-at-point-or-error): New.
	(slime-format-string-expand): New; use them.

	* swank-backend.lisp (format-string-expand): New interface.
	* swank.lisp (swank-format-string-expand): New; use it.


--- /project/slime/cvsroot/slime/slime.el	2009/02/17 09:03:41	1.1124
+++ /project/slime/cvsroot/slime/slime.el	2009/02/22 14:18:47	1.1125
@@ -4962,6 +4962,18 @@
   (remap 'advertised-undo 'slime-macroexpand-undo)
   (remap 'undo 'slime-macroexpand-undo))
 
+(defun slime-macroexpand-undo (&optional arg)
+  (interactive)
+  (flet ((undo-only (arg)
+           ;; Emacs 22.x introduced `undo-only' which works by binding
+           ;; `undo-no-redo' to t. We do it this way so we don't break
+           ;; prior Emacs versions.
+           (let ((undo-no-redo t)) (undo arg))))
+    (let ((inhibit-read-only t))
+      (when (fboundp 'slime-remove-edits)
+        (slime-remove-edits (point-min) (point-max)))
+      (undo-only arg))))
+
 (defun slime-sexp-at-point-for-macroexpansion ()
   "Essentially like SLIME-SEXP-AT-POINT-OR-ERROR, but behaves a
 bit more sanely in situations like ,(loop ...) where you want to
@@ -4993,6 +5005,13 @@
     (slime-eval-async slime-eval-macroexpand-expression
                       #'slime-initialize-macroexpansion-buffer)))
 
+(defun slime-macroexpand-again ()
+  "Reperform the last macroexpansion."
+  (interactive)
+  (slime-eval-async slime-eval-macroexpand-expression 
+                    (slime-rcurry #'slime-initialize-macroexpansion-buffer
+                                  (current-buffer))))
+
 (defun slime-initialize-macroexpansion-buffer (expansion &optional buffer)
   (pop-to-buffer (or buffer (slime-create-macroexpansion-buffer)))
   (setq buffer-undo-list nil) ; Get rid of undo information from
@@ -5073,25 +5092,11 @@
   (interactive)
   (slime-eval-macroexpand 'swank:swank-compiler-macroexpand-1))
 
-(defun slime-macroexpand-again ()
-  "Reperform the last macroexpansion."
-  (interactive)
-  (slime-eval-async slime-eval-macroexpand-expression 
-                    (slime-rcurry #'slime-initialize-macroexpansion-buffer
-                                  (current-buffer))))
-
-(defun slime-macroexpand-undo (&optional arg)
+(defun slime-format-string-expand ()
+  "Format the format-string at point, and display its expansion."
   (interactive)
-  (flet ((undo-only (arg)
-           ;; Emacs 22.x introduced `undo-only' which works by binding
-           ;; `undo-no-redo' to t. We do it this way so we don't break
-           ;; prior Emacs versions.
-           (let ((undo-no-redo t)) (undo arg))))
-    (let ((inhibit-read-only t))
-      (when (fboundp 'slime-remove-edits)
-        (slime-remove-edits (point-min) (point-max)))
-      (undo-only arg))))
-
+  (slime-eval-macroexpand 'swank:swank-format-string-expand
+                          (slime-string-at-point-or-error)))
 
 ;;;; Subprocess control
 
@@ -8089,8 +8094,18 @@
 
 (defun slime-sexp-at-point-or-error ()
   "Return the sexp at point as a string, othwise signal an error."
-  (or (slime-sexp-at-point)
-      (error "No expression at point.")))
+  (or (slime-sexp-at-point) (error "No expression at point.")))
+
+(defun slime-string-at-point ()
+  "Returns the string at point as a string, otherwise nil."
+  (let ((sexp (slime-sexp-at-point)))
+    (if (eql (char-syntax (aref sexp 0)) ?\")
+        sexp
+        nil)))
+
+(defun slime-string-at-point-or-error ()
+  "Return the sexp at point as a string, othwise signal an error."
+  (or (slime-string-at-point) (error "No string at point.")))
 
 (defun slime-input-complete-p (start end)
   "Return t if the region from START to END contains a complete sexp."
--- /project/slime/cvsroot/slime/swank-backend.lisp	2009/02/14 12:33:28	1.172
+++ /project/slime/cvsroot/slime/swank-backend.lisp	2009/02/22 14:18:47	1.173
@@ -581,6 +581,10 @@
 		   (values new-form expanded)))))
     (frob form env)))
 
+(definterface format-string-expand (control-string)
+  "Expand the format string CONTROL-STRING."
+  (macroexpand `(formatter ,control-string)))
+
 (definterface describe-symbol-for-emacs (symbol)
    "Return a property list describing SYMBOL.
 
--- /project/slime/cvsroot/slime/swank.lisp	2009/02/17 09:03:41	1.635
+++ /project/slime/cvsroot/slime/swank.lisp	2009/02/22 14:18:47	1.636
@@ -2895,6 +2895,9 @@
 (defslimefun swank-compiler-macroexpand (string)
   (apply-macro-expander #'compiler-macroexpand string))
 
+(defslimefun swank-format-string-expand (string)
+  (apply-macro-expander #'format-string-expand string))
+
 (defslimefun disassemble-symbol (name)
   (with-buffer-syntax ()
     (with-output-to-string (*standard-output*)





More information about the slime-cvs mailing list