From 3f44db4f7be24c6daacad0956f019610aeb5f868 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 13 May 2026 06:32:08 -0500 Subject: fix(calibredb-epub): point cj/nov--file-path at nov-file-name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fallback chain was checking `nov-epub-filename` and `nov-epub-file`, but neither symbol exists in nov.el — the real var is `nov-file-name`, set by `nov-mode` from the visited file. Both `boundp` arms always returned nil, so the fallbacks were dead code. The bug was dormant rather than active: `buffer-file-name` always holds the EPUB path for normal nov buffers and covered the first arm of the `or`. I replaced both wrong-named arms with a single live arm on `nov-file-name`, and added a Boundary test that exercises it. --- tests/test-calibredb-epub-config.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/test-calibredb-epub-config.el b/tests/test-calibredb-epub-config.el index 34f4f49a5..48d638358 100644 --- a/tests/test-calibredb-epub-config.el +++ b/tests/test-calibredb-epub-config.el @@ -373,6 +373,15 @@ result is a plain string that the jump-to-calibredb query can interpolate." (setq buffer-file-name "/tmp/sample.epub") (should (equal "/tmp/sample.epub" (cj/nov--file-path))))) +(ert-deftest test-calibredb-epub-file-path-falls-back-to-nov-file-name () + "Boundary: in `nov-mode' with no `buffer-file-name', the helper falls back +to nov.el's own `nov-file-name' (set by `nov-mode' from the visited file)." + (with-temp-buffer + (setq-local major-mode 'nov-mode) + (setq buffer-file-name nil) + (setq-local nov-file-name "/tmp/sample.epub") + (should (equal "/tmp/sample.epub" (cj/nov--file-path))))) + (ert-deftest test-calibredb-epub-file-path-returns-nil-outside-nov-mode () "Error: outside `nov-mode' the helper returns nil regardless of file name." (with-temp-buffer -- cgit v1.2.3