@@ -3290,7 +3290,7 @@ indented the same amount."
3290
3290
3291
3291
(defmacro markdown-temp-eww (&rest body )
3292
3292
`(progn
3293
- ,@(if (require ' eww nil t ) body
3293
+ ,@(if (markdown-live-preview-has- eww-p ) body
3294
3294
`((ad-enable-advice #'markdown-live-preview-window-eww
3295
3295
'around 'markdown-create-fake-eww )
3296
3296
(ad-activate #'markdown-live-preview-window-eww )
@@ -3324,7 +3324,7 @@ indented the same amount."
3324
3324
3325
3325
(ert-deftest test-markdown-ext/live-preview-exports-sync ()
3326
3326
(let ((markdown-live-preview-do-sync t ))
3327
- (unless (require ' eww nil t )
3327
+ (unless (markdown-live-preview-has- eww-p )
3328
3328
(should-error (markdown-live-preview-sync-export)))
3329
3329
(markdown-test/live-preview-exports)))
3330
3330
@@ -3370,13 +3370,27 @@ indented the same amount."
3370
3370
(setq markdown-test-hit-advice t )
3371
3371
(should (eq (selected-window ) markdown-test-eww-window)))
3372
3372
3373
+ (defadvice get-buffer-create (before markdown-set-window-width-mock disable)
3374
+ (when (let ((buf (ad-get-arg 0 ))) (and (stringp buf) (string= buf " *eww*" )))
3375
+ (setq markdown-test-hit-advice t )
3376
+ (should (eq (selected-window ) markdown-test-eww-window))))
3377
+
3373
3378
(defmacro markdown-eww-open-file-advice (&rest body )
3374
- `(progn
3375
- (ad-enable-advice #'eww-open-file 'before 'markdown-set-window-width )
3376
- (ad-activate #'eww-open-file )
3377
- ,@body
3378
- (ad-disable-advice #'eww-open-file 'before 'markdown-set-window-width )
3379
- (ad-activate #'eww-open-file )))
3379
+ (if (markdown-live-preview-has-eww-p)
3380
+ `(progn
3381
+ (ad-enable-advice #'eww-open-file 'before 'markdown-set-window-width )
3382
+ (ad-activate #'eww-open-file )
3383
+ ,@body
3384
+ (ad-disable-advice #'eww-open-file 'before 'markdown-set-window-width )
3385
+ (ad-activate #'eww-open-file ))
3386
+ `(progn
3387
+ (ad-enable-advice #'get-buffer-create 'before
3388
+ 'markdown-set-window-width-mock )
3389
+ (ad-activate #'get-buffer-create )
3390
+ ,@body
3391
+ (ad-disable-advice #'get-buffer-create 'before
3392
+ 'markdown-set-window-width-mock )
3393
+ (ad-activate #'get-buffer-create ))))
3380
3394
3381
3395
(defun markdown-test/test-window-size-eww ()
3382
3396
(setq markdown-test-hit-advice nil )
@@ -3401,7 +3415,6 @@ indented the same amount."
3401
3415
(markdown-live-preview-sync-export)
3402
3416
(markdown-live-preview-async-export))
3403
3417
(markdown-test/live-preview-wait)
3404
- (sit-for .1 )
3405
3418
; ; at this point, `eww-render' should have finished, and eww should
3406
3419
; ; have redisplayed. the advice checks that, since there was a
3407
3420
; ; single window displaying the *eww* buffer, that window was used
0 commit comments