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

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

[elpa] externals/lentic a1775e7f70 135/333: Specialised first and header


From: ELPA Syncer
Subject: [elpa] externals/lentic a1775e7f70 135/333: Specialised first and header line handling for orgel.
Date: Tue, 27 Feb 2024 13:00:18 -0500 (EST)

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

    Specialised first and header line handling for orgel.
---
 lentic-org.el | 109 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 83 insertions(+), 26 deletions(-)

diff --git a/lentic-org.el b/lentic-org.el
index 12015f8eab..a0cedbc74d 100644
--- a/lentic-org.el
+++ b/lentic-org.el
@@ -37,6 +37,7 @@
 ;; #+BEGIN_SRC emacs-lisp
 (require 'cl-lib)
 (require 'lentic-block)
+(require 'm-buffer-at)
 ;; #+END_SRC
 
 
@@ -219,33 +220,89 @@
   ;; so, this needs to be more complex -- if we include the first line, expand
   ;; to all of the first line, I think. This should leave the first line in a
   ;; consistent state
-  (call-next-method conf start stop length-before
-                    start-converted stop-converted)
   (m-buffer-with-markers
-      ((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")))
+      ((first-line
+        (m-buffer-match-first-line
+         (lentic-this conf)))
+       (header-one-line
+        (m-buffer-match
+          (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
+    (let*
+        ((start-in-special
+          (when
+              (and
+               start
+               (m-buffer-in-match-p
+                special-lines start))
+            (m-buffer-at-line-beginning-position
+             (lentic-this conf)
+             start)))
+         (start (or start-in-special start))
+         (start-converted
+          (if start-in-special
+              (m-buffer-at-line-beginning-position
+               (lentic-that conf)
+               start-converted)
+            start-converted))
+         (stop-in-special
+          (when
+              (and
+               stop
+               (m-buffer-in-match-p
+                special-lines stop))
+            (m-buffer-at-line-end-position
+             (lentic-this conf)
+             stop)))
+         (stop (or stop-in-special stop))
+         (stop-converted
+          (if stop-in-special
+              (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")))))
+
+(defmethod lentic-convert
+  ((conf lentic-org-to-orgel-configuration)
+   location)
+  (let ((converted (call-next-method conf location)))
+    (m-buffer-with-current-position
+        (oref conf :this-buffer)
+        location
+      (beginning-of-line)
+      (if (looking-at "[*] \\w*$")
+          (- converted 1)
+        converted))))
 
 (defmethod lentic-invert
   ((conf lentic-org-to-orgel-configuration))



reply via email to

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