Skip to content

Commit 46eb6f9

Browse files
committed
lispy.el: no need to "xv" twice to move test overlay
* lispy-inline.el (lispy--show): Set `last-point' property of `lispy-overlay'. * lispy.el (lispy-view-test): Works only from "|(should (string=". When the point has moved from the last invocation, just move the overlay and update it appropriately instead of just hiding it.
1 parent 8463221 commit 46eb6f9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lispy-inline.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ Return t if at least one was deleted."
227227

228228
(defun lispy--show (str)
229229
"Show STR hint when `lispy--show-fits-p' is t."
230-
(let ((strs (lispy--show-fits-p str)))
230+
(let ((last-point (point))
231+
(strs (lispy--show-fits-p str)))
231232
(when strs
232233
(setq str (lispy--join-pad
233234
strs
@@ -249,7 +250,8 @@ Return t if at least one was deleted."
249250
(setq lispy-overlay (make-overlay (point) (+ (point) 1)))
250251
(overlay-put lispy-overlay 'priority 9999))
251252
(overlay-put lispy-overlay 'display str)
252-
(overlay-put lispy-overlay 'after-string ""))
253+
(overlay-put lispy-overlay 'after-string "")
254+
(put 'lispy-overlay 'last-point last-point))
253255
t)))
254256

255257
(defun lispy--pretty-args (symbol)

lispy.el

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,17 +3245,16 @@ If the region is active, replace instead of yanking."
32453245
(defun lispy-view-test ()
32463246
"View better the test at point."
32473247
(interactive)
3248-
(cond ((overlayp lispy-overlay)
3248+
(cond ((and (overlayp lispy-overlay)
3249+
(eq (point) (get 'lispy-overlay 'last-point)))
32493250
(delete-overlay lispy-overlay)
32503251
(setq lispy-overlay nil))
32513252

3252-
((or (looking-at "(string=")
3253-
(looking-at "(should"))
3253+
3254+
3255+
((looking-at "(should (string=")
32543256
(setq lispy-hint-pos (point))
3255-
(let* ((expr (read (lispy--string-dwim)))
3256-
(expr (if (eq (car expr) 'should)
3257-
(cadr expr)
3258-
expr))
3257+
(let* ((expr (cadr (read (lispy--string-dwim))))
32593258
(str1 (cadr (cadr expr)))
32603259
(str2 (caddr expr))
32613260
(keys (cddadr expr))
@@ -3269,7 +3268,7 @@ If the region is active, replace instead of yanking."
32693268
(propertize str2 'face 'lispy-face-hint)))))
32703269

32713270
(t
3272-
(user-error "Should position point before (string="))))
3271+
(lispy-complain "should position point before (should (string="))))
32733272

32743273
;;* Predicates
32753274
(defun lispy--in-string-p ()

0 commit comments

Comments
 (0)