all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Roche <Tom_Roche@pobox.com>
To: help-gnu-emacs@gnu.org,
Subject: Re: [C-u M-q] -> unfill-paragraph
Date: Mon, 14 Nov 2011 12:27:38 -0500	[thread overview]
Message-ID: <87pqgu7gxh.fsf@pobox.com> (raw)
In-Reply-To: <87lirjz7uc.fsf@ericabrahamsen.net>


[Text-mode tables enclosed--best viewed in monospace font--
 and there's also some utf-8]

Tom Roche Thu, 10 Nov 2011 12:29:33 -0500
>>>> [How] to write one's own `fill-paragraph' façade such that

>>>> * [my-fill-paragraph hides] the emacs-provided `fill-paragraph'

>>>> * [my-fill-paragraph delegates] to the emacs-provided
>>>>   `fill-paragraph' except when called with [C-u]

Scott Frazer Thu, 10 Nov 2011 14:00:14 -0500
>>> (defun my-fill-paragraph (&optional arg)
>>>   (interactive "P")
>>>   (let ((fill-column (if arg (point-max) fill-column)))
>>>     (fill-paragraph)))

>>> (global-set-key (kbd "M-q") 'my-fill-paragraph)

Tom Roche Sun, 13 Nov 2011 10:52:44 -0500
>> That works, except for region handling[, i.e.,]

>> +--------------------------------------------------------------+
>> |                    | M-q              | C-u M-q              |
>> +--------------------------------------------------------------+
>> | no region selected | fill paragraph   | unfill paragraph     |
>> |                    | surrounding or   | surrounding or       |
>> |                    | following point  | following point      |
>> +--------------------------------------------------------------+
>> | region selected    | nothing          | unfills (only)       |
>> |                    |                  | first paragraph      |
>> |                    |                  | in the region        |
>> +--------------------------------------------------------------+

>> What I want is

>> +-----------------------------------------------------------+
>> |                    | M-q              | C-u M-q           |
>> +-----------------------------------------------------------+
>> | no region selected | fill paragraph   | unfill paragraph  |
>> |                    | surrounding or   | surrounding or    |
>> |                    | following point  | following point   |
>> +-----------------------------------------------------------+
>> | region selected    | fill all         | unfill all        |
>> |                    | paragraphs in    | paragraphs in     |
>> |                    | the region       | the region        |
>> +-----------------------------------------------------------+

>> Note that the wanted region-handling behaviors are those which one
>> gets using M-x, i.e., with region selected

>> * `M-x fill-paragraph' fills all paragraphs in the selected region

>> * `M-x unfill-paragraph' unfills all paragraphs in the selected region

Eric Abrahamsen Mon, 14 Nov 2011 11:44:11 +0800
> Scott's basic approach is still correct: bind M-q to what you want,

Yes, that I understand.

> `call-interactively' ensures that whatever prefix arguments
> `fill-paragraph' and `unfill-paragraph' might take (the region being
> the important one here) are passed to those commands properly.

Thanks! This indeed seems to work as desired:

(defun my-fill-paragraph (&optional arg)
  (interactive "P")
  (if arg
    (call-interactively 'unfill-paragraph)
    (call-interactively 'fill-paragraph)))

(global-set-key (kbd "M-q") 'my-fill-paragraph)

I'll "field-test" today then post gnu-emacs-sources (with attribution).



      parent reply	other threads:[~2011-11-14 17:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 21:15 [C-u M-q] -> unfill-paragraph Tom Roche
2011-11-10  3:55 ` Eric Abrahamsen
2011-11-10 17:29 ` Tom Roche
2011-11-10 19:00   ` Scott Frazer
2011-11-13  1:50   ` Tom Roche
2011-11-13 15:52   ` Tom Roche
2011-11-14  3:44     ` Eric Abrahamsen
2011-11-14 17:27   ` Tom Roche [this message]

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

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

  git send-email \
    --in-reply-to=87pqgu7gxh.fsf@pobox.com \
    --to=tom_roche@pobox.com \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.