]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-indent.el
Merge from trunk; up to 2013-02-18T01:30:27Z!monnier@iro.umontreal.ca.
[gnu-emacs] / lisp / org / org-indent.el
index ae0c91eaedff462ebd511ccdfd9f163425b3e22a..d5f17b2cb69f42cc88421030038d04cc5c931aae 100644 (file)
@@ -1,5 +1,5 @@
 ;;; org-indent.el --- Dynamic indentation for  Org-mode
-;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -45,6 +45,7 @@
 (declare-function org-inlinetask-get-task-level "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
 (declare-function org-list-item-body-column "org-list" (item))
+(defvar org-inlinetask-show-first-star)
 
 (defgroup org-indent nil
   "Options concerning dynamic virtual outline indentation."
@@ -158,10 +159,9 @@ properties, after each buffer modification, on the modified zone.
 
 The process is synchronous.  Though, initial indentation of
 buffer, which can take a few seconds on large buffers, is done
-during idle time." nil " Ind" nil
+during idle time."
+  nil " Ind" nil
   (cond
-   ((org-bound-and-true-p org-inhibit-startup)
-    (setq org-indent-mode nil))
    ((and org-indent-mode (featurep 'xemacs))
     (message "org-indent-mode does not work in XEmacs - refusing to turn it on")
     (setq org-indent-mode nil))
@@ -182,9 +182,11 @@ during idle time." nil " Ind" nil
       (org-set-local 'org-hide-leading-stars-before-indent-mode
                     org-hide-leading-stars)
       (org-set-local 'org-hide-leading-stars t))
-    (make-local-variable 'buffer-substring-filters)
-    (add-to-list 'buffer-substring-filters
-                'org-indent-remove-properties-from-string)
+    (make-local-variable 'filter-buffer-substring-functions)
+    (add-hook 'filter-buffer-substring-functions
+             (lambda (fun start end delete)
+               (org-indent-remove-properties-from-string
+                (funcall fun start end delete))))
     (org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
     (org-add-hook 'before-change-functions
                  'org-indent-notify-modified-headline nil 'local)
@@ -208,9 +210,10 @@ during idle time." nil " Ind" nil
     (when (boundp 'org-hide-leading-stars-before-indent-mode)
       (org-set-local 'org-hide-leading-stars
                     org-hide-leading-stars-before-indent-mode))
-    (setq buffer-substring-filters
-         (delq 'org-indent-remove-properties-from-string
-               buffer-substring-filters))
+    (remove-hook 'filter-buffer-substring-functions
+                (lambda (fun start end delete)
+                  (org-indent-remove-properties-from-string
+                   (funcall fun start end delete))))
     (remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
     (remove-hook 'before-change-functions
                 'org-indent-notify-modified-headline 'local)
@@ -222,9 +225,9 @@ during idle time." nil " Ind" nil
 (defun org-indent-indent-buffer ()
   "Add indentation properties to the accessible part of the buffer."
   (interactive)
-  (if (not (eq major-mode 'org-mode))
+  (if (not (derived-mode-p 'org-mode))
       (error "Not in Org mode")
-    (message "Setting buffer indentation. It may take a few seconds...")
+    (message "Setting buffer indentation.  It may take a few seconds...")
     (org-indent-remove-properties (point-min) (point-max))
     (org-indent-add-properties (point-min) (point-max))
     (message "Indentation of buffer set.")))
@@ -293,8 +296,10 @@ Assume point is at beginning of line."
                (let ((stars (aref org-indent-stars
                                   (min l org-indent-max-levels))))
                  (and stars
-                      (concat org-indent-inlinetask-first-star
-                              (substring stars 1)))))
+                      (if (org-bound-and-true-p org-inlinetask-show-first-star)
+                          (concat org-indent-inlinetask-first-star
+                                  (substring stars 1))
+                        stars))))
               (h (aref org-indent-stars
                        (min l org-indent-max-levels)))
               (t (aref org-indent-strings
@@ -412,16 +417,21 @@ This function is meant to be called by `after-change-functions'."
       (if (or org-indent-modified-headline-flag
              (save-excursion
                (goto-char beg)
+               (beginning-of-line)
                (re-search-forward org-outline-regexp-bol end t)))
-       (let ((end (save-excursion
-                    (goto-char end)
-                    (org-with-limited-levels (outline-next-heading))
-                    (point))))
-         (setq org-indent-modified-headline-flag nil)
-         (org-indent-add-properties beg end))
+         (let ((end (save-excursion
+                      (goto-char end)
+                      (org-with-limited-levels (outline-next-heading))
+                      (point))))
+           (setq org-indent-modified-headline-flag nil)
+           (org-indent-add-properties beg end))
        ;; Otherwise, only set properties on modified area.
        (org-indent-add-properties beg end)))))
 
 (provide 'org-indent)
 
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
 ;;; org-indent.el ends here