emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/macrostep aa4736c 067/110: Fix some silly errors


From: ELPA Syncer
Subject: [nongnu] elpa/macrostep aa4736c 067/110: Fix some silly errors
Date: Sat, 7 Aug 2021 09:18:04 -0400 (EDT)

branch: elpa/macrostep
commit aa4736c06f2159aed421b19b73fe377ffe36cdff
Author: Luís Oliveira <loliveira@common-lisp.net>
Commit: Luís Oliveira <loliveira@common-lisp.net>

    Fix some silly errors
---
 swank-macrostep.lisp | 66 ++++++++++++++++++++++++----------------------------
 1 file changed, 30 insertions(+), 36 deletions(-)

diff --git a/swank-macrostep.lisp b/swank-macrostep.lisp
index d954687..0ca3fba 100644
--- a/swank-macrostep.lisp
+++ b/swank-macrostep.lisp
@@ -17,17 +17,17 @@
            (bindings (mapcar #'read-from-string binding-strings))
            (env (compute-environment bindings))
            (expansion
-            (multiple-value-bind (expansion expanded?)
-                (macroexpand-1 form env)
-              (if expanded?
-                  expansion
-                (if (not compiler-macros?)
-                    (error "Not a macro form.")
-                  (multiple-value-bind (expansion expanded?)
-                      (compiler-macroexpand-1 form env)
-                    (if expanded?
-                        expansion
-                        (error "Not a macro or compiler-macro form.")))))))
+             (multiple-value-bind (expansion expanded?)
+                 (macroexpand-1 form env)
+               (if expanded?
+                   expansion
+                   (if (not compiler-macros?)
+                       (error "Not a macro form.")
+                       (multiple-value-bind (expansion expanded?)
+                           (compiler-macroexpand-1 form env)
+                         (if expanded?
+                             expansion
+                             (error "Not a macro or compiler-macro 
form.")))))))
            (pretty-expansion (to-string expansion)))
       (list pretty-expansion
             (multiple-value-bind (expansion* tracking-stream)
@@ -35,20 +35,21 @@
               (multiple-value-bind (macros compiler-macros)
                   (collect-macro-forms expansion*)
                 (flet ((collect-positions (forms type)
-                         (mapcar (lambda (form)
-                                   (destructuring-bind (start end)
-                                       (cdr (assoc form (forms-of 
tracking-stream)))
-                                     ;; this assumes that the operator
-                                     ;; starts right next to the opening
-                                     ;; parenthesis. I guess we could be
-                                     ;; more forgiving with some
-                                     ;; cleverness on the Emacs side.
-                                     (let ((op-end (+ start (length (to-string 
(first form))))))
-                                       (list type
-                                             start (position-line start 
tracking-stream)
-                                             op-end (position-line op-end 
tracking-stream)
-                                             end (position-line end 
tracking-stream)))))
-                                 forms)))
+                         (loop for form in forms
+                               for bounds = (cdr (assoc form (forms-of 
tracking-stream)))
+                               when bounds
+                                 collect (destructuring-bind (start end)
+                                             bounds
+                                           ;; this assumes that the operator
+                                           ;; starts right next to the opening
+                                           ;; parenthesis. I guess we could be
+                                           ;; more forgiving with some
+                                           ;; cleverness on the Emacs side.
+                                           (let ((op-end (+ start (length 
(to-string (first form))))))
+                                             (list type
+                                                   start (position-line start 
tracking-stream)
+                                                   op-end (position-line 
op-end tracking-stream)
+                                                   end (position-line end 
tracking-stream)))))))
                   (append (collect-positions macros :macro)
                           (collect-positions compiler-macros 
:compiler-macro)))))))))
 
@@ -156,18 +157,11 @@
 (defun form-tracking-stream-p (stream)
   (typep stream 'form-tracking-stream))
 
-(defun line-and-column (position tracking-stream)
-  (let* ((line (or (position-if (lambda (newline-pos)
-                                  (> newline-pos position))
-                                (newlines-of tracking-stream))
-                   1))
-         (column (if (eql line 1)
-                     position
-                     (- position (aref (newlines-of tracking-stream) (1- 
line))))))
-    (values line column)))
-
 (defun position-line (position tracking-stream)
-  (nth-value 0 (line-and-column position tracking-stream)))
+  (or (position-if (lambda (newline-pos)
+                     (> newline-pos position))
+                   (newlines-of tracking-stream))
+      (length (newlines-of tracking-stream))))
 
 (defun tracking-read-from-string (string &key (readtable *readtable*))
   (with-input-from-string (string-stream string)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]