diff lisp/org/org-indent.el @ 111880:a7740098b594

Update to Org mode 7.4
author Carsten Dominik <carsten.dominik@gmail.com>
date Sat, 11 Dec 2010 17:42:53 +0100
parents 5cb272c831e8
children 417b1e4d63cd
line wrap: on
line diff
--- a/lisp/org/org-indent.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-indent.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -38,6 +38,10 @@
 (eval-when-compile
   (require 'cl))
 
+(defvar org-inlinetask-min-level)
+(declare-function org-inlinetask-get-task-level "org-inlinetask" ())
+(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
+
 (defgroup org-indent nil
   "Options concerning dynamic virtual outline indentation."
   :tag "Org Indent"
@@ -219,35 +223,49 @@
 (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)))))))
 
+(defvar org-inlinetask-min-level)
 (defun org-indent-refresh-section ()
   "Refresh indentation properties in the current outline section.
 Point is assumed to be at the beginning of a headline."
@@ -255,7 +273,11 @@
   (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 +290,11 @@
   (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)))