unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: How to switch paragraph-indent-minor-mode off?
Date: Fri, 20 Apr 2007 10:41:27 -0400	[thread overview]
Message-ID: <jwvwt079kji.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: 87ps63gjmy.fsf@gmail.com

> 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))))

  parent reply	other threads:[~2007-04-20 14:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 14:28 How to switch paragraph-indent-minor-mode off? Rodolfo Medina
2007-04-17 17:21 ` Amy Templeton
2007-04-20 14:41 ` Stefan Monnier [this message]
2007-04-25  5:01   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwt079kji.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).