@@ -230,6 +230,17 @@ The hint will consist of the possible nouns that apply to the verb."
230
230
" Face for Elisp commands."
231
231
:group 'lispy-faces )
232
232
233
+ (defface lispy-test-face
234
+ '((t (:background " #f8f2ac" )))
235
+ " Face for `lispy-view-test' ."
236
+ :group 'lispy-faces )
237
+
238
+ (defface lispy-cursor-face
239
+ '((t
240
+ (:background " #000000" :foreground " #ffffff" )))
241
+ " Face for `lispy-view-test' ."
242
+ :group 'lispy-faces )
243
+
233
244
(defface lispy-occur-face
234
245
'((t (:background " #CECEFF" )))
235
246
" Face for `lispy-occur' matches."
@@ -3242,6 +3253,82 @@ If the region is active, replace instead of yanking."
3242
3253
(looking-at lispy-left))
3243
3254
(insert " " ))))
3244
3255
3256
+ (defun lispy--fontify (str )
3257
+ " Return STR fontified in `emacs-lisp-mode' "
3258
+ (with-temp-buffer
3259
+ (emacs-lisp-mode )
3260
+ (show-paren-mode )
3261
+ (insert str)
3262
+ (font-lock-fontify-buffer )
3263
+ (let ((color-paren (face-attribute 'show-paren-match :background ))
3264
+ (color-cursor-fg (face-attribute 'lispy-cursor-face :foreground ))
3265
+ (color-cursor-bg (face-attribute 'lispy-cursor-face :background ))
3266
+ pt mk p1 p2)
3267
+ (goto-char (point-min ))
3268
+ (when (search-forward " |" nil t )
3269
+ (backward-delete-char 1 )
3270
+ (setq pt (point ))
3271
+ (when (eolp )
3272
+ (insert " " )))
3273
+ (goto-char (point-min ))
3274
+ (when (search-forward " ~" nil t )
3275
+ (backward-delete-char 1 )
3276
+ (setq mk (point ))
3277
+ (when (< mk pt)
3278
+ (decf pt)))
3279
+ (goto-char pt)
3280
+ (cond ((looking-back lispy-right)
3281
+ (setq p2 (1- (point )))
3282
+ (lispy-different)
3283
+ (setq p1 (point )))
3284
+ ((looking-at lispy-left)
3285
+ (setq p1 (point ))
3286
+ (lispy-different)
3287
+ (setq p2 (1- (point )))))
3288
+ (setq str (buffer-string ))
3289
+ (add-face-text-property 0 (length str) '(face 'lispy-test-face ) t str)
3290
+ (when pt
3291
+ (when mk
3292
+ (if (< mk pt)
3293
+ (progn
3294
+ (add-text-properties (1- mk) (1- pt) '(face region ) str)
3295
+ (set-text-properties (1- pt) pt '(face lispy-cursor-face) str))
3296
+ (add-text-properties (1- (min pt mk)) (1- (max pt mk)) '(face region ) str)
3297
+ (set-text-properties (1- pt) pt '(face lispy-cursor-face) str)))
3298
+ (when p1
3299
+ (add-text-properties
3300
+ (1- p1) p1
3301
+ `(face (:background
3302
+ , color-paren
3303
+ :foreground
3304
+ ,(if (and mk
3305
+ (>= p1 (min pt mk))
3306
+ (<= p1 (max pt mk)))
3307
+ color-cursor-fg
3308
+ color-cursor-bg))) str))
3309
+ (when p2
3310
+ (add-text-properties
3311
+ (1- p2) p2
3312
+ `(face (:background
3313
+ , color-paren
3314
+ :foreground
3315
+ ,(if (and mk
3316
+ (>= p2 (min pt mk))
3317
+ (<= p2 (max pt mk)))
3318
+ color-cursor-fg
3319
+ color-cursor-bg)))
3320
+ str))
3321
+ (add-text-properties
3322
+ (1- pt) pt
3323
+ `(face (:background
3324
+ , color-cursor-bg
3325
+ :foreground
3326
+ ,(if (eq pt p1)
3327
+ color-paren
3328
+ color-cursor-fg)))
3329
+ str)
3330
+ str))))
3331
+
3245
3332
(defun lispy-view-test ()
3246
3333
" View better the test at point."
3247
3334
(interactive )
@@ -3250,8 +3337,6 @@ If the region is active, replace instead of yanking."
3250
3337
(delete-overlay lispy-overlay)
3251
3338
(setq lispy-overlay nil ))
3252
3339
3253
-
3254
-
3255
3340
((looking-at " (should (string=" )
3256
3341
(setq lispy-hint-pos (point ))
3257
3342
(let* ((expr (cadr (read (lispy--string-dwim))))
@@ -3261,11 +3346,13 @@ If the region is active, replace instead of yanking."
3261
3346
(sep (make-string (- (window-width )
3262
3347
(current-column )) ?- )))
3263
3348
(lispy--show
3264
- (concat (propertize str1 'face 'lispy-face-hint)
3349
+ (concat " \n "
3350
+ (lispy--fontify str1)
3265
3351
" \n " sep " \n "
3266
3352
(substring (prin1-to-string keys) 1 -1 )
3267
3353
" \n " sep " \n "
3268
- (propertize str2 'face 'lispy-face-hint)))))
3354
+ (lispy--fontify str2)
3355
+ " \n " ))))
3269
3356
3270
3357
(t
3271
3358
(lispy-complain " should position point before (should (string=" ))))
0 commit comments