summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-10-14 10:16:06 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-10-14 10:16:06 +0200
commitf5152e03a12a3256bf6c7ecaffd5b421a1fa606a (patch)
tree0d009b8a0ad8f4603171e513e7d6592c7d7b38bf
parent79e8552ed38d17e9e90caf27cf485fc44ac00bb6 (diff)
downloadorg-mode-f5152e03a12a3256bf6c7ecaffd5b421a1fa606a.tar.gz
Fix indentation of text in inline tasks
* lisp/org-inlinetask.el (org-inlinetask-in-task-p): New function. * lisp/org.el (org-indent-line-function): Fix indentation of inline tasks Patch by Nicolas Goaziou
-rw-r--r--lisp/org-inlinetask.el16
-rw-r--r--lisp/org.el21
2 files changed, 26 insertions, 11 deletions
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el
index fce515d..e18dce8 100644
--- a/lisp/org-inlinetask.el
+++ b/lisp/org-inlinetask.el
@@ -129,6 +129,22 @@ If prefix arg NO-STATE is set, ignore `org-inlinetask-defaut-state'."
(end-of-line -1))
(define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
+(defun org-inlinetask-in-task-p ()
+ "Return true if point is inside an inline task."
+ (save-excursion
+ (let* ((nstars (if org-odd-levels-only
+ (1- (* 2 (or org-inlinetask-min-level 200)))
+ (or org-inlinetask-min-level 200)))
+ (stars-re (concat "^\\(?:\\*\\{"
+ (format "%d" (- nstars 1))
+ ",\\}\\)[ \t]+"))
+ (task-beg-re (concat stars-re "\\(?:.*\\)"))
+ (task-end-re (concat stars-re "\\(?:END\\|end\\)")))
+ (beginning-of-line)
+ (or (looking-at task-beg-re)
+ (and (re-search-forward "^\\*+[ \t]+" nil t)
+ (progn (beginning-of-line) (looking-at task-end-re)))))))
+
(defvar htmlp) ; dynamically scoped into the next function
(defvar latexp) ; dynamically scoped into the next function
(defun org-inlinetask-export-handler ()
diff --git a/lisp/org.el b/lisp/org.el
index 53a2b47..c49d171 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18601,6 +18601,8 @@ which make use of the date at the cursor."
(itemp (org-at-item-p))
(case-fold-search t)
(org-drawer-regexp (or org-drawer-regexp "\000"))
+ (inline-task-p (and (featurep 'org-inlinetask)
+ (org-inlinetask-in-task-p)))
column bpos bcol tpos tcol bullet btype bullet-type)
;; Find the previous relevant line
(beginning-of-line 1)
@@ -18656,7 +18658,14 @@ which make use of the date at the cursor."
;; what to do.
(t
(beginning-of-line 0)
- (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]")
+ (while (and (not (bobp))
+ ;; skip comments, verbatim, empty lines, tables,
+ ;; inline tasks
+ (or (looking-at "[ \t]*[\n:#|]")
+ (and (org-in-item-p) (goto-char (org-list-top-point)))
+ (and (not inline-task-p)
+ (featurep 'org-inlinetask)
+ (org-inlinetask-in-task-p)))
(not (looking-at "[ \t]*:END:"))
(not (looking-at org-drawer-regexp)))
(beginning-of-line 0))
@@ -18675,16 +18684,6 @@ which make use of the date at the cursor."
((looking-at "\\([ \t]*\\):END:")
(goto-char (match-end 1))
(setq column (current-column)))
- ;; There was a list that since ended: indent relatively to
- ;; current heading.
- ((org-in-item-p)
- (outline-previous-heading)
- (if (and org-adapt-indentation
- (looking-at "\\*+[ \t]+"))
- (progn
- (goto-char (match-end 0))
- (setq column (current-column)))
- (setq column 0)))
;; Else, nothing noticeable found: get indentation and go on.
(t (setq column (org-get-indentation))))))
(goto-char pos)