From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Roche Newsgroups: gmane.emacs.help Subject: Re: [C-u M-q] -> unfill-paragraph Date: Mon, 14 Nov 2011 12:27:38 -0500 Message-ID: <87pqgu7gxh.fsf@pobox.com> References: <87lirjz7uc.fsf@ericabrahamsen.net> <87zkg02f5f.fsf@pobox.com> <87mxc023k6.fsf@pobox.com> <87lirn28ea.fsf@pobox.com> Reply-To: help-gnu-emacs@gnu.org, Tom Roche NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1321291573 19761 80.91.229.12 (14 Nov 2011 17:26:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 14 Nov 2011 17:26:13 +0000 (UTC) To: help-gnu-emacs@gnu.org, Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 14 18:26:10 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RQ0IK-0007nj-BX for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Nov 2011 18:26:08 +0100 Original-Received: from localhost ([::1]:51785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ0IJ-0000t4-Cc for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Nov 2011 12:26:07 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:56903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ0IB-0000rv-7r for help-gnu-emacs@gnu.org; Mon, 14 Nov 2011 12:26:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ0I7-0007Zg-9K for help-gnu-emacs@gnu.org; Mon, 14 Nov 2011 12:25:59 -0500 Original-Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:65383 helo=smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ0I7-0007ZU-6H for help-gnu-emacs@gnu.org; Mon, 14 Nov 2011 12:25:55 -0500 Original-Received: from smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 68A26670D; Mon, 14 Nov 2011 12:25:53 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:in-reply-to:references:reply-to:date:message-id :mime-version:content-type:content-transfer-encoding; s=sasl; bh=hPuHAXyZiYOhOeDYUKl+bUXsh44=; b=ieib7Autrcfj4tZbO1NhRKHeD1nN BxHW6gWCGXC9Nnn3lrGPAftQX6O0/g5sZ5O0wkjgT+VZhupLxHTNCr6qtiAnLe0f jMvleBDovehld7NFQrEeUWBWBUZqrNAJonnto7buk+xzs1wuhMURwHEVlSwETw0X Hn4whIAfcP11rtQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :in-reply-to:references:reply-to:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=NYM3pO toUjaHYoaUTrUAPV4+p/yn+SmeyfovrBkLmkF+I63yamsAIHYfkLNy0YD669/ehi O7J8IthlbTVHfhJdCenGNJNSw8JE3crBdFqdUQXKuPHGR0XE6R+drEzix4D+CfmG 8XcZTAQxnNxmVFMC+yGJ0liRoaVii3GX9ckJU= Original-Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 601EA670B; Mon, 14 Nov 2011 12:25:53 -0500 (EST) Original-Received: from tlrPanP5.pobox.com (unknown [50.52.137.242]) by b-sasl-quonix.pobox.com (Postfix) with ESMTPA id 7ECFD6709; Mon, 14 Nov 2011 12:25:51 -0500 (EST) In-Reply-To: <87lirjz7uc.fsf@ericabrahamsen.net> User-Agent: GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4) X-Pobox-Relay-ID: B36A65FA-0EE5-11E1-9B7B-9DB42E706CDE-07218935!b-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 208.72.237.35 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82913 Archived-At: [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=C3=A7ade 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).