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

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

[elpa] externals/lentic 73fe35fa77 023/333: Refactoring to remove code d


From: ELPA Syncer
Subject: [elpa] externals/lentic 73fe35fa77 023/333: Refactoring to remove code duplication.
Date: Tue, 27 Feb 2024 12:59:56 -0500 (EST)

branch: externals/lentic
commit 73fe35fa778e6c9d8f1eaa83a7c3b051cab07e73
Author: Phillip Lord <phillord@haughton.ncl.ac.uk>
Commit: Phillip Lord <phillord@haughton.ncl.ac.uk>

    Refactoring to remove code duplication.
---
 linked-buffer-block.el      | 33 +++++++++++++++++++++------------
 linked-buffer-latex-code.el | 30 ++++++++++++++++++------------
 2 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/linked-buffer-block.el b/linked-buffer-block.el
index 5facad986f..ee08e0c000 100644
--- a/linked-buffer-block.el
+++ b/linked-buffer-block.el
@@ -28,7 +28,6 @@
 ;; line comment characters that the other one lacks. Commented regions may be
 ;; in blocks with block-delimiters between then.
 
-(require 'dash)
 (require 'm-buffer)
 (require 'linked-buffer)
 
@@ -67,14 +66,15 @@ start of line block comment in one buffer but not the 
other."
 
 (defmethod linked-buffer-blk-line-start-comment
   ((conf linked-buffer-block-configuration))
-  (concat "^" (oref conf :comment)))
+  (concat "^" 
+          (oref conf :comment)))
 
 (defun linked-buffer-blk-uncomment-region (conf begin end buffer)
   "Given CONF,  remove start-of-line characters in region.
 Region is between BEGIN and END in BUFFER. CONF is a
 function `linked-buffer-configuration' object."
   (m-buffer-replace-match
-   (m-buffer-match-data
+    (m-buffer-match
     buffer
     (linked-buffer-blk-line-start-comment conf)
     :begin begin :end end) ""))
@@ -93,7 +93,7 @@ BEGIN and END in BUFFER."
   "Given CONF, a `linked-buffer-configuration' object, add
 start of line comment characters beween BEGIN and END in BUFFER."
   (m-buffer-replace-match
-   (m-buffer-match-data
+   (m-buffer-match
     buffer
     ;; perhaps we should ignore lines which are already commented,
     "\\(^\\).+"
@@ -123,14 +123,13 @@ BEGIN and END in BUFFER."
 demarcation markers between BEGIN and END in BUFFER. Returns a
 list of start end cons pairs. BEGIN is considered to be an
 implicit start and END an implicit stop."
-  (let ((match-start
-         (m-buffer-match-begin
-          buffer
-          (linked-buffer-block-comment-start-regexp conf)))
-        (match-end
-         (m-buffer-match-end
-          buffer
-          (linked-buffer-block-comment-stop-regexp conf))))
+  (let* ((match-block
+          (linked-buffer-block-match
+           conf buffer))
+         (match-start
+          (car match-block))
+         (match-end
+          (cadr match-block)))
     (unless
         (= (length match-start)
            (length match-end))
@@ -149,6 +148,16 @@ implicit start and END an implicit stop."
       match-end
       (list (set-marker (make-marker) end buffer))))))
 
+(defmethod linked-buffer-block-match ((conf linked-buffer-block-configuration)
+                                      buffer)
+  (list
+   (m-buffer-match-begin
+    buffer
+    (linked-buffer-block-comment-start-regexp conf))
+   (m-buffer-match-end
+    buffer
+    (linked-buffer-block-comment-stop-regexp conf))))
+
 (defun linked-buffer-pabbrev-expansion-length ()
   "Returns the length of any text that pabbrev has currently added to the 
buffer."
   ;; this *exact* form suppresses byte compiler warnings.
diff --git a/linked-buffer-latex-code.el b/linked-buffer-latex-code.el
index a8e5e27d99..cf4eac1d0a 100644
--- a/linked-buffer-latex-code.el
+++ b/linked-buffer-latex-code.el
@@ -37,18 +37,24 @@
 (require 'linked-buffer-block)
 
 (defun linked-buffer-clojure-latex-init ()
-  (setq linked-buffer-config
-        (linked-buffer-commented-block-configuration
-         "lb-commented"
-         :this-buffer (current-buffer)
-         :linked-mode 'tex-mode
-         :linked-file
-         (concat
-          (file-name-sans-extension
-           (buffer-file-name)) ".tex")
-         :comment ";; "
-         :comment-start "\\\\end{code}"
-         :comment-stop "\\\\begin{code}")))
+  (if
+      (equal
+       "clj"
+       (file-name-extension
+        (buffer-file-name)))
+      (setq linked-buffer-config
+            (linked-buffer-commented-block-configuration
+             "lb-commented clojure latex"
+             :this-buffer (current-buffer)
+             :linked-mode 'tex-mode
+             :linked-file
+             (concat
+              (file-name-sans-extension
+               (buffer-file-name)) ".tex")
+             :comment ";; "
+             :comment-start "\\\\end{code}"
+             :comment-stop "\\\\begin{code}"))
+    (error "Can only use linked-buffer-clojure-latex-init in a .clj buffer")))
 
 (defun linked-buffer-clojure-latex-delayed-init ()
   (linked-buffer-delayed-init 'linked-buffer-clojure-latex-init))



reply via email to

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