[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-transclusion b3e59a7b0a 25/29: refactor(thing-at-po
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-transclusion b3e59a7b0a 25/29: refactor(thing-at-point): contain within src-lines.el #157 |
Date: |
Mon, 8 May 2023 06:59:10 -0400 (EDT) |
branch: externals/org-transclusion
commit b3e59a7b0a56bfafff7a753d6ebbd8ad60ef745c
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
refactor(thing-at-point): contain within src-lines.el #157
- Use 'org-transclusion-content-format-functions' hook for ensure new line
- Change name of function 'org-transclusion-ensure-newline'
We haven't used the double hyphen "--" convention to visually denote
"private" functions
---
org-transclusion-src-lines.el | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/org-transclusion-src-lines.el b/org-transclusion-src-lines.el
index 97fdbf3583..4d431e794b 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 March 2023
+;; Last modified: 08 May 2023
;;; Commentary:
;; This is an extension to `org-transclusion'. When active, it adds features
@@ -32,8 +32,6 @@
(declare-function org-transclusion-org-file-p
"org-transclusion")
-(declare-function org-transclusion-keyword-value-thing-at-point
- "org-transclusion")
;;;; Setting up the extension
;; Add a new transclusion type
@@ -55,7 +53,8 @@
#'org-transclusion-keyword-plist-to-string-src-lines)
;; Transclusion content formating
-;; Not needed. Default works for text files.
+(add-hook 'org-transclusion-content-format-functions
+ #'org-transclusion-content-format-src-lines)
;; Open source buffer
(add-hook 'org-transclusion-open-source-marker-functions
@@ -211,7 +210,7 @@ for the range works."
(format "#+begin_src %s" src-lang)
(when rest (format " %s" rest))
"\n"
- (org-transclusion--ensure-newline src-content)
+ (org-transclusion-ensure-newline src-content)
"#+end_src\n")))))
;; Return the payload either modified or unmodified
payload))
@@ -305,5 +304,31 @@ for non-Org text files including program source files."
(- (region-end) newline-offset))))
(cons src-ov tc-ov))))
+;;; Thing-at-point
+(defun org-transclusion-keyword-value-thing-at-point (string)
+ "It is a utility function used converting a keyword STRING to plist.
+It is meant to be used by `org-transclusion-get-string-to-plist'.
+It needs to be set in `org-transclusion-get-keyword-values-hook'.
+Double qutations are optional :thing-at-point \"sexp\". The regex should
+match any valid elisp symbol (but please don't quote it)."
+ (when (string-match ":thing-at-point \\([[:alnum:][:punct:]]+\\)" string)
+ (list :thing-at-point (org-strip-quotes (match-string 1 string)))))
+
+(defun org-transclusion-content-format-src-lines (type content indent)
+ "Format text CONTENT from source before transcluding.
+Return content modified (or unmodified, if not applicable).
+
+This is the default one. It only returns the content as is.
+
+INDENT is the number of current indentation of the #+transclude."
+ (when (org-transclusion-src-lines-p type)
+ (let ((content (org-transclusion-ensure-newline content)))
+ (org-transclusion-content-format type content indent))))
+
+(defun org-transclusion-ensure-newline (str)
+ (if (not (string-suffix-p "\n" str))
+ (concat str "\n")
+ str))
+
(provide 'org-transclusion-src-lines)
;;; org-transclusion-src-lines.el ends here
- [elpa] externals/org-transclusion 4881798b9d 05/29: Nil Safety, (continued)
- [elpa] externals/org-transclusion 4881798b9d 05/29: Nil Safety, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 134c8a645f 04/29: Namespace bounds-of-n-things-at-point, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 310bd28b10 14/29: Augment only needed for magical enter in thing-at-point branch., ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 2bade767cb 15/29: Adapt to magic enter., ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 01a8367387 07/29: Move new-line guarentee to cover all content sources, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 2053106e73 23/29: style(org-transclusion.el): indentation, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 51cac54fed 11/29: Need newline guarentee also in content-src-lines, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 9db0791c07 18/29: refactor: remove unused let variable, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 1146293107 26/29: Merge pull request #157 from devcarbon-com/feature--things-at-point, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion b6091cdcaa 19/29: doc: update manual for the new feature for live-sync org src block, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion b3e59a7b0a 25/29: refactor(thing-at-point): contain within src-lines.el #157,
ELPA Syncer <=
- [elpa] externals/org-transclusion e4f96e114b 27/29: Merge branch 'dev/feature--things-at-point', ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 364cb5bf3f 28/29: docs: NEWS and user manual to mention thing-at-point, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 2cb719e80f 02/29: Add support for handling identations when using :thing-at-point sexp, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 8317ec94fa 09/29: Fixup, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 654c1a83f9 17/29: feat: suggestion for live-sync-buffers-src-lines, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 28737e1b5c 08/29: Need newline guarentee also in content-src-lines, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 1b5f428e58 10/29: Move new-line guarentee to cover all content sources, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion b9d73ad7fd 16/29: Typo., ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion f0e8240695 20/29: doc: mention the live-sync to be in the next stable rel for ELPA, ELPA Syncer, 2023/05/08
- [elpa] externals/org-transclusion 1695f306e6 22/29: refactor: reverted changes to org-transclusion.el, ELPA Syncer, 2023/05/08