[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to switch paragraph-indent-minor-mode off?
From: |
Stefan Monnier |
Subject: |
Re: How to switch paragraph-indent-minor-mode off? |
Date: |
Fri, 20 Apr 2007 10:41:27 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux) |
> In text mode, when I want to enable paragraph-indent-minor-mode, I simply
> do: `M-x paragraph-indent-minor-mode RET'; but then if I want to disable
> it again I must exit Emacs and restart it. Can anyone suggest how to
> switch on and off at pleasure the paragraph-indent-minor-mode within the
> same buffer?
You can try using the following definition which fixes
paragraph-indent-minor-mode to really be a minor mode as the name implies.
Stefan
(define-minor-mode paragraph-indent-minor-mode
"Minor mode for editing text, with leading spaces starting a paragraph.
In this mode, you do not need blank lines between paragraphs when the
first line of the following paragraph starts with whitespace, as with
`paragraph-indent-text-mode'.
Turning on Paragraph-Indent minor mode runs the normal hook
`paragraph-indent-text-mode-hook'."
;; Change the definition of a paragraph start.
(let ((ps-re "[ \t\n\f]\\|"))
(if (eq t (compare-strings ps-re nil nil
paragraph-start nil (length ps-re)))
(if (not paragraph-indent-minor-mode)
(set (make-local-variable 'paragraph-start)
(substring paragraph-start (length ps-re))))
(if paragraph-indent-minor-mode
(set (make-local-variable 'paragraph-start)
(concat ps-re paragraph-start)))))
;; Change the indentation function.
(if paragraph-indent-minor-mode
(set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
(if (eq indent-line-function 'indent-to-left-margin)
(set (make-local-variable 'indent-line-function) 'indent-region))))