[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic bfebaa4997 058/333: Support for orgel files.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic bfebaa4997 058/333: Support for orgel files. |
Date: |
Tue, 27 Feb 2024 13:00:02 -0500 (EST) |
branch: externals/lentic
commit bfebaa499732fed67dcb78e850d31bf538b495bc
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Support for orgel files.
The previous org->el translation was very simple. This version restricts
the structure of the org file that can be used, but provides a more
complete translation. So ";;; Headers" are translated into "* Headers".
---
dev-resources/orgel-org.el | 9 ++++
dev-resources/orgel-org.org | 9 ++++
linked-buffer-org.el | 103 ++++++++++++++++++++++++++++++++++++++++++++
test/linked-buffer-test.el | 15 ++++++-
4 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/dev-resources/orgel-org.el b/dev-resources/orgel-org.el
new file mode 100644
index 0000000000..2f3140a8ec
--- /dev/null
+++ b/dev-resources/orgel-org.el
@@ -0,0 +1,9 @@
+;;; orgel-org.el --- A test file -*- lexical-binding: t -*-
+
+;; Author: Phillip Lord
+
+;;; Commentary:
+
+;; #+BEGIN_SRC emacs-lisp
+(defun orgel-function ())
+;; #+END_SRC
diff --git a/dev-resources/orgel-org.org b/dev-resources/orgel-org.org
new file mode 100644
index 0000000000..f1130f136a
--- /dev/null
+++ b/dev-resources/orgel-org.org
@@ -0,0 +1,9 @@
+# # orgel-org.el --- A test file -*- lexical-binding: t -*-
+
+Author: Phillip Lord
+
+* Commentary
+
+#+BEGIN_SRC emacs-lisp
+(defun orgel-function ())
+#+END_SRC
diff --git a/linked-buffer-org.el b/linked-buffer-org.el
index 388c6bafb4..8013c8d29f 100644
--- a/linked-buffer-org.el
+++ b/linked-buffer-org.el
@@ -38,6 +38,7 @@
;;; Code:
+;; Simple org to el with nothing special
(defun linked-buffer-org-to-el-new ()
(linked-buffer-uncommented-block-configuration
"lb-org-to-el"
@@ -72,5 +73,107 @@
(setq linked-buffer-config
(linked-buffer-el-to-org-new)))
+
+;; this is the more complex stuff for orgel
+;; which treats ;;; comments specially
+(defclass linked-buffer-org-to-orgel-configuration
+ (linked-buffer-uncommented-block-configuration)
+ ())
+
+(defmethod linked-buffer-clone
+ ((conf linked-buffer-org-to-orgel-configuration))
+ ;; do everything else to the buffer
+ (call-next-method conf)
+ (m-buffer-replace-match
+ (m-buffer-match
+ (linked-buffer-that conf)
+ ";; # # "
+ :end
+ (cadr
+ (car
+ (m-buffer-match-line
+ (linked-buffer-that conf)))))
+ ";;; ")
+ ;; replace big headers
+ (m-buffer-replace-match
+ (m-buffer-match (linked-buffer-that conf)
+ "^;; [*] \\(\\\w*\\)")
+ ";;; \\1:"))
+
+(defmethod linked-buffer-invert
+ ((conf linked-buffer-org-to-orgel-configuration))
+ (let ((rtn
+ (linked-buffer-orgel-to-org-new)))
+ (oset rtn :that-buffer
+ (linked-buffer-this conf))
+ rtn))
+
+(defun linked-buffer-org-to-orgel-new ()
+ (linked-buffer-org-to-orgel-configuration
+ "lb-orgel-to-el"
+ :this-buffer (current-buffer)
+ :linked-file
+ (concat
+ (file-name-sans-extension
+ (buffer-file-name))
+ ".el")
+ :comment ";; "
+ :comment-stop "#\\\+BEGIN_SRC emacs-lisp"
+ :comment-start "#\\\+END_SRC"))
+
+(defun linked-buffer-org-orgel-init ()
+ (setq linked-buffer-config
+ (linked-buffer-org-to-orgel-new)))
+
+(defclass linked-buffer-orgel-to-org-configuration
+ (linked-buffer-commented-block-configuration)
+ ())
+
+(defmethod linked-buffer-clone
+ ((conf linked-buffer-orgel-to-org-configuration))
+ ;; do everything else to the buffer
+ (call-next-method conf)
+ (m-buffer-replace-match
+ (m-buffer-match
+ (linked-buffer-that conf)
+ ";;; "
+ :end
+ (cadr
+ (car
+ (m-buffer-match-line
+ (linked-buffer-that conf)))))
+ "# # ")
+ (m-buffer-replace-match
+ (m-buffer-match (linked-buffer-that conf)
+ "^;;; \\(\\\w*\\):")
+ "* \\1"))
+
+(defmethod linked-buffer-invert
+ ((conf linked-buffer-orgel-to-org-configuration))
+ (let ((rtn
+ (linked-buffer-org-to-orgel-new)))
+ (oset rtn :that-buffer (linked-buffer-this conf))
+ rtn))
+
+(defun linked-buffer-orgel-to-org-new ()
+ (linked-buffer-orgel-to-org-configuration
+ "lb-orgel-to-org"
+ :this-buffer (current-buffer)
+ ;; we don't really need a file and could cope without, but org mode assumes
+ ;; that the buffer is file name bound when it exports. As it happens, this
+ ;; also means that file saving is possible which in turn saves the el file
+ :linked-file
+ (concat
+ (file-name-sans-extension
+ (buffer-file-name))
+ ".org")
+ :comment ";; "
+ :comment-stop "#\\\+BEGIN_SRC emacs-lisp"
+ :comment-start "#\\\+END_SRC"))
+
+(defun linked-buffer-orgel-org-init ()
+ (setq linked-buffer-config
+ (linked-buffer-orgel-to-org-new)))
+
(provide 'linked-buffer-org)
;;; linked-buffer-org.el ends here
diff --git a/test/linked-buffer-test.el b/test/linked-buffer-test.el
index f8a582f000..74f4b289cb 100644
--- a/test/linked-buffer-test.el
+++ b/test/linked-buffer-test.el
@@ -1,4 +1,3 @@
-
(require 'linked-buffer)
(require 'linked-buffer-latex-code)
(require 'linked-buffer-asciidoc)
@@ -26,7 +25,6 @@
(linked-buffer-batch-clone-with-config
(linked-buffer-test-file file) init)))
-
(defvar conf-default
(linked-buffer-default-configuration "bob"))
@@ -69,3 +67,16 @@
(linked-buffer-test-clone-equal
'linked-buffer-el-org-init
"el-org.el" "el-org.org")))
+
+(ert-deftest linked-buffer-orgel-org ()
+ (should
+ (linked-buffer-test-clone-equal
+ 'linked-buffer-orgel-org-init
+ "orgel-org.el" "orgel-org.org")))
+
+;; Use this to generate a new test file
+
+;; (linked-buffer-batch-clone-and-save-with-config
+;; "../dev-resources/orgel-org.el"
+;; 'linked-buffer-orgel-org-init
+;; )
- [elpa] externals/lentic 66182f8c76 036/333: v0.4 release., (continued)
- [elpa] externals/lentic 66182f8c76 036/333: v0.4 release., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 30d35ba86f 030/333: f-el added for tests., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic d0d3f1cb78 038/333: Moved file name, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic dd1d2983fb 042/333: Change names to better represent function., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 86fbd438db 041/333: More travis, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 743bdff483 039/333: Move to cask., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 206a92e92b 045/333: Now handles "----" with no source directives correctly., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic c09c57b8ce 051/333: Saving buffer forces linked-buffer saving also., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a821a5c8b1 048/333: Uncommented config was broken., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic cd3d385aad 050/333: Asciidoc supports for lisp., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bfebaa4997 058/333: Support for orgel files.,
ELPA Syncer <=
- [elpa] externals/lentic 8da4b5f906 062/333: Added file local for orgel, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 63a217ec37 059/333: m-buffer dependency to 0.5, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic fcc9aaefb7 069/333: org-to-clojure support added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic aee6bef444 073/333: Full commenting and orgel style documentation., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e80d2346e6 070/333: Split local variables string., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic f7ad2e9267 077/333: Small documentation update., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 191e7b3c66 080/333: Initial incorporation of incremental change., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e3032a6ebc 067/333: v0.5 release, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a188840402 090/333: Incremental updates for block mode., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 475d8e14ba 071/333: Case sensitivity an option for blocks., ELPA Syncer, 2024/02/27