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

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

[elpa] externals/lentic 0b8b94003d 214/333: Multiple buffer support for


From: ELPA Syncer
Subject: [elpa] externals/lentic 0b8b94003d 214/333: Multiple buffer support for org/orgel.
Date: Tue, 27 Feb 2024 13:00:36 -0500 (EST)

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

    Multiple buffer support for org/orgel.
    
    The return values for the org/orgel lentic-clone implementations now
    obey the new interfaces enabling multiple buffers.
---
 .gitignore                  |   1 +
 examples/multi-orgel-org.el |  22 +++++++++
 lentic-block.el             |   4 +-
 lentic-org.el               | 107 +++++++++++++++++++++++++-------------------
 test/lentic-test.el         |   2 +-
 5 files changed, 88 insertions(+), 48 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1ea7cb9a47..b70a755da7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,4 +24,5 @@ auto
 /examples/clj-adoc.adoc
 /examples/owl.tex
 /examples/literate-haskell.tex
+/examples/multi-orgel-org.org
 Makefile-local
\ No newline at end of file
diff --git a/examples/multi-orgel-org.el b/examples/multi-orgel-org.el
new file mode 100644
index 0000000000..58ee4b1481
--- /dev/null
+++ b/examples/multi-orgel-org.el
@@ -0,0 +1,22 @@
+;;; orgel-org.el --- A test file -*- lexical-binding: t -*-
+
+;; Author: Phillip Lord
+
+;;; Commentary:
+
+;; This is an "orgel" file. That is a valid emacs lisp file with comments in
+;; org-mode. The header comments are translated into header one in org mode.
+
+
+;; #+BEGIN_SRC emacs-lisp
+(defun orgel-function ())
+;; #+END_SRC
+
+;; ThisAnd we finish off with the local variables declaration. And here we 
write
+;; some osome more stuff
+
+;; Well
+
+;; # Local Variables:
+;; # lentic-init: (lentic-orgel-org-init lentic-default-init)
+;; # End:
diff --git a/lentic-block.el b/lentic-block.el
index 06b4ca648a..c9cbaf5847 100644
--- a/lentic-block.el
+++ b/lentic-block.el
@@ -419,8 +419,8 @@ between the two buffers; we don't care which one has 
comments."
                            (when start-at-bolp
                              "start")))
     (let* ((clone-return
-           (call-next-method conf start stop length-before
-                             start-converted stop-converted))
+            (call-next-method conf start stop length-before
+                              start-converted stop-converted))
            (clone-return
             (unless start-at-bolp
               clone-return)))
diff --git a/lentic-org.el b/lentic-org.el
index e666e1e269..5c8d572be2 100644
--- a/lentic-org.el
+++ b/lentic-org.el
@@ -219,9 +219,9 @@
          (lentic-this conf)))
        (header-one-line
         (m-buffer-match
-          (lentic-this conf)
-          "^[*] \\(\\w*\\)$"
-          :begin (cl-cadar first-line)))
+         (lentic-this conf)
+         "^[*] \\(\\w*\\)$"
+         :begin (cl-cadar first-line)))
        (special-lines
         (-concat first-line header-one-line)))
     ;; check whether we are in a special line -- if so widen the change extent
@@ -257,33 +257,41 @@
               (m-buffer-at-line-end-position
                (lentic-that conf)
                stop-converted)
-            stop-converted)))
-      (call-next-method conf start stop length-before
-                        start-converted stop-converted)
-      (let ((first-line-end-match
-             (cl-cadar
-              (m-buffer-match-first-line
-               (lentic-that conf)))))
-        (m-buffer-replace-match
-         (m-buffer-match
-          (lentic-that conf)
-          ;; we can be in one of two states depending on whether we have made 
a new
-          ;; clone or an incremental change
-          "^;; \\(;;;\\|# #\\)"
-          :end first-line-end-match)
-         ";;;")
-        ;; replace big headers, in either of their two states
-        (m-buffer-replace-match
-         (m-buffer-match
-          (lentic-that conf)
-          "^;; [*] \\(\\w*\\)$"
-          :begin first-line-end-match)
-         ";;; \\1:")
-        (m-buffer-replace-match
-         (m-buffer-match (lentic-that conf)
-                         "^;; ;;; \\(\\w*:\\)$"
-                         :begin first-line-end-match)
-         ";;; \\1")))))
+            stop-converted))
+         (clone-return
+          (call-next-method conf start stop length-before
+                            start-converted stop-converted))
+         (first-line-end-match
+          (cl-cadar
+           (m-buffer-match-first-line
+            (lentic-that conf))))
+         ;; can't just use or here because we need non-short circuiting
+         (c1
+          (m-buffer-replace-match
+           (m-buffer-match
+            (lentic-that conf)
+            ;; we can be in one of two states depending on whether we have 
made a new
+            ;; clone or an incremental change
+            "^;; \\(;;;\\|# #\\)"
+            :end first-line-end-match)
+           ";;;"))
+         ;; replace big headers, in either of their two states
+         (c2
+          (m-buffer-replace-match
+           (m-buffer-match
+            (lentic-that conf)
+            "^;; [*] \\(\\w*\\)$"
+            :begin first-line-end-match)
+           ";;; \\1:"))
+         (c3
+          (m-buffer-replace-match
+           (m-buffer-match (lentic-that conf)
+                           "^;; ;;; \\(\\w*:\\)$"
+                           :begin first-line-end-match)
+           ";;; \\1")))
+      (if (or start-in-special stop-in-special c1 c2 c3)
+          nil
+        clone-return))))
 
 (defmethod lentic-convert
   ((conf lentic-org-to-orgel-configuration)
@@ -335,21 +343,30 @@
   ((conf lentic-orgel-to-org-configuration)
    &optional start stop length-before start-converted stop-converted)
   ;; do everything else to the buffer
-  (call-next-method conf start stop length-before
-                    start-converted stop-converted)
-  (m-buffer-replace-match
-   (m-buffer-match
-    (lentic-that conf)
-    ";;; "
-    :end
-    (cl-cadar
-     (m-buffer-match-first-line
-      (lentic-that conf))))
-   "# # ")
-  (m-buffer-replace-match
-   (m-buffer-match (lentic-that conf)
-                   "^;;; \\(\\\w*\\):")
-   "* \\1"))
+  (let* ((clone-return
+          (call-next-method conf start stop length-before
+                            start-converted stop-converted))
+         (m1
+          (m-buffer-replace-match
+           (m-buffer-match
+            (lentic-that conf)
+            ";;; "
+            :end
+            (cl-cadar
+             (m-buffer-match-first-line
+              (lentic-that conf))))
+           "# # "))
+         (m2
+          (m-buffer-replace-match
+           (m-buffer-match (lentic-that conf)
+                           "^;;; \\(\\\w*\\):")
+           "* \\1")))
+    (unless
+        ;; update some stuff
+        (or m1 m2)
+      ;; and return clone-return unless we have updated stuff in which case
+      ;; return nil
+      clone-return)))
 
 (defmethod lentic-invert
   ((conf lentic-orgel-to-org-configuration))
diff --git a/test/lentic-test.el b/test/lentic-test.el
index 14e8cf2364..784983415e 100644
--- a/test/lentic-test.el
+++ b/test/lentic-test.el
@@ -66,7 +66,7 @@
     (let ((this (get-file-buffer (lentic-test-file file))))
       (when this
         (with-current-buffer this
-          (let ((this (lentic-that (car lentic-config))))
+          (let ((that (lentic-that (car lentic-config))))
             (kill-buffer that)))
         (kill-buffer this)))))
 



reply via email to

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