[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-transclusion ee816482df 8/9: Merge pull request #17
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-transclusion ee816482df 8/9: Merge pull request #178 and #176 for feature--org-block-live-sync |
Date: |
Wed, 29 Mar 2023 16:59:08 -0400 (EDT) |
branch: externals/org-transclusion
commit ee816482dfc2616ac3efc060213410d418c1aaf6
Merge: ff722826ce 076b2a4597
Author: nobiot <me@nobiot.com>
Commit: GitHub <noreply@github.com>
Merge pull request #178 and #176 for feature--org-block-live-sync
A major feature contribution by @devcarbon-com (Benjamin Cherry). Benjamin
has commenced the FSF copyright assignment paperwork process; refer to
https://github.com/nobiot/org-transclusion/pull/176#issuecomment-1485658657
Thank you so much for putting it together! I could not work out the logic;
it is truly remarkable.
---
NEWS | 10 ++++++++++
docs/org-transclusion-manual.org | 5 ++++-
org-transclusion-src-lines.el | 18 +++++++++++++-----
org-transclusion.el | 7 +++++--
test/python-1.py | 11 +++++++++++
test/python-2.py | 8 ++++++++
test/python-3.py | 6 ++++++
test/test-live-sync.org | 12 ++++++++++++
8 files changed, 69 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
index 9e28ffd263..9fe7d840d1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,14 @@
* Current development version
+ - feat: add org-block-live-sync
+
+ - Command 'org-transclusion-live-sync-start' now can start live sync
+ when
+
+ 1) transcluding a source code text file
+ 2) into org src block with the ':src' property in #+transclude
+
+ Example: #+transclude: [[python-1.py]] :src python
+
- feat: add org-transclusion-detach
- New command 'org-transclusion-detach' can be used on the transclusion
diff --git a/docs/org-transclusion-manual.org b/docs/org-transclusion-manual.org
index 72da9d5b36..b636cb8a7f 100644
--- a/docs/org-transclusion-manual.org
+++ b/docs/org-transclusion-manual.org
@@ -1,7 +1,7 @@
#+title: Org-transclusion User Manual
#+author: Noboru Ota <me@nobiot.com>
#+macro: version 1.3.x
-#+macro: modified 04 March 2023
+#+macro: modified 29 March 2023
#+language: en
#+export_file_name: org-transclusion.texi
@@ -419,6 +419,9 @@ The source block will have the additional properties:
,#+begin_src python :session :results value
#+end_example
+With since 2023-03-28 update, you can also use live-sync the source code
+transcluded into src-block.
+
** Transclude range of lines for text and source files
:PROPERTIES:
:CUSTOM_ID: transclude-range-of-lines-for-text-and-source-files
diff --git a/org-transclusion-src-lines.el b/org-transclusion-src-lines.el
index 71938cda82..b0aaafdc8d 100644
--- a/org-transclusion-src-lines.el
+++ b/org-transclusion-src-lines.el
@@ -17,7 +17,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; Created: 24 May 2021
-;; Last modified: 08 February 2023
+;; Last modified: 28 March 2023
;;; Commentary:
;; This is an extension to `org-transclusion'. When active, it adds features
@@ -258,10 +258,18 @@ The cons cell to be returned is in this format:
This function uses TYPE to identify relevant files; it's meant
for non-Org text files including program source files."
(when (org-transclusion-src-lines-p type)
- ;; Let's not allow live-sync when source is transcluded into a source
block.
- (when (string= "src" type)
- (user-error "No live sync for src-code block"))
- (org-transclusion-live-sync-buffers-others-default nil)))
+ (cl-destructuring-bind
+ (src-ov . tc-ov) (org-transclusion-live-sync-buffers-others-default
nil)
+ (save-mark-and-excursion
+ (org-babel-mark-block)
+ (let* ((src-ov-length (- (overlay-end src-ov) (overlay-start
src-ov)))
+ (region-length (- (region-end) (region-beginning)))
+ (overlay-has-extra-newline (= 1 (- region-length
src-ov-length)))
+ (newline-offset (if overlay-has-extra-newline 1 0)))
+ (move-overlay tc-ov
+ (region-beginning)
+ (- (region-end) newline-offset))))
+ (cons src-ov tc-ov))))
(provide 'org-transclusion-src-lines)
;;; org-transclusion-src-lines.el ends here
diff --git a/org-transclusion.el b/org-transclusion.el
index 2678bdbde3..2989ff098f 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -17,7 +17,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; Created: 10 October 2020
-;; Last modified: 05 March 2023
+;; Last modified: 28 March 2023
;; URL: https://github.com/nobiot/org-transclusion
;; Keywords: org-mode, transclusion, writing
@@ -680,7 +680,10 @@ a couple of org-transclusion specific keybindings; namely:
(user-error
(concat
"No live-sync can be started. "
- "Lengths of transclusion and source are not identical"))
+ "Lengths of transclusion and source are not identical"
+ (format " - tc: [%s] src: [%s]"
+ (- (overlay-end tc-ov) (overlay-start tc-ov))
+ (- (overlay-end src-ov) (overlay-start src-ov)))))
nil) ; return nil
(org-transclusion-live-sync-modify-overlays
(text-clone-set-overlays src-ov tc-ov))
diff --git a/test/python-1.py b/test/python-1.py
new file mode 100644
index 0000000000..5aa2044ed5
--- /dev/null
+++ b/test/python-1.py
@@ -0,0 +1,11 @@
+import matplotlib
+import matplotlib.pyplot as plt
+# end here
+# id-1234
+fig=plt.figure(figsize=(9,6))
+plt.plot([1,3,2])
+fig.tight_layout()
+fname = 'pyfig2.png'
+plt.savefig(fname)
+# id-1234 end here
+return fname # return this to org-mode
diff --git a/test/python-2.py b/test/python-2.py
new file mode 100644
index 0000000000..c5e29aabb3
--- /dev/null
+++ b/test/python-2.py
@@ -0,0 +1,8 @@
+def foo(x):
+ if x>0:
+ return x+1
+
+ else:
+ return x-1
+
+return foo(5)
diff --git a/test/python-3.py b/test/python-3.py
new file mode 100644
index 0000000000..502d500580
--- /dev/null
+++ b/test/python-3.py
@@ -0,0 +1,6 @@
+import random
+if random.randint(0,10) % 2 == 0:
+ ret = "even"
+else:
+ ret = "odd"
+ret
diff --git a/test/test-live-sync.org b/test/test-live-sync.org
new file mode 100644
index 0000000000..87eeced85f
--- /dev/null
+++ b/test/test-live-sync.org
@@ -0,0 +1,12 @@
+#+transclude: [[file:test-src.org::code]]
+
+#+transclude: [[python-1.py]] :src python
+
+#+RESULTS:
+[[./pyfig2.png]]
+
+
+#+transclude: [[python-2.py]] :src python
+
+#+RESULTS:
+: 6
- [elpa] externals/org-transclusion updated (ff722826ce -> 2e77e341c6), ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 9060dcf712 3/9: Adapt to magic enter., ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 980a0fc9b4 1/9: Allow live sync on org-blocks -- experimental, ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 076b2a4597 7/9: doc: update manual for the new feature for live-sync org src block, ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 67c9bfbeeb 2/9: Augment only needed for magical enter in thing-at-point branch., ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 2d0502f6bd 4/9: Typo., ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 4fb11ac23b 5/9: feat: suggestion for live-sync-buffers-src-lines, ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion 2e77e341c6 9/9: doc: mention the live-sync to be in the next stable rel for ELPA, ELPA Syncer, 2023/03/29
- [elpa] externals/org-transclusion ee816482df 8/9: Merge pull request #178 and #176 for feature--org-block-live-sync,
ELPA Syncer <=
- [elpa] externals/org-transclusion 2751fbc7d0 6/9: refactor: remove unused let variable, ELPA Syncer, 2023/03/29