summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-11-17 23:08:15 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2010-11-18 16:35:46 +0100
commitc538b0eeab5e9c62dfdc447acd9b5ce4cabd92f0 (patch)
tree9d38e8a1639f7f6a4313b00e1fc71f1549c4a211
parent97f4c3f9a1bffef82593af25b43a87f0768f3f3c (diff)
downloadorg-mode-c538b0eeab5e9c62dfdc447acd9b5ce4cabd92f0.tar.gz
Fix indentation of drawers, blocks and literal examples
* lisp/org.el (org-indent-line-function): drawers and blocks have no influence on indentation of text below. Also fix indentation problem with a block at column 0 and add a special case for literal examples.
-rw-r--r--lisp/org.el33
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/org.el b/lisp/org.el
index e45dab0..023e019 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18671,7 +18671,7 @@ which make use of the date at the cursor."
;; We want this to be just right, so use the full arsenal.
(defun org-indent-line-function ()
- "Indent line like previous, but further if previous was headline or item."
+ "Indent line depending on context."
(interactive)
(let* ((pos (point))
(itemp (org-at-item-p))
@@ -18680,13 +18680,15 @@ which make use of the date at the cursor."
(inline-task-p (and (featurep 'org-inlinetask)
(org-inlinetask-in-task-p)))
column bpos bcol tpos tcol)
- ;; Find the previous relevant line
(beginning-of-line 1)
(cond
;; Comments
- ((looking-at "#") (setq column 0))
+ ((looking-at "# ") (setq column 0))
;; Headings
((looking-at "\\*+ ") (setq column 0))
+ ;; Literal examples
+ ((looking-at "[ \t]*:[ \t]")
+ (setq column (org-get-indentation))) ; do nothing
;; Drawers
((and (looking-at "[ \t]*:END:")
(save-excursion (re-search-backward org-drawer-regexp nil t)))
@@ -18719,20 +18721,23 @@ which make use of the date at the cursor."
(setq tcol (+ bcol 5)))
(goto-char pos)
(setq column (if itemp (org-get-indentation) tcol)))
- ;; This line has nothing special, look upside to get a clue about
- ;; what to do.
+ ;; This line has nothing special, look at the previous relevant
+ ;; line to compute indentation
(t
(beginning-of-line 0)
(while (and (not (bobp))
+ (not (looking-at org-drawer-regexp))
;; skip comments, verbatim, empty lines, tables,
- ;; inline tasks
- (or (looking-at "[ \t]*[\n:#|]")
+ ;; inline tasks, lists, drawers and blocks
+ (or (and (looking-at "[ \t]*:END:")
+ (re-search-backward org-drawer-regexp nil t))
+ (and (looking-at "[ \t]*#\\+end_")
+ (re-search-backward "[ \t]*#\\+begin_"nil t))
+ (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)))
+ (org-inlinetask-in-task-p))))
(beginning-of-line 0))
(cond
;; There was an heading above.
@@ -18741,20 +18746,18 @@ which make use of the date at the cursor."
(setq column 0)
(goto-char (match-end 0))
(setq column (current-column))))
- ;; A drawer had started and is unfinished: indent consequently.
+ ;; A drawer had started and is unfinished
((looking-at org-drawer-regexp)
(goto-char (1- (match-beginning 1)))
(setq column (current-column)))
- ;; The drawer had ended: indent like its :END: line.
- ((looking-at "\\([ \t]*\\):END:")
- (goto-char (match-end 1))
- (setq column (current-column)))
;; Else, nothing noticeable found: get indentation and go on.
(t (setq column (org-get-indentation))))))
+ ;; Now apply indentation and move cursor accordingly
(goto-char pos)
(if (<= (current-column) (current-indentation))
(org-indent-line-to column)
(save-excursion (org-indent-line-to column)))
+ ;; Special polishing for properties, see `org-property-format'
(setq column (current-column))
(beginning-of-line 1)
(if (looking-at