[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode b4bff80aa3 1/4: Fix when eww-auto-rename-buf
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode b4bff80aa3 1/4: Fix when eww-auto-rename-buffer is non-nil |
Date: |
Fri, 9 Dec 2022 22:59:11 -0500 (EST) |
branch: elpa/markdown-mode
commit b4bff80aa3bb20f06120b4557add98fa9e16105f
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>
Fix when eww-auto-rename-buffer is non-nil
---
markdown-mode.el | 8 +++++++-
tests/markdown-test.el | 13 +++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/markdown-mode.el b/markdown-mode.el
index 4e59afaf16..256ebdfa76 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7542,7 +7542,13 @@ This is the inverse of `markdown-live-preview-buffer'.")
"Preview FILE with eww.
To be used with `markdown-live-preview-window-function'."
(eww-open-file file)
- (get-buffer "*eww*"))
+ ;; #737 if `eww-auto-rename-buffer' is non-nil, the buffer name is not
"*eww*"
+ ;; Try to find the buffer whose name ends with "eww*"
+ (if (bound-and-true-p eww-auto-rename-buffer)
+ (cl-loop for buf in (buffer-list)
+ when (string-match-p "eww\\*\\'" (buffer-name buf))
+ return buf)
+ (get-buffer "*eww*")))
(defun markdown-visual-lines-between-points (beg end)
(save-excursion
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 780f9cab07..03883cc113 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -33,6 +33,11 @@
(require 'cl-lib)
(require 'ispell)
+(eval-when-compile
+ ;; This is for byte-compile warnings on older Emacs.
+ ;; eww-auto-rename-buffer is introduced at Emacs 29.1
+ (defvar eww-auto-rename-buffer))
+
(defvar electric-pair-pairs)
(defconst markdown-test-dir
@@ -6862,6 +6867,14 @@ Detail:
https://github.com/jrblevin/markdown-mode/pull/590"
(window-start) (window-point))
final-win-st-diff)))))))
+(when (version< "29" emacs-version)
+ (ert-deftest test-markdown-live-preview/eww-auto-rename-buffer ()
+ "Test `eww-auto-rename-buffer' is non-nil.
+Detail: https://github.com/jrblevin/markdown-mode/issues/737"
+ (let ((markdown-command #'markdown-command-identity))
+ (let ((eww-auto-rename-buffer 'title))
+ (should (markdown-live-preview-window-eww "Markdown.md"))))))
+
;;; Tests for imenu
(ert-deftest test-markdown-imenu/metadata ()