Ihor Radchenko writes:
We should probably reserve the workaround to Emacs 28 and older and
eventually remove it when Org drops Emacs 28 support.

Ok.

I tested using Emacs 28 and 27 and your patch is passing all the tests.

Thanks.

--
Sébastien Miquel
From 6ea37a3041fb3266e94af0bfce29aa76f6c4439d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miq...@posteo.eu>
Date: Fri, 7 Jul 2023 13:58:17 +0200
Subject: [PATCH] test-org-src.el: Work around `current-column' bug in older
 emacs

* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Work
around `current-column' not working in the presence of display strings
in older emacs.
---
 testing/lisp/test-org-src.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
index a634d85e8..ebf8d8569 100644
--- a/testing/lisp/test-org-src.el
+++ b/testing/lisp/test-org-src.el
@@ -416,7 +416,13 @@ This is a tab:\t.
      (let ((org-edit-src-content-indentation 2)
 	   (org-src-preserve-indentation nil))
        (font-lock-ensure)
-       (current-column)))))
+       ;;  `current-column' will not work with older versions of emacs
+       ;; before commit 4243747b1b8: Fix 'current-column' in the
+       ;; presence of display strings
+       (if (<= emacs-major-version 28)
+           (+ (progn (backward-char) (length (get-text-property (point) 'display)))
+              (current-column))
+         (current-column))))))
   ;; The initial tab characters respect org's `tab-width'.
   (should
    (equal
@@ -432,7 +438,10 @@ This is a tab:\t.
      (let ((org-edit-src-content-indentation 2)
 	   (org-src-preserve-indentation nil))
        (font-lock-ensure)
-       (current-column))))))
+       (if (<= emacs-major-version 28)
+           (+ (progn (backward-char) (length (get-text-property (point) 'display)))
+              (current-column))
+         (current-column)))))))
 
 (ert-deftest test-org-src/indented-latex-fragments ()
   "Test editing multiline indented LaTeX fragment."
-- 
2.41.0

Reply via email to