@@ -59,15 +59,18 @@ Intended for :set property for `customize'."
59
59
(when (featurep 'org-transclusion )
60
60
(org-transclusion-load-extensions-maybe 'force )))
61
61
62
- (defcustom org-transclusion-extensions '(org-transclusion-src-lines org-transclusion-font-lock)
62
+ (defcustom org-transclusion-extensions
63
+ '(org-transclusion-src-lines org-transclusion-font-lock)
63
64
" Extensions to be loaded with org-transclusion.el."
64
65
:set #'org-transclusion-set-extensions
65
66
:type
66
67
'(set :greedy t
67
- (const :tag " src-lines: Add :src and :lines for non-Org files" org-transclusion-src-lines)
68
- (const :tag " font-lock: Add font-lock for Org-transclusion" org-transclusion-font-lock)
69
-
70
- (const :tag " indent-mode: Support org-indent-mode" org-transclusion-indent-mode)
68
+ (const :tag " src-lines: Add :src and :lines for non-Org files"
69
+ org-transclusion-src-lines)
70
+ (const :tag " font-lock: Add font-lock for Org-transclusion"
71
+ org-transclusion-font-lock)
72
+ (const :tag " indent-mode: Support org-indent-mode"
73
+ org-transclusion-indent-mode)
71
74
(const :tag " html: Transclude HTML converted to Org with Pandoc"
72
75
org-transclusion-html)
73
76
(repeat :tag " Other packages" :inline t (symbol :tag " Package" ))))
@@ -379,14 +382,16 @@ transclusion keyword."
379
382
(interactive " P" )
380
383
(let* ((context (org-element-lineage
381
384
(org-element-context )'(link ) t ))
382
- (auto-transclude-p (if (or (not arg) (numberp arg)) org-transclusion-mode
385
+ (auto-transclude-p (if (or (not arg) (numberp arg))
386
+ org-transclusion-mode
383
387
; ; if `universal-argument' is passed,
384
388
; ; reverse nil/t when
385
- (if org-transclusion-mode nil t ))))
389
+ (not org-transclusion-mode))))
386
390
(let* ((contents-beg (org-element-property :contents-begin context))
387
391
(contents-end (org-element-property :contents-end context))
388
- (contents (when contents-beg
389
- (buffer-substring-no-properties contents-beg contents-end)))
392
+ (contents (and contents-beg
393
+ (buffer-substring-no-properties contents-beg
394
+ contents-end)))
390
395
(link (org-element-link-interpreter context contents)))
391
396
(save-excursion
392
397
(org-transclusion-search-or-add-next-empty-line)
@@ -473,11 +478,10 @@ hooks in `org-transclusion-add-functions'."
473
478
(eq src-content nil ))
474
479
; ; Keep going with program when no content `org-transclusion-add-all'
475
480
; ; should move to the next transclusion
476
- (progn (message
477
- (format
478
- " No content found with \" %s\" . Check the link at point %d, line %d"
479
- (org-element-property :raw-link link ) (point ) (org-current-line ))
480
- nil ))
481
+ (prog1 nil
482
+ (message
483
+ " No content found with \" %s\" . Check the link at point %d, line %d"
484
+ (org-element-property :raw-link link ) (point ) (org-current-line )))
481
485
(let ((beg (line-beginning-position ))
482
486
(end))
483
487
(org-transclusion-with-inhibit-read-only
@@ -524,7 +528,8 @@ the rest of the buffer unchanged."
524
528
(with-demoted-errors
525
529
" Not transcluded. Continue to next: %S"
526
530
(when (org-transclusion-add)
527
- (message (format " Transcluded at point %d , line %d " (point ) (org-current-line ))))))))
531
+ (message " Transcluded at point %d , line %d "
532
+ (point ) (org-current-line )))))))
528
533
(goto-char marker)
529
534
(move-marker marker nil ) ; point nowhere for GC
530
535
t )))
@@ -533,10 +538,10 @@ the rest of the buffer unchanged."
533
538
" Remove transcluded text at point.
534
539
When success, return the beginning point of the keyword re-inserted."
535
540
(interactive )
536
- (if-let* ((beg (marker-position ( get-char-property ( point )
537
- 'org-transclusion-beg-mkr )))
538
- (end (marker-position ( get-char-property ( point )
539
- 'org-transclusion-end-mkr )))
541
+ (if-let* ((beg (marker-position
542
+ ( get-char-property ( point ) 'org-transclusion-beg-mkr )))
543
+ (end (marker-position
544
+ ( get-char-property ( point ) 'org-transclusion-end-mkr )))
540
545
(keyword-plist (get-char-property (point )
541
546
'org-transclusion-orig-keyword ))
542
547
(indent (plist-get keyword-plist :current-indentation ))
@@ -795,9 +800,10 @@ set in `before-save-hook'. It also move the point back to
795
800
(move-marker p nil )
796
801
(setq do-count (1+ do-count))
797
802
(when (> do-count do-length)
798
- (error " org-transclusion: Aborting. You may be in an infinite loop " ))))
799
- ; ; After save and adding all transclusions, the modified flag should be
800
- ; ; set to nil
803
+ (error
804
+ " org-transclusion: Aborting. You may be in an infinite loop" ))))
805
+ ; ; After save and adding all transclusions, the modified flag should
806
+ ; ; be set to nil.
801
807
(restore-buffer-modified-p nil )
802
808
(when org-transclusion-remember-point
803
809
(goto-char org-transclusion-remember-point))))
@@ -973,8 +979,8 @@ Return nil if not found."
973
979
(if mkr
974
980
(append payload (org-transclusion-content-org-marker mkr plist))
975
981
(message
976
- ( format " No transclusion done for this ID. Ensure it works at point %d , line %d "
977
- (point ) (org-current-line ) ))
982
+ " No transclusion done for this ID. Ensure it works at point %d, line %d"
983
+ (point ) (org-current-line ))
978
984
nil ))))
979
985
980
986
(defun org-transclusion-add-org-file (link plist )
@@ -995,7 +1001,8 @@ Return nil if not found."
995
1001
; ;-----------------------------------------------------------------------------
996
1002
; ;;; Functions for inserting content
997
1003
998
- (defun org-transclusion-content-insert (keyword-values type content sbuf sbeg send copy )
1004
+ (defun org-transclusion-content-insert ( keyword-values type content
1005
+ sbuf sbeg send copy )
999
1006
" Insert CONTENT at point and put source overlay in SBUF.
1000
1007
Return t when successful.
1001
1008
@@ -1052,28 +1059,23 @@ based on the following arguments:
1052
1059
(setq end (point ))
1053
1060
(setq end-mkr (set-marker (make-marker ) end))
1054
1061
(unless copy
1055
- (add-text-properties beg end
1056
- `(local-map , org-transclusion-map
1057
- read-only t
1058
- front-sticky t
1059
- ; ; rear-nonticky seems better for
1060
- ; ; src-lines to add "#+result" after C-c
1061
- ; ; C-c
1062
- rear-nonsticky t
1063
- org-transclusion-type , type
1064
- org-transclusion-beg-mkr
1065
- , beg-mkr
1066
- org-transclusion-end-mkr
1067
- , end-mkr
1068
- org-transclusion-pair
1069
- , tc-pair
1070
- org-transclusion-orig-keyword
1071
- , keyword-values
1072
- ; ; TODO Fringe is not supported for terminal
1073
- line-prefix
1074
- ,(org-transclusion-propertize-transclusion)
1075
- wrap-prefix
1076
- ,(org-transclusion-propertize-transclusion)))
1062
+ (add-text-properties
1063
+ beg end
1064
+ `( local-map , org-transclusion-map
1065
+ read-only t
1066
+ front-sticky t
1067
+ ; ; rear-nonticky seems better for
1068
+ ; ; src-lines to add "#+result" after C-c
1069
+ ; ; C-c
1070
+ rear-nonsticky t
1071
+ org-transclusion-type , type
1072
+ org-transclusion-beg-mkr , beg-mkr
1073
+ org-transclusion-end-mkr , end-mkr
1074
+ org-transclusion-pair , tc-pair
1075
+ org-transclusion-orig-keyword , keyword-values
1076
+ ; ; TODO Fringe is not supported for terminal
1077
+ line-prefix ,(org-transclusion-propertize-transclusion)
1078
+ wrap-prefix ,(org-transclusion-propertize-transclusion)))
1077
1079
; ; Put the transclusion overlay
1078
1080
(let ((ov-tc (text-clone-make-overlay beg end)))
1079
1081
(overlay-put ov-tc 'evaporate t )
@@ -1210,7 +1212,8 @@ property controls the filter applied to the transclusion."
1210
1212
; ; For dedicated target, we want to get the parent paragraph,
1211
1213
; ; rather than the target itself
1212
1214
(when (and (string= " target" type)
1213
- (string= " paragraph" (org-element-type (org-element-property :parent el))))
1215
+ (string= " paragraph"
1216
+ (org-element-type (org-element-property :parent el))))
1214
1217
(setq el (org-element-property :parent el)))
1215
1218
(let ((beg (org-element-property :begin el))
1216
1219
(end (org-element-property :end el))
@@ -1243,7 +1246,8 @@ property controls the filter applied to the transclusion."
1243
1246
1244
1247
; ; Expand file names in all the links
1245
1248
(when expand-links
1246
- (org-element-map obj 'link #'org-transclusion-content-filter-expand-links ))
1249
+ (org-element-map obj 'link
1250
+ #'org-transclusion-content-filter-expand-links ))
1247
1251
1248
1252
(list :src-content (org-element-interpret-data obj)
1249
1253
:src-buf (current-buffer )
@@ -1401,12 +1405,14 @@ Case 2. #+transclude inside another transclusion"
1401
1405
; ; Case 1. Element at point is NOT #+transclude:
1402
1406
((not (and (string-equal " keyword" (org-element-type elm))
1403
1407
(string-equal " TRANSCLUDE" (org-element-property :key elm))))
1404
- (user-error (format " Not at a transclude keyword or transclusion in a block at point %d , line %d "
1405
- (point ) (org-current-line ))))
1408
+ (user-error
1409
+ " Not at a transclude keyword or transclusion in a block at point %d, line %d"
1410
+ (point ) (org-current-line )))
1406
1411
; ; Case 2. #+transclude inside another transclusion
1407
1412
((org-transclusion-within-transclusion-p)
1408
- (user-error (format " Cannot transclude in another transclusion at point %d , line %d "
1409
- (point ) (org-current-line ))))
1413
+ (user-error
1414
+ " Cannot transclude in another transclusion at point %d, line %d"
1415
+ (point ) (org-current-line )))
1410
1416
(t
1411
1417
t ))))
1412
1418
@@ -1431,8 +1437,9 @@ https://github.com/nobiot/org-transclusion/issues/177."
1431
1437
(eol (line-end-position ))
1432
1438
(case-fold-search t ))
1433
1439
(goto-char bol)
1434
- (when (and (re-search-forward " ^[[:blank:]]*#\\ +\\ (\\ S-*\\ )" eol :noerror )
1435
- (string-equal-ignore-case " transclude" (match-string-no-properties 1 )))
1440
+ (when (and (re-search-forward " ^[[:blank:]]*#\\ +\\ (\\ S-*\\ )" eol t )
1441
+ (string-equal-ignore-case
1442
+ " transclude" (match-string-no-properties 1 )))
1436
1443
(replace-match
1437
1444
(concat (match-string-no-properties 1 ) " :" )
1438
1445
t nil nil 1 )
@@ -1568,12 +1575,12 @@ original buffer. This is required especially when transclusion is
1568
1575
for a paragraph, which can be right next to another paragraph
1569
1576
without a blank space; thus, subsumed by the surrounding
1570
1577
paragraph."
1571
- (let* ((beg (or (when -let ((m (get-char-property (point )
1578
+ (let* ((beg (or (and -let* ((m (get-char-property (point )
1572
1579
'org-transclusion-beg-mkr )))
1573
1580
(marker-position m))
1574
1581
(overlay-start (get-char-property (point )
1575
1582
'org-transclusion-pair ))))
1576
- (end (or (when -let ((m (get-char-property (point )
1583
+ (end (or (and -let* ((m (get-char-property (point )
1577
1584
'org-transclusion-end-mkr )))
1578
1585
(marker-position m))
1579
1586
(overlay-end (get-char-property (point )
0 commit comments