Comments (9)
This works fine for me with the latest clojure-mode (and Emacs nightly). How would one reproduce your issue?
from clojure-mode.
Just updates to latest clojure-mode. Still doesn't work.
Consider this test file (opened with clojure-test-mode active)
(ns foo
(:use clojure.test))
(deftest foo
(is (= 42 23)))
When not narrowed, C-, will correctly highlight the last line red. If you narrow the buffer to the deftest (highlight the whole deftest block and type M-x narrow-to-region), and then execute M-x clojure-test-run-tests (C-,), the line doesn't get highlighted red.
from clojure-mode.
Aha, I see what you mean now - thanks. If you narrow to a region containing multiple failing tests, does it only fail to highlight the final test? ie. is it just a problem with the last line in the narrowed region?
from clojure-mode.
No, it fails to highlight all lines. It starts counting lines at the current (point-min). This is a problem in narrowed buffers, as (point-min) is != 0.
Thus, if a test in the 5th line of the file fails, it highlights the 5th line of the buffer, regardless if it's narrowed or now. I'll take a look at it now and probably write a small path if it isn't too complicated.
from clojure-mode.
Fix: Wrap everything in clojure-test-extract-result
in save-restriction
and un-narrow (widen) the buffer before highlighting. The (widen) fixes the line-numbering and save-restriction re-narrows the buffer when the function returns.
Patch:
diff --git a/clojure-test-mode.el b/clojure-test-mode.el
index 3583615..5b77792 100644
--- a/clojure-test-mode.el
+++ b/clojure-test-mode.el
@@ -240,17 +240,19 @@
(defun clojure-test-extract-result (result)
"Parse the result from a single test. May contain multiple is blocks."
- (dolist (is-result (rest result))
- (unless (member (aref is-result 0) clojure-test-ignore-results)
- (incf clojure-test-count)
- (destructuring-bind (event msg expected actual line) (coerce is-result 'list)
- (if (equal :fail event)
- (progn (incf clojure-test-failure-count)
- (clojure-test-highlight-problem
- line event (format "Expected %s, got %s" expected actual)))
- (when (equal :error event)
- (incf clojure-test-error-count)
- (clojure-test-highlight-problem line event actual)))))))
+ (save-restriction
+ (widen)
+ (dolist (is-result (rest result))
+ (unless (member (aref is-result 0) clojure-test-ignore-results)
+ (incf clojure-test-count)
+ (destructuring-bind (event msg expected actual line) (coerce is-result 'list)
+ (if (equal :fail event)
+ (progn (incf clojure-test-failure-count)
+ (clojure-test-highlight-problem
+ line event (format "Expected %s, got %s" expected actual)))
+ (when (equal :error event)
+ (incf clojure-test-error-count)
+ (clojure-test-highlight-problem line event actual))))))))
(defun clojure-test-highlight-problem (line event message)
from clojure-mode.
Does the following also work?
diff --git a/clojure-test-mode.el b/clojure-test-mode.el
index 3583615..1d76d77 100644
--- a/clojure-test-mode.el
+++ b/clojure-test-mode.el
@@ -255,7 +255,7 @@
(defun clojure-test-highlight-problem (line event message)
(save-excursion
- (goto-char (point-min)) (forward-line (1- line))
+ (goto-line line)
(let ((beg (point)))
(end-of-line)
(let ((overlay (make-overlay beg (point))))
from clojure-mode.
Rather than guessing, I set things up to try out my fix, and it seems to do the trick.
from clojure-mode.
Yup, your's seems to work, as well as mine. I wasn't guessing, of course. I tried my patch before submitting as well.
Your patch looks cleaner, though ;-)
from clojure-mode.
I figured you'd tried out your patch, so I thought I'd do you the courtesy of trying out mine. :-)
I've filed a pull request, #37.
from clojure-mode.
Related Issues (20)
- Incorrect syntax highlighting for test name defined with `deftest` HOT 4
- Suggestions not working
- `clojure-find-def` fails on symbols that contain special characters
- Emacs hangs when `clojure-toplevel-inside-comment-form` is `t`, and `comment` is used as a var HOT 5
- Feature: Clojure-mode tree sitter support in Emacs v29 HOT 22
- Support nbb projects
- Infinite loop in `clojure-sort-ns` when sorting a ns with comments
- Suggestion - add additional characters to syntax table to support evil mode word motions HOT 1
- clojure-add-arity severs arglist metadata
- Dedicated lightweight edn-mode? HOT 1
- `clojure-sexp-starts-until-position` can loop forever
- Symbols with colon in the middle get wrong syntax highlighting HOT 1
- An extra form before the ns form, on the same line as the ns form, breaks test detection. HOT 2
- `clojure-mode-display-version` broken HOT 2
- Adaptive fill mode broken in docstring HOT 5
- Derive the mode from prog-mode or lisp-data-mode HOT 3
- Indentation very slow on 20230911.1653 HOT 29
- Use Eldev HOT 1
- Syntax highlighting broken for digits after the first in % args
- `.lpy` extension support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clojure-mode.