unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to switch paragraph-indent-minor-mode off?
@ 2007-04-17 14:28 Rodolfo Medina
  2007-04-17 17:21 ` Amy Templeton
  2007-04-20 14:41 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Rodolfo Medina @ 2007-04-17 14:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hi.

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?

Thanks,
Rodolfo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to switch paragraph-indent-minor-mode off?
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Amy Templeton @ 2007-04-17 17:21 UTC (permalink / raw)
  To: help-gnu-emacs

Rudolfo Medina wrote:
> then if I want to disable it again I must exit emacs and
> restart it.

You don't actually need to restart all of Emacs; if you just
kill the buffer (C-x k RET will kill the current buffer) and
then find the file (C-x C-f filename or path/to/file) it
will find the file in default text mode, without
paragraph-indent-minor-mode enabled. 

If you don't want to kill the buffer, however, you could
always put together a simple function such as this:

(defun parindent-off ()
  (interactive)
  (paragraph-indent-text-mode)
  (text-mode))

...in your .emacs file. Turning on
paragraph-indent-text-mode seems to turn off
paragraph-indent-minor-mode, so by going from there to text
mode you turn off the minor mode. There are doubtless more
graceful solutions out there, but this works as a quick fix.

Hope that helps.

Amy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to switch paragraph-indent-minor-mode off?
  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
  2007-04-25  5:01   ` Stefan Monnier
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2007-04-20 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to switch paragraph-indent-minor-mode off?
  2007-04-20 14:41 ` Stefan Monnier
@ 2007-04-25  5:01   ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2007-04-25  5:01 UTC (permalink / raw)
  To: help-gnu-emacs

> (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'."

And here I forgot the following line:

  nil nil nil

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

Sorry,


        Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-04-25  5:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-04-25  5:01   ` Stefan Monnier

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