From 60b7668b89ff00213dd8f66b54698b6ddecb427b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Simen=20Heggest=C3=B8yl?= Date: Sun, 1 Oct 2017 20:24:55 +0200 Subject: [PATCH] Keep eww buffer current when looking up CSS on MDN * lisp/textmodes/css-mode.el (css-lookup-symbol): Keep the eww buffer current when looking up CSS documentation on MDN. This fixes a bug where the eww buffer's content sometimes get mangled when switching buffers mid-render. --- lisp/textmodes/css-mode.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index ce9bbf47e77..9022ab7c3fb 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1659,14 +1659,13 @@ on what is seen near point." (setq symbol (concat ":" symbol))) (let ((url (format css-lookup-url-format symbol)) (buffer (get-buffer-create "*MDN CSS*"))) - (save-selected-window - ;; Make sure to display the buffer before calling `eww', as - ;; that calls `pop-to-buffer-same-window'. - (switch-to-buffer-other-window buffer) - (with-current-buffer buffer - (eww-mode) - (add-hook 'eww-after-render-hook #'css--mdn-after-render nil t) - (eww url)))))) + ;; Make sure to display the buffer before calling `eww', as that + ;; calls `pop-to-buffer-same-window'. + (switch-to-buffer-other-window buffer) + (with-current-buffer buffer + (eww-mode) + (add-hook 'eww-after-render-hook #'css--mdn-after-render nil t) + (eww url))))) (provide 'css-mode) ;;; css-mode.el ends here -- 2.11.4.GIT