forked from nobiot/org-transclusion
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorg-transclusion-indent-mode.el
68 lines (56 loc) · 2.45 KB
/
org-transclusion-indent-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; org-transclusion-indent-mode.el --- support org-indent-mode -*- lexical-binding: t; -*-
;;; Commentary:
;; This file is part of Org-transclusion
;;; Code:
(require 'org-indent)
(declare-function org-transclusion-within-transclusion-p
'org-transclusion)
(defun org-translusion-indent-add-properties (beg end)
"BEG END."
(advice-add #'org-indent-set-line-properties
:override
#'org-transclusion-indent-set-line-properties-ad)
(org-indent-add-properties beg end)
(advice-remove #'org-indent-set-line-properties
#'org-transclusion-indent-set-line-properties-ad))
(defun org-transclusion-indent-set-line-properties-ad (level indentation &optional heading)
"Set prefix properties on current line an move to next one.
LEVEL is the current level of heading. INDENTATION is the
expected indentation when wrapping line.
When optional argument HEADING is non-nil, assume line is at
a heading. Moreover, if it is `inlinetask', the first star will
have `org-warning' face."
(let* ((line (aref (pcase heading
(`nil org-indent--text-line-prefixes)
(`inlinetask org-indent--inlinetask-line-prefixes)
(_ org-indent--heading-line-prefixes))
level))
(wrap
(org-add-props
(concat line
(if heading (concat (make-string level ?*) " ")
(make-string indentation ?\s)))
nil 'face 'org-indent)))
;; Org-transclusion's addition begin
(when (org-transclusion-within-transclusion-p)
(setq line
(concat line
(propertize
"x"
'display
'(left-fringe org-transclusion-fringe-bitmap
org-transclusion-fringe))))
(setq wrap
(concat line
(propertize
"x"
'display
'(left-fringe org-transclusion-fringe-bitmap
org-transclusion-fringe)))))
;; Org-transclusion's addition end
;; Add properties down to the next line to indent empty lines.
(add-text-properties (line-beginning-position) (line-beginning-position 2)
`(line-prefix ,line wrap-prefix ,wrap)))
(forward-line))
(provide 'org-transclusion-indent-mode)
;;; org-transclusion-indent-mode.el ends here