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

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

[elpa] externals/phpinspect e7b1f22e8c 068/126: Sort tokens by size when


From: ELPA Syncer
Subject: [elpa] externals/phpinspect e7b1f22e8c 068/126: Sort tokens by size when returning tokens around point
Date: Sat, 12 Aug 2023 00:58:45 -0400 (EDT)

branch: externals/phpinspect
commit e7b1f22e8cc6bb5d56ee071682989252be245405
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>

    Sort tokens by size when returning tokens around point
---
 phpinspect-buffer.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/phpinspect-buffer.el b/phpinspect-buffer.el
index 21e9d4e422..43bb87b1f0 100644
--- a/phpinspect-buffer.el
+++ b/phpinspect-buffer.el
@@ -34,6 +34,15 @@ buffer. This variable is only set for buffers where
 (defalias 'phpinspect-region-start #'car)
 (defalias 'phpinspect-region-end #'cadr)
 
+(defsubst phpinspect-region-size (region)
+  (- (phpinspect-region-end region) (phpinspect-region-start region)))
+
+(defsubst phpinspect-region> (reg1 reg2)
+  (> (phpinspect-region-size reg1) (phpinspect-region-size reg2)))
+
+(defsubst phpinspect-region< (reg1 reg2)
+  (< (phpinspect-region-size reg1) (phpinspect-region-size reg2)))
+
 (cl-defstruct (phpinspect-buffer (:constructor phpinspect-make-buffer))
   "An object containing phpinspect related metadata linked to an
 emacs buffer."
@@ -76,6 +85,10 @@ linked with."
                   (>= (phpinspect-region-end region) point))
          (push token tokens)))
      (phpinspect-buffer-location-map buffer))
-    tokens))
+    (sort tokens (lambda (tok1 tok2)
+                   (phpinspect-region< (phpinspect-buffer-token-location tok1)
+                                       (phpinspect-buffer-token-location 
tok2))))))
+
+
 
 (provide 'phpinspect-buffer)



reply via email to

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