@@ -3290,7 +3290,7 @@ indented the same amount."
32903290
32913291(defmacro markdown-temp-eww (&rest body )
32923292 `(progn
3293- ,@(if (require ' eww nil t ) body
3293+ ,@(if (markdown-live-preview-has- eww-p ) body
32943294 `((ad-enable-advice #'markdown-live-preview-window-eww
32953295 'around 'markdown-create-fake-eww )
32963296 (ad-activate #'markdown-live-preview-window-eww )
@@ -3324,7 +3324,7 @@ indented the same amount."
33243324
33253325(ert-deftest test-markdown-ext/live-preview-exports-sync ()
33263326 (let ((markdown-live-preview-do-sync t ))
3327- (unless (require ' eww nil t )
3327+ (unless (markdown-live-preview-has- eww-p )
33283328 (should-error (markdown-live-preview-sync-export)))
33293329 (markdown-test/live-preview-exports)))
33303330
@@ -3370,13 +3370,27 @@ indented the same amount."
33703370 (setq markdown-test-hit-advice t )
33713371 (should (eq (selected-window ) markdown-test-eww-window)))
33723372
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+
33733378(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 ))))
33803394
33813395(defun markdown-test/test-window-size-eww ()
33823396 (setq markdown-test-hit-advice nil )
@@ -3401,7 +3415,6 @@ indented the same amount."
34013415 (markdown-live-preview-sync-export)
34023416 (markdown-live-preview-async-export))
34033417 (markdown-test/live-preview-wait)
3404- (sit-for .1 )
34053418 ; ; at this point, `eww-render' should have finished, and eww should
34063419 ; ; have redisplayed. the advice checks that, since there was a
34073420 ; ; single window displaying the *eww* buffer, that window was used
0 commit comments