[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-transclusion d479bec65a 1/7: add: #147 support :lin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-transclusion d479bec65a 1/7: add: #147 support :lines for org-id link |
Date: |
Tue, 23 Aug 2022 15:57:54 -0400 (EDT) |
branch: externals/org-transclusion
commit d479bec65a535e339f84244235510b58fed5e9eb
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
add: #147 support :lines for org-id link
Currently `:lines` property is only supported for file links. This
change enables `:lines` to org-id links in the form of `[[id:<org id>
:lines]]`. Note that when this is done, Org-transclusion treats the
target buffer like a normal text file, thus other Org-specific filtering
properties such as `:exclude-elements` and `:only-contents` won't work
as they rely on `org-elements` (that is, the target buffer needs to be
treated as an Org buffer not a text buffer).
---
org-transclusion-src-lines.el | 35 +++++++++++++++++++++--------------
test/test-2.1-lines.org | 2 ++
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/org-transclusion-src-lines.el b/org-transclusion-src-lines.el
index 98725b4c39..3ae40e95a8 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: 28 December 2021
+;; Last modified: 26 June 2022
;;; Commentary:
;; This is an extension to `org-transclusion'. When active, it adds features
@@ -73,11 +73,11 @@ Return nil if PLIST does not contain \":src\" or \":lines\"
properties."
(org-transclusion-content-src-lines link plist)))
;; :lines needs to be the last condition to check because :src INCLUDE
:lines
((or (plist-get plist :lines)
- (plist-get plist :end)
+ (plist-get plist :end))
;; Link contains a search-option ::<string>
;; and NOT for an Org file
- (and (org-element-property :search-option link)
- (not (org-transclusion-org-file-p (org-element-property :path
link)))))
+;; (and (org-element-property :search-option link)
+;; (not (org-transclusion-org-file-p (org-element-property :path
link)))))
(append '(:tc-type "lines")
(org-transclusion-content-range-of-lines link plist)))))
@@ -104,21 +104,28 @@ line 10. Likewise, when the second number is omitted
(e.g. 10-),
it means from line 10 to the end of file."
(let* ((path (org-element-property :path link))
(search-option (org-element-property :search-option link))
- (buf (find-file-noselect path))
+ (type (org-element-property :type link))
+ (entry-pos) (buf)
(lines (plist-get plist :lines))
(end-search-op (plist-get plist :end)))
+ (if (not (string= type "id")) (setq buf (find-file-noselect path))
+ (let ((filename-pos (org-id-find path)))
+ (setq buf (find-file-noselect (car filename-pos)))
+ (setq entry-pos (cdr filename-pos))))
(when buf
(with-current-buffer buf
(org-with-wide-buffer
- (let* ((start-pos (or (when search-option
- (save-excursion
- (ignore-errors
- ;; FIXME `org-link-search' does not return
- ;; postion when ::/regex/ and ;;number are
- ;; used
- (if (org-link-search search-option)
- (line-beginning-position)))))
- (point-min)))
+ (let* ((start-pos (cond
+ (entry-pos)
+ ((when search-option
+ (save-excursion
+ (ignore-errors
+ ;; FIXME `org-link-search' does not
+ ;; return postion when eithher
+ ;; ::/regex/ or ::number is used
+ (if (org-link-search search-option)
+ (line-beginning-position))))))
+ ((point-min))))
(end-pos (when end-search-op
(save-excursion
(ignore-errors
diff --git a/test/test-2.1-lines.org b/test/test-2.1-lines.org
index 6b98e79ed9..0b3f93439e 100644
--- a/test/test-2.1-lines.org
+++ b/test/test-2.1-lines.org
@@ -6,6 +6,8 @@ Including lines of source code
[[file:./paragraph.org::/Lorem/]]
+#+transclude: [[id:2022-06-26T141859]] :lines 5-10
+
#+name: source code 1
#+transclude: [[file:../org-transclusion-src-lines.el]] :lines 1-10 :src elisp
#+transclude: [[file:test-src.el]] :lines 1-
- [elpa] externals/org-transclusion updated (5cb94542e1 -> b6c7bcb632), ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion c49dcbd440 5/7: (intrnl) fix source comment, ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion d479bec65a 1/7: add: #147 support :lines for org-id link,
ELPA Syncer <=
- [elpa] externals/org-transclusion fb947f5a83 4/7: fix: conditions in org-transclusion-add-src-lines, ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion 5f7e300f04 2/7: (internal) change line ending from CRLF to LF, ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion e3b588be07 6/7: intrnl: test file, ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion b6c7bcb632 7/7: chg: visit file as RAWFILE, ELPA Syncer, 2022/08/23
- [elpa] externals/org-transclusion 65f74f4666 3/7: (internal) update test file for lines, ELPA Syncer, 2022/08/23