emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/adoc-mode 2578d9a6c3 191/199: Addresses #33. Re-structure


From: ELPA Syncer
Subject: [nongnu] elpa/adoc-mode 2578d9a6c3 191/199: Addresses #33. Re-structure also `adoc-kw-replacement`.
Date: Sun, 3 Sep 2023 06:59:45 -0400 (EDT)

branch: elpa/adoc-mode
commit 2578d9a6c360b5cb31a22703412e0d25e14f9d17
Author: Tobias Zawada <TOZ@esi-group.com>
Commit: TobiasZawada <i@tn-home.de>

    Addresses #33. Re-structure also `adoc-kw-replacement`.
    
    Also add ert test for keyword-replacement
---
 adoc-mode.el           | 21 ++++++++-------------
 test/adoc-mode-test.el | 17 +++++++++++++++++
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/adoc-mode.el b/adoc-mode.el
index d2a5d9697e..aba1a8d4e6 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -1901,18 +1901,13 @@ meta characters."
   `(list
     ;; matcher function
     (lambda (end)
-      (let ((found t) (prevented t) saved-point)
-        (while (and found prevented)
-          (setq saved-point (point))
-          (setq found
-                (adoc-kwf-search ,regexp end t))
-          (setq prevented ; prevented is only meaningful wenn found is non-nil
-                (or
-                 (not found) ; the following is only needed when found
-                 (text-property-not-all (match-beginning 1) (match-end 1) 
'adoc-reserved nil)))
-          (when (and found prevented)
-            (goto-char (+ saved-point 1))))
-        (when (and found (not prevented) adoc-insert-replacement ,replacement)
+      (let (found)
+        (while (and (setq found
+                          (adoc-kwf-search ,regexp end t))
+                    (text-property-not-all (match-beginning 1) (match-end 1) 
'adoc-reserved nil))
+          (setq found nil)
+          (goto-char (+ (match-beginning 0) 1)))
+        (when (and found adoc-insert-replacement ,replacement)
           (let* ((s (cond
                      ((stringp ,replacement)
                       ,replacement)
@@ -1924,7 +1919,7 @@ meta characters."
             (setq adoc-replacement-failed (not o))
             (unless adoc-replacement-failed
               (overlay-put o 'after-string s))))
-        (and found (not prevented))))
+        found))
 
     ;; highlighers
     ;; TODO: replacement instead warining face if resolver is not given
diff --git a/test/adoc-mode-test.el b/test/adoc-mode-test.el
index c6b1d3e272..d20ced6390 100644
--- a/test/adoc-mode-test.el
+++ b/test/adoc-mode-test.el
@@ -1026,6 +1026,23 @@ Don't use it for anything real.")
            (cons "sub chapter 2.1" 262)))))
     (kill-buffer "adoc-test")))
 
+(ert-deftest adoctest-adoc-kw-replacement ()
+  (unwind-protect
+      (progn
+       (set-buffer (get-buffer-create "adoc-test"))
+       (erase-buffer)
+       (adoc-mode)
+       (let ((adoc-insert-replacement t))
+         (adoc-calc)
+         (insert "(C)")
+         (font-lock-flush)
+         (font-lock-ensure)
+         (should (string-equal (overlay-get (car (overlays-in (point) 
(point-max))) 'after-string) "©"))
+         )
+       )
+    (adoc-calc)
+    (kill-buffer "adoc-test")))
+
 ;; purpose
 ;; - ensure that the latest version, i.e. the one currently in buffer(s), of
 ;;   adoc-mode and adoc-mode-test is used for the test



reply via email to

[Prev in Thread] Current Thread [Next in Thread]