[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 4abbcd4b7f 259/333: Org-mode now support multipl
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 4abbcd4b7f 259/333: Org-mode now support multiple src blocks. |
Date: |
Tue, 27 Feb 2024 13:00:42 -0500 (EST) |
branch: externals/lentic
commit 4abbcd4b7f345e57afba5c93f9bf28b36ec84825
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Org-mode now support multiple src blocks.
Previously, the lentic required matched blocks for "begin_src blah" with
"end_src". This fails if source blocks are used for more than one
language.
Here we add generic support for "unmatched" delimiters, where the close
block is identified as the next one to occur after an open. This also
means that the buffer cannot become invalid.
Closes #12.
---
.gitignore | 6 ++++
Cask | 2 +-
examples/org-el-clj-python.org | 34 +++++++++++++++++++++
examples/orgel-org-with-others.org | 24 +++++++++++++++
lentic-block.el | 50 +++++++++++++++++++++++++++++++
lentic-org.el | 60 ++++++++++++++++++++++++++++++--------
6 files changed, 163 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index 232e5ddc66..d3170465ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,9 @@ auto
Makefile-local
/examples/multi-block-comment.tex
/examples/multi-block-comment-copy.tex
+/examples/org-el-clj-python.clj
+/examples/org-el-clj-python.el
+/examples/org-el-clj-python.py
+/examples/org-python.py
+/examples/many-multi-block-comment-copy.tex
+/dev-resources/asciidoc-clj.clj
diff --git a/Cask b/Cask
index f3a67c6a06..8080df17e9 100644
--- a/Cask
+++ b/Cask
@@ -1,7 +1,7 @@
;; -*- emacs-lisp -*-
(source gnu)
(source marmalade)
-(source melpa-stable)
+(source melpa)
(package-file "lentic.el")
diff --git a/examples/org-el-clj-python.org b/examples/org-el-clj-python.org
new file mode 100644
index 0000000000..a426b465f5
--- /dev/null
+++ b/examples/org-el-clj-python.org
@@ -0,0 +1,34 @@
+
+* Introduction
+
+This file shows hello world in several languages
+
+
+
+
+* Emacs Lisp
+
+#+begin_src emacs-lisp
+(message "hello world")
+#+end_src
+
+* Clojure
+
+#+begin_src clojure
+(print "hello world")
+#+end_src
+
+* Python
+
+#+begin_src python
+print( "hello world" )
+#+end_src
+
+* Footer
+
+
+# Local Variables:
+# lentic-init: (lentic-org-el-init lentic-org-clojure-init
lentic-org-python-init)
+# End:
+
+
diff --git a/examples/orgel-org-with-others.org
b/examples/orgel-org-with-others.org
new file mode 100644
index 0000000000..7fcd4065f6
--- /dev/null
+++ b/examples/orgel-org-with-others.org
@@ -0,0 +1,24 @@
+# # 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.
+
+Now what hapens
+#+begin_src emacs-lisp
+(defun orgel-function ())
+#+end_src
+
+And we finish off with the local variables declaration.
+
+#+begin_src python
+print("This is python")
+#+end_src
+
+
+# Local Variables:
+# lentic-init: lentic-orgel-org-init
+# End:
diff --git a/lentic-block.el b/lentic-block.el
index 6a1095bfe8..f32fb2f46f 100644
--- a/lentic-block.el
+++ b/lentic-block.el
@@ -514,6 +514,56 @@ between the two buffers; we don't care which one has
comments."
((conf lentic-uncommented-block-configuration))
(oref conf :comment-stop))
+(defclass lentic-unmatched-block-configuration ()
+ ()
+ :documentation "Configuration for blocked lentics where the
+markers are not necessarily paired. Instead for every open block
+marker, the next close marker is used, and all others are
+ignored."
+ :abstract t)
+
+(defmethod lentic-blk-marker-boundaries
+ ((conf lentic-unmatched-block-configuration)
+ buffer)
+ "Given CONF, a `lentic-configuration' object, find
+demarcation markers. Returns a list of start end cons pairs.
+`point-min' is considered to be an implicit start and `point-max'
+an implicit stop."
+ (let* ((match-block
+ (lentic-block-match
+ conf buffer))
+ (match-start
+ (car match-block))
+ (match-end
+ (cadr match-block)))
+ (let* ((part
+ (-drop-while
+ (lambda (n)
+ (not (car n)))
+ (m-buffer-partition-by-marker
+ match-start match-end)))
+ (zipped
+ (with-current-buffer buffer
+ (-zip-with
+ #'list
+ (cons (point-min-marker)
+ (-map #'cadr part))
+ (-snoc
+ (-map #'car part)
+ (point-max-marker))))))
+ zipped)))
+
+(defclass lentic-unmatched-commented-block-configuration
+ (lentic-unmatched-block-configuration
+ lentic-commented-block-configuration)
+ ())
+
+(defclass lentic-unmatched-uncommented-block-configuration
+ (lentic-unmatched-block-configuration
+ lentic-uncommented-block-configuration)
+ ())
+
+
(provide 'lentic-block)
;;; lentic-block.el ends here
diff --git a/lentic-org.el b/lentic-org.el
index 6b51a59aa3..a3d24d6d72 100644
--- a/lentic-org.el
+++ b/lentic-org.el
@@ -82,7 +82,7 @@
;;;###autoload
(defun lentic-org-el-init ()
(lentic-org-oset
- (lentic-uncommented-block-configuration
+ (lentic-unmatched-uncommented-block-configuration
"lb-org-to-el"
:lentic-file
(concat
@@ -96,7 +96,7 @@
;;;###autoload
(defun lentic-el-org-init ()
(lentic-org-oset
- (lentic-commented-block-configuration
+ (lentic-unmatched-commented-block-configuration
"lb-el-to-org"
:lentic-file
(concat
@@ -205,7 +205,7 @@
;; #+BEGIN_SRC emacs-lisp
(defclass lentic-org-to-orgel-configuration
- (lentic-uncommented-block-configuration)
+ (lentic-unmatched-block-configuration lentic-uncommented-block-configuration)
())
(defmethod lentic-clone
@@ -334,9 +334,8 @@
;; this.
;; #+BEGIN_SRC emacs-lisp
-
(defclass lentic-orgel-to-org-configuration
- (lentic-commented-block-configuration)
+ (lentic-unmatched-block-configuration lentic-commented-block-configuration)
())
(defmethod lentic-create
@@ -403,7 +402,8 @@
;; #+END_SRC
-;; *** org->clojure
+
+;; ** org->clojure
;; #+BEGIN_SRC emacs-lisp
(defun lentic-org-clojure-oset (conf)
@@ -412,15 +412,12 @@
:this-buffer (current-buffer)
:comment ";; "
:comment-stop "#\\\+BEGIN_SRC clojure"
- :comment-start "#\\\+END_SRC"
- ;; don't ignore case -- so using lower case begin_src
- ;; will be ignored. Probably we should count instead!
- :case-fold-search nil))
+ :comment-start "#\\\+END_SRC"))
;;;###autoload
(defun lentic-org-clojure-init ()
(lentic-org-clojure-oset
- (lentic-uncommented-block-configuration
+ (lentic-unmatched-uncommented-block-configuration
"lb-org-to-clojure"
:lentic-file
(concat
@@ -434,7 +431,7 @@
;;;###autoload
(defun lentic-clojure-org-init ()
(lentic-org-clojure-oset
- (lentic-commented-block-configuration
+ (lentic-unmatched-commented-block-configuration
"lb-clojure-to-org"
:lentic-file
(concat
@@ -446,6 +443,45 @@
'lentic-clojure-org-init)
;; #+END_SRC
+;; ** org->python
+
+;; #+begin_src emacs-lisp
+(defun lentic-org-python-oset (conf)
+ (lentic-m-oset
+ conf
+ :this-buffer (current-buffer)
+ :comment "# "
+ :comment-stop "#\\\+BEGIN_SRC python"
+ :comment-start "#\\\+END_SRC"))
+
+;;;###autoload
+(defun lentic-org-python-init ()
+ (lentic-org-python-oset
+ (lentic-unmatched-uncommented-block-configuration
+ "lb-org-to-python"
+ :lentic-file
+ (concat
+ (file-name-sans-extension
+ (buffer-file-name))
+ ".py"))))
+
+(add-to-list 'lentic-init-functions
+ 'lentic-org-python-init)
+
+;;;###autoload
+(defun lentic-python-org-init ()
+ (lentic-org-python-oset
+ (lentic-unmatched-commented-block-configuration
+ "lb-python-to-org"
+ :lentic-file
+ (concat
+ (file-name-sans-extension
+ (buffer-file-name))
+ ".org"))))
+
+(add-to-list 'lentic-init-functions
+ 'lentic-python-org-init)
+;; #+end_src
;;; Footer:
- [elpa] externals/lentic fa3b9bcbda 282/333: Move var declaration inside source markers., (continued)
- [elpa] externals/lentic fa3b9bcbda 282/333: Move var declaration inside source markers., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic ed1d792d9f 286/333: Depend on melpa-stable only., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic fc44aa8c96 271/333: Change symbol names to chunk., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 17b82d8e29 150/333: Merge branch 'expt/incremental-whitelist', ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 5b6d83c4fc 227/333: show-all on create in org-mode., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 7d27529728 239/333: Bye-Bye Info, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bc973d85d1 236/333: Merge branch 'patch-1' of https://github.com/Prathyvsh/lentic into Prathyvsh-patch-1, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic ae8ac15494 213/333: lentic-when-buffer added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 53283a1fc3 223/333: README update and roadmap added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 6d52e00c01 246/333: Explicitly exclude -autoloads and -pkg files., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4abbcd4b7f 259/333: Org-mode now support multiple src blocks.,
ELPA Syncer <=
- [elpa] externals/lentic a5ad1e2215 299/333: Move lentic-test-clone to assess, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e8e448e149 324/333: Merge pull request #55 from ether42/master, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 37f9fedb44 284/333: Remove marmalade., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 0f7664a90f 318/333: Log to external-debugging-output, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 621671d1a7 269/333: Garbage Collects configs on init., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 08f9b0f4d1 274/333: Merge branch 'master' of github.com:phillord/lentic, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 90fb12acdf 326/333: Fix duplicated code error., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e41580a2dc 319/333: Fix typo in markup, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 8655ecd51e 293/333: v0.11 release., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 6b4737219e 297/333: Document tests, ELPA Syncer, 2024/02/27