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

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

[elpa] externals/lentic 7b75e8079c 276/333: Regularisation of start/stop


From: ELPA Syncer
Subject: [elpa] externals/lentic 7b75e8079c 276/333: Regularisation of start/stop handling.
Date: Tue, 27 Feb 2024 13:00:44 -0500 (EST)

branch: externals/lentic
commit 7b75e8079c23abcf228144d81f66018ee5b87ada
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    Regularisation of start/stop handling.
    
    All configurations now use the same regexp to identify the start and
    stop of comment sections, with optional comment block, and anchored to
    the start of the line.
    
    Previously, I had three different regexps with different variations of
    anchors and groups. Nasty.
    
    The anchoring should prevent spurious matches to source blocks (occuring
    in strings, for example, in org-mode source buffers).
    
    Closes issue #36.
---
 dev-resources/string-src-block.el  |  6 ++++++
 dev-resources/string-src-block.org |  6 ++++++
 examples/string-src-block.el       | 12 ++++++++++++
 lentic-chunk.el                    | 31 ++++---------------------------
 test/lentic-test.el                | 12 ++++++++++++
 5 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/dev-resources/string-src-block.el 
b/dev-resources/string-src-block.el
new file mode 100644
index 0000000000..a844944cb1
--- /dev/null
+++ b/dev-resources/string-src-block.el
@@ -0,0 +1,6 @@
+;; #+begin_src emacs-lisp
+(setq org-structure-template-alist
+      (quote (("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")
+              ("e" "#+begin_example\n?\n#+end_example" 
"<example>\n?\n</example>")
+              ("I" "#+include %file ?" "<include file=%file markup=\"?\">"))))
+;; #+end_src
diff --git a/dev-resources/string-src-block.org 
b/dev-resources/string-src-block.org
new file mode 100644
index 0000000000..b93e7f5733
--- /dev/null
+++ b/dev-resources/string-src-block.org
@@ -0,0 +1,6 @@
+#+begin_src emacs-lisp
+(setq org-structure-template-alist
+      (quote (("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")
+              ("e" "#+begin_example\n?\n#+end_example" 
"<example>\n?\n</example>")
+              ("I" "#+include %file ?" "<include file=%file markup=\"?\">"))))
+#+end_src
diff --git a/examples/string-src-block.el b/examples/string-src-block.el
new file mode 100644
index 0000000000..6804e0dc08
--- /dev/null
+++ b/examples/string-src-block.el
@@ -0,0 +1,12 @@
+;;; lentic_test --- testing it
+
+;; #+begin_src emacs-lisp
+(setq org-structure-template-alist
+      (quote (("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")
+               ("e" "#+begin_example\n?\n#+end_example" 
"<example>\n?\n</example>")
+               ("I" "#+include %file ?" "<include file=%file markup=\"?\">"))))
+;; #+end_src
+
+;; # Local Variables:
+;; # lentic-init: lentic-org-orgel-init
+;; # End:
diff --git a/lentic-chunk.el b/lentic-chunk.el
index f34c2fcfb4..c5e8092617 100644
--- a/lentic-chunk.el
+++ b/lentic-chunk.el
@@ -92,17 +92,15 @@ start of line chunk comment in one buffer but not the 
other."
 (defmethod lentic-chunk-comment-start-regexp
   ((conf lentic-chunk-configuration))
   ;; todo -- what does this regexp do?
-  (format "^\\(%s\\)*%s"
+  (format "^\\(%s\\)?%s"
           (oref conf :comment)
-          (regexp-quote
-           (oref conf :comment-start))))
+          (oref conf :comment-start)))
 
 (defmethod lentic-chunk-comment-stop-regexp
   ((conf lentic-chunk-configuration))
-  (format "^\\(%s\\)*%s"
+  (format "^\\(%s\\)?%s"
           (oref conf :comment)
-          (regexp-quote
-           (oref conf :comment-stop))))
+          (oref conf :comment-stop)))
 
 (defmethod lentic-chunk-line-start-comment
   ((conf lentic-chunk-configuration))
@@ -410,18 +408,6 @@ between the two buffers; we don't care which one has 
comments."
    :comment-start (oref conf :comment-start)
    :comment-stop (oref conf :comment-stop)))
 
-(defmethod lentic-chunk-comment-start-regexp
-  ((conf lentic-commented-chunk-configuration))
-  (concat
-   "\\(" (regexp-quote (oref conf :comment)) "\\)?"
-   (oref conf :comment-start)))
-
-(defmethod lentic-chunk-comment-stop-regexp
-  ((conf lentic-commented-chunk-configuration))
-  (concat
-   "\\(" (regexp-quote (oref conf :comment)) "\\)?"
-   (oref conf :comment-stop)))
-
 (defmethod lentic-clone
   ((conf lentic-uncommented-chunk-configuration)
    &optional start stop length-before start-converted stop-converted)
@@ -505,15 +491,6 @@ between the two buffers; we don't care which one has 
comments."
    :comment-start (oref  conf :comment-start)
    :comment-stop (oref conf :comment-stop)))
 
-(defmethod lentic-chunk-comment-start-regexp
-  ((conf lentic-uncommented-chunk-configuration))
-  (oref conf :comment-start))
-
-(defmethod lentic-chunk-comment-stop-regexp
-  ((conf lentic-uncommented-chunk-configuration))
-  (oref conf :comment-stop))
-
-
 ;; #+end_src
 
 ;; ** Unmatched Chunk Configuration
diff --git a/test/lentic-test.el b/test/lentic-test.el
index 5b281c84e3..0fe68dd5d0 100644
--- a/test/lentic-test.el
+++ b/test/lentic-test.el
@@ -180,6 +180,18 @@ Addresses issue #19."
     'lentic-orgel-org-init
     "orgel-org-with-tags.el" "orgel-org-with-tags.org")))
 
+(ert-deftest lentic-orgel-org-with-inline-delimitor()
+  "Test that stringed or otherwise not at the start of
+line delimitors are not detected.
+
+Addresses issue #36."
+  (should
+   (lentic-test-clone-equal
+    'lentic-org-orgel-init
+    "string-src-block.org"
+    "string-src-block.el")))
+
+
 (ert-deftest lentic-org-clojure ()
   (should
    (lentic-test-clone-equal



reply via email to

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