From 040b2aa6b2d8e1d83a9ccd6c399d1a311416aeaa Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 5 Jul 2010 17:46:19 +0200 Subject: [PATCH] Indent-mode: Disable in Emacs 21 and earlier * lisp/org-indent.el (org-indent-mode): Refuse to turn on prior to Emacs 23.2 --- doc/org.texi | 11 +++--- lisp/org-indent.el | 89 ++++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index eb9115241..4e9f093f4 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -12687,12 +12687,11 @@ more text | more text @noindent -If you are using at least Emacs 23.2 and version 6.29 of Org, this kind of -view can be achieved dynamically at display time using -@code{org-indent-mode}. @i{Using this with earlier versions of Emacs can -lead to crashes.} In this minor -mode, all lines are prefixed for display with the necessary amount of -space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix} +If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash +with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can +be achieved dynamically at display time using @code{org-indent-mode}. In +this minor mode, all lines are prefixed for display with the necessary amount +of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix} property, such that @code{visual-line-mode} (or purely setting @code{word-wrap}) wraps long lines (including headlines) correctly indented. }. Also headlines are prefixed with additional stars, so that the amount of diff --git a/lisp/org-indent.el b/lisp/org-indent.el index 77411afdc..70618cb93 100644 --- a/lisp/org-indent.el +++ b/lisp/org-indent.el @@ -127,45 +127,56 @@ Internally this works by adding `line-prefix' properties to all non-headlines. These properties are updated locally in idle time. FIXME: How to update when broken?" nil " Ind" nil - (if (org-bound-and-true-p org-inhibit-startup) - (setq org-indent-mode nil) - (if org-indent-mode - (progn - (org-set-local 'indent-tabs-mode nil) - (or org-indent-strings (org-indent-initialize)) - (when org-indent-mode-turns-off-org-adapt-indentation - (org-set-local 'org-adapt-indentation nil)) - (when org-indent-mode-turns-on-hiding-stars - (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) - (org-add-hook 'org-after-demote-entry-hook - 'org-indent-refresh-section nil 'local) - (org-add-hook 'org-after-promote-entry-hook - 'org-indent-refresh-section nil 'local) - (org-add-hook 'org-font-lock-hook - 'org-indent-refresh-to nil 'local) - (and font-lock-mode (org-restart-font-lock)) - ) - (save-excursion - (save-restriction - (org-indent-remove-properties (point-min) (point-max)) - (kill-local-variable 'org-adapt-indentation) - (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 'org-after-promote-entry-hook - 'org-indent-refresh-section 'local) - (remove-hook 'org-after-demote-entry-hook - 'org-indent-refresh-section 'local) - (and font-lock-mode (org-restart-font-lock)) - (redraw-display)))))) + (cond + ((org-bound-and-true-p org-inhibit-startup) + (setq org-indent-mode nil)) + ((and org-indent-mode + (or (< emacs-major-version 23) + (and (= emacs-major-version 23) + (< emacs-minor-version 2)))) + (message "org-indent-mode is can crash Emacs 23.1 - refused to turn it on!") + (ding) + (sit-for 1) + (setq org-indent-mode nil)) + (org-indent-mode + ;; mode was turned on. + (org-set-local 'indent-tabs-mode nil) + (or org-indent-strings (org-indent-initialize)) + (when org-indent-mode-turns-off-org-adapt-indentation + (org-set-local 'org-adapt-indentation nil)) + (when org-indent-mode-turns-on-hiding-stars + (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) + (org-add-hook 'org-after-demote-entry-hook + 'org-indent-refresh-section nil 'local) + (org-add-hook 'org-after-promote-entry-hook + 'org-indent-refresh-section nil 'local) + (org-add-hook 'org-font-lock-hook + 'org-indent-refresh-to nil 'local) + (and font-lock-mode (org-restart-font-lock)) + ) + (t + ;; mode was turned off (or we refused to turn it on) + (save-excursion + (save-restriction + (org-indent-remove-properties (point-min) (point-max)) + (kill-local-variable 'org-adapt-indentation) + (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 'org-after-promote-entry-hook + 'org-indent-refresh-section 'local) + (remove-hook 'org-after-demote-entry-hook + 'org-indent-refresh-section 'local) + (and font-lock-mode (org-restart-font-lock)) + (redraw-display)))))) (defface org-indent