Mercurial > emacs
comparison lisp/org/org-indent.el @ 109469:f2f8baec8e43
Merge from mainline.
author | Katsumi Yamaoka <katsumi@flagship2> |
---|---|
date | Mon, 19 Jul 2010 11:26:46 +0000 |
parents | a150e8a14679 |
children | 5cb272c831e8 |
comparison
equal
deleted
inserted
replaced
109468:af1c1a57ee7f | 109469:f2f8baec8e43 |
---|---|
2 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. | 2 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
3 ;; | 3 ;; |
4 ;; Author: Carsten Dominik <carsten at orgmode dot org> | 4 ;; Author: Carsten Dominik <carsten at orgmode dot org> |
5 ;; Keywords: outlines, hypermedia, calendar, wp | 5 ;; Keywords: outlines, hypermedia, calendar, wp |
6 ;; Homepage: http://orgmode.org | 6 ;; Homepage: http://orgmode.org |
7 ;; Version: 6.35i | 7 ;; Version: 7.01 |
8 ;; | 8 ;; |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 ;; | 10 ;; |
11 ;; GNU Emacs is free software: you can redistribute it and/or modify | 11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
12 ;; it under the terms of the GNU General Public License as published by | 12 ;; it under the terms of the GNU General Public License as published by |
27 | 27 |
28 ;; This is an implementation of dynamic virtual indentation. It works | 28 ;; This is an implementation of dynamic virtual indentation. It works |
29 ;; by adding text properties to a buffer to make sure lines are | 29 ;; by adding text properties to a buffer to make sure lines are |
30 ;; indented according to outline structure. | 30 ;; indented according to outline structure. |
31 | 31 |
32 ;;; Code: | |
33 | |
32 (require 'org-macs) | 34 (require 'org-macs) |
33 (require 'org-compat) | 35 (require 'org-compat) |
34 (require 'org) | 36 (require 'org) |
37 | |
35 (eval-when-compile | 38 (eval-when-compile |
36 (require 'cl)) | 39 (require 'cl)) |
37 | |
38 | 40 |
39 (defgroup org-indent nil | 41 (defgroup org-indent nil |
40 "Options concerning dynamic virtual outline indentation." | 42 "Options concerning dynamic virtual outline indentation." |
41 :tag "Org Indent" | 43 :tag "Org Indent" |
42 :group 'org) | 44 :group 'org) |
43 | 45 |
44 (defconst org-indent-max 40 | 46 (defconst org-indent-max 40 |
45 "Maximum indentation in characters") | 47 "Maximum indentation in characters.") |
46 (defconst org-indent-max-levels 40 | 48 (defconst org-indent-max-levels 40 |
47 "Maximum indentation in characters") | 49 "Maximum indentation in characters.") |
48 | 50 |
49 (defvar org-indent-strings nil | 51 (defvar org-indent-strings nil |
50 "Vector with all indentation strings. | 52 "Vector with all indentation strings. |
51 It will be set in `org-indent-initialize'.") | 53 It will be set in `org-indent-initialize'.") |
52 (defvar org-indent-stars nil | 54 (defvar org-indent-stars nil |
53 "Vector with all indentation star strings. | 55 "Vector with all indentation star strings. |
54 It will be set in `org-indent-initialize'.") | 56 It will be set in `org-indent-initialize'.") |
55 (defvar org-hide-leading-stars-before-indent-mode nil | 57 (defvar org-hide-leading-stars-before-indent-mode nil |
56 "Used locally") | 58 "Used locally.") |
57 | 59 |
58 (defcustom org-indent-boundary-char ?\ ; comment to protect space char | 60 (defcustom org-indent-boundary-char ?\ ; comment to protect space char |
59 "The end of the virtual indentation strings, a single-character string. | 61 "The end of the virtual indentation strings, a single-character string. |
60 The default is just a space, but if you wish, you can use \"|\" or so. | 62 The default is just a space, but if you wish, you can use \"|\" or so. |
61 This can be useful on a terminal window - under a windowing system, | 63 This can be useful on a terminal window - under a windowing system, |
65 (set var val) | 67 (set var val) |
66 (and org-indent-strings (org-indent-initialize))) | 68 (and org-indent-strings (org-indent-initialize))) |
67 :type 'character) | 69 :type 'character) |
68 | 70 |
69 (defcustom org-indent-mode-turns-off-org-adapt-indentation t | 71 (defcustom org-indent-mode-turns-off-org-adapt-indentation t |
70 "Non-nil means turning on `org-indent-mode' turns off indentation adaptation. | 72 "Non-nil means setting the variable `org-indent-mode' will \ |
73 turn off indentation adaptation. | |
71 For details see the variable `org-adapt-indentation'." | 74 For details see the variable `org-adapt-indentation'." |
72 :group 'org-indent | 75 :group 'org-indent |
73 :type 'boolean) | 76 :type 'boolean) |
74 | 77 |
75 (defcustom org-indent-mode-turns-on-hiding-stars t | 78 (defcustom org-indent-mode-turns-on-hiding-stars t |
76 "Non-nil means turning on `org-indent-mode' turns on `org-hide-leading-stars'." | 79 "Non-nil means setting the variable `org-indent-mode' will \ |
80 turn on `org-hide-leading-stars'." | |
77 :group 'org-indent | 81 :group 'org-indent |
78 :type 'boolean) | 82 :type 'boolean) |
79 | 83 |
80 (defcustom org-indent-indentation-per-level 2 | 84 (defcustom org-indent-indentation-per-level 2 |
81 "Indentation per level in number of characters." | 85 "Indentation per level in number of characters." |
125 | 129 |
126 Internally this works by adding `line-prefix' properties to all non-headlines. | 130 Internally this works by adding `line-prefix' properties to all non-headlines. |
127 These properties are updated locally in idle time. | 131 These properties are updated locally in idle time. |
128 FIXME: How to update when broken?" | 132 FIXME: How to update when broken?" |
129 nil " Ind" nil | 133 nil " Ind" nil |
130 (if (org-bound-and-true-p org-inhibit-startup) | 134 (cond |
131 (setq org-indent-mode nil) | 135 ((org-bound-and-true-p org-inhibit-startup) |
132 (if org-indent-mode | 136 (setq org-indent-mode nil)) |
133 (progn | 137 ((and org-indent-mode (featurep 'xemacs)) |
134 (or org-indent-strings (org-indent-initialize)) | 138 (message "org-indent-mode does not work in XEmacs - refused to turn it on") |
135 (when org-indent-mode-turns-off-org-adapt-indentation | 139 (setq org-indent-mode nil)) |
136 (org-set-local 'org-adapt-indentation nil)) | 140 ((and org-indent-mode |
137 (when org-indent-mode-turns-on-hiding-stars | 141 (not (org-version-check "23.1.50" "Org Indent mode" :predicate))) |
138 (org-set-local 'org-hide-leading-stars-before-indent-mode | 142 (message "org-indent-mode is can crash Emacs 23.1 - refused to turn it on!") |
139 org-hide-leading-stars) | 143 (ding) |
140 (org-set-local 'org-hide-leading-stars t)) | 144 (sit-for 1) |
141 (make-local-variable 'buffer-substring-filters) | 145 (setq org-indent-mode nil)) |
142 (add-to-list 'buffer-substring-filters | 146 (org-indent-mode |
143 'org-indent-remove-properties-from-string) | 147 ;; mode was turned on. |
144 (org-add-hook 'org-after-demote-entry-hook | 148 (org-set-local 'indent-tabs-mode nil) |
145 'org-indent-refresh-section nil 'local) | 149 (or org-indent-strings (org-indent-initialize)) |
146 (org-add-hook 'org-after-promote-entry-hook | 150 (when org-indent-mode-turns-off-org-adapt-indentation |
147 'org-indent-refresh-section nil 'local) | 151 (org-set-local 'org-adapt-indentation nil)) |
148 (org-add-hook 'org-font-lock-hook | 152 (when org-indent-mode-turns-on-hiding-stars |
149 'org-indent-refresh-to nil 'local) | 153 (org-set-local 'org-hide-leading-stars-before-indent-mode |
150 (and font-lock-mode (org-restart-font-lock)) | 154 org-hide-leading-stars) |
151 ) | 155 (org-set-local 'org-hide-leading-stars t)) |
152 (save-excursion | 156 (make-local-variable 'buffer-substring-filters) |
153 (save-restriction | 157 (add-to-list 'buffer-substring-filters |
154 (org-indent-remove-properties (point-min) (point-max)) | 158 'org-indent-remove-properties-from-string) |
155 (kill-local-variable 'org-adapt-indentation) | 159 (org-add-hook 'org-after-demote-entry-hook |
156 (when (boundp 'org-hide-leading-stars-before-indent-mode) | 160 'org-indent-refresh-section nil 'local) |
157 (org-set-local 'org-hide-leading-stars | 161 (org-add-hook 'org-after-promote-entry-hook |
158 org-hide-leading-stars-before-indent-mode)) | 162 'org-indent-refresh-section nil 'local) |
159 (setq buffer-substring-filters | 163 (org-add-hook 'org-font-lock-hook |
160 (delq 'org-indent-remove-properties-from-string | 164 'org-indent-refresh-to nil 'local) |
161 buffer-substring-filters)) | 165 (and font-lock-mode (org-restart-font-lock)) |
162 (remove-hook 'org-after-promote-entry-hook | 166 ) |
163 'org-indent-refresh-section 'local) | 167 (t |
164 (remove-hook 'org-after-demote-entry-hook | 168 ;; mode was turned off (or we refused to turn it on) |
165 'org-indent-refresh-section 'local) | 169 (save-excursion |
166 (and font-lock-mode (org-restart-font-lock)) | 170 (save-restriction |
167 (redraw-display)))))) | 171 (org-indent-remove-properties (point-min) (point-max)) |
172 (kill-local-variable 'org-adapt-indentation) | |
173 (when (boundp 'org-hide-leading-stars-before-indent-mode) | |
174 (org-set-local 'org-hide-leading-stars | |
175 org-hide-leading-stars-before-indent-mode)) | |
176 (setq buffer-substring-filters | |
177 (delq 'org-indent-remove-properties-from-string | |
178 buffer-substring-filters)) | |
179 (remove-hook 'org-after-promote-entry-hook | |
180 'org-indent-refresh-section 'local) | |
181 (remove-hook 'org-after-demote-entry-hook | |
182 'org-indent-refresh-section 'local) | |
183 (and font-lock-mode (org-restart-font-lock)) | |
184 (redraw-display)))))) | |
168 | 185 |
169 | 186 |
170 (defface org-indent | 187 (defface org-indent |
171 (org-compatible-face nil nil) | 188 (org-compatible-face nil nil) |
172 "Face for outline indentation. | 189 "Face for outline indentation. |