summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-11-06 15:48:38 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2010-12-06 19:13:09 +0100
commit85591ffcbfeb566045f41a801d7ad3632b55c653 (patch)
tree4ef984908c21ccfcc358bf9d9388a0708c46b492
parent9be9f727f8d744c144151e22d2816b6d88d85b67 (diff)
downloadorg-mode-85591ffcbfeb566045f41a801d7ad3632b55c653.tar.gz
Fix indentation of text after an inline task in indent-mode
* org-inlinetask.el (org-inlinetask-get-task-level): new function * org-indent.el (org-indent-add-properties): find true level of indentation wrt inline tasks.
-rw-r--r--lisp/org-indent.el81
1 files changed, 51 insertions, 30 deletions
diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index 39ba445..e2b28cc 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -219,34 +219,47 @@ useful to make it ever so slightly different."
(defun org-indent-add-properties (beg end)
"Add indentation properties between BEG and END.
Assumes that BEG is at the beginning of a line."
- (when (or t org-indent-mode)
- (let ((inhibit-modification-hooks t)
- ov b e n level exit nstars)
- (with-silent-modifications
- (save-excursion
- (goto-char beg)
- (while (not exit)
- (setq e end)
- (if (not (re-search-forward org-indent-outline-re nil t))
- (setq e (point-max) exit t)
- (setq e (match-beginning 0))
- (if (>= e end) (setq exit t))
- (setq level (- (match-end 0) (match-beginning 0) 1))
- (setq nstars (- (* (1- level) org-indent-indentation-per-level)
- (1- level)))
- (add-text-properties
- (point-at-bol) (point-at-eol)
- (list 'line-prefix
- (aref org-indent-stars nstars)
- 'wrap-prefix
- (aref org-indent-strings
- (* level org-indent-indentation-per-level)))))
- (when (and b (> e b))
- (add-text-properties
- b e (list 'line-prefix (aref org-indent-strings n)
- 'wrap-prefix (aref org-indent-strings n))))
- (setq b (1+ (point-at-eol))
- n (* (or level 0) org-indent-indentation-per-level))))))))
+ (let* ((inhibit-modification-hooks t)
+ (inlinetaskp (featurep 'org-inlinetask))
+ (get-real-level (lambda (pos lvl)
+ (save-excursion
+ (goto-char pos)
+ (if (and inlinetaskp (org-inlinetask-in-task-p))
+ (org-inlinetask-get-task-level)
+ lvl))))
+ (b beg)
+ (e end)
+ (level 0)
+ (n 0)
+ exit nstars)
+ (with-silent-modifications
+ (save-excursion
+ (goto-char beg)
+ (while (not exit)
+ (setq e end)
+ (if (not (re-search-forward org-indent-outline-re nil t))
+ (setq e (point-max) exit t)
+ (setq e (match-beginning 0))
+ (if (>= e end) (setq exit t))
+ (unless (and inlinetaskp (org-inlinetask-in-task-p))
+ (setq level (- (match-end 0) (match-beginning 0) 1)))
+ (setq nstars (* (1- (funcall get-real-level e level))
+ (1- org-indent-indentation-per-level)))
+ (add-text-properties
+ (point-at-bol) (point-at-eol)
+ (list 'line-prefix
+ (aref org-indent-stars nstars)
+ 'wrap-prefix
+ (aref org-indent-strings
+ (* (funcall get-real-level e level)
+ org-indent-indentation-per-level)))))
+ (when (> e b)
+ (add-text-properties
+ b e (list 'line-prefix (aref org-indent-strings n)
+ 'wrap-prefix (aref org-indent-strings n))))
+ (setq b (1+ (point-at-eol))
+ n (* (funcall get-real-level b level)
+ org-indent-indentation-per-level)))))))
(defun org-indent-refresh-section ()
"Refresh indentation properties in the current outline section.
@@ -255,7 +268,11 @@ Point is assumed to be at the beginning of a headline."
(when org-indent-mode
(let (beg end)
(save-excursion
- (when (ignore-errors (org-back-to-heading))
+ (when (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
+ (if (featurep 'org-inlinetask)
+ (1- org-inlinetask-min-level)
+ ""))))
+ (org-back-to-heading)))
(setq beg (point))
(setq end (or (save-excursion (or (outline-next-heading) (point)))))
(org-indent-remove-properties beg end)
@@ -268,7 +285,11 @@ Point is assumed to be at the beginning of a headline."
(when org-indent-mode
(let ((beg (point)) (end limit))
(save-excursion
- (and (ignore-errors (org-back-to-heading t))
+ (and (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
+ (if (featurep 'org-inlinetask)
+ (1- org-inlinetask-min-level)
+ ""))))
+ (org-back-to-heading)))
(setq beg (point))))
(org-indent-remove-properties beg end)
(org-indent-add-properties beg end)))