From mboxrd@z Thu Jan  1 00:00:00 1970
Path: main.gmane.org!not-for-mail
From: Alex Schroeder <alex@emacswiki.org>
Newsgroups: gmane.emacs.devel
Subject: filling in the minibuffer
Date: Mon, 16 Aug 2004 13:37:44 +0200
Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Message-ID: <87d61rgvp3.fsf@emacswiki.org>
NNTP-Posting-Host: deer.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: sea.gmane.org 1092656322 22606 80.91.224.253 (16 Aug 2004 11:38:42 GMT)
X-Complaints-To: usenet@sea.gmane.org
NNTP-Posting-Date: Mon, 16 Aug 2004 11:38:42 +0000 (UTC)
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 16 13:38:33 2004
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Original-Received: from lists.gnu.org ([199.232.76.165])
	by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian))
	id 1Bwfou-0006lo-00
	for <ged-emacs-devel@m.gmane.org>; Mon, 16 Aug 2004 13:38:33 +0200
Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.33)
	id 1Bwft1-0003Hz-3X
	for ged-emacs-devel@m.gmane.org; Mon, 16 Aug 2004 07:42:47 -0400
Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33)
	id 1Bwfss-0003Gw-CG
	for emacs-devel@gnu.org; Mon, 16 Aug 2004 07:42:38 -0400
Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33)
	id 1Bwfsq-0003GJ-TB
	for emacs-devel@gnu.org; Mon, 16 Aug 2004 07:42:37 -0400
Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.33) id 1Bwfsq-0003GG-Pf
	for emacs-devel@gnu.org; Mon, 16 Aug 2004 07:42:36 -0400
Original-Received: from [62.2.95.247] (helo=smtp.hispeed.ch)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1BwfoI-0007Cy-Bg
	for emacs-devel@gnu.org; Mon, 16 Aug 2004 07:37:54 -0400
Original-Received: from confusibombus (80-218-5-218.dclient.hispeed.ch [80.218.5.218])
	by smtp.hispeed.ch (8.12.6/8.12.6/tornado-1.0) with ESMTP id
	i7GBblYC031476
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO)
	for <emacs-devel@gnu.org>; Mon, 16 Aug 2004 13:37:48 +0200
Original-Received: from alex by confusibombus with local (Exim 4.34) id 1BwfoB-0000gK-7O
	for emacs-devel@gnu.org; Mon, 16 Aug 2004 13:37:47 +0200
Original-To: emacs-devel@gnu.org
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACkElEQVR42s1a0bLsIAgzjv//
	y7kPd9pVKxKVdk6fzux2C4EAwR6QZBpcQEopIf3Fq3a52Lfh0Mjjk99zcWYBwA2ihEen9jVxfAf/
	u0+Y2HQwNoVw4Dx34trRV6NSjiLPmfPt77jwiBxB/3PnZ3B2AGxzHnGu0wcBwAIAyQwZGvQhiFcy
	YLOFQcSB/MS82n3ec37vykNqRFTX9rVWR2U5+pZNIggll0CUOQN9BDdm1LfBmcZxIEqjL6r2JU/D
	galaB7Zg4jlY2ulnIx9OR4iMRl38CAFyKaA8jAxE7lNn650VKMULZ/54crqn0YQCJGQliebXkFIK
	hwqmGm28cgsSjz/hzRCMneQEwMjVoH3gWTtMPgIslJUV5uIluvUEkyzU+gUGQO62e9NuSdZCzNOM
	fDPC87iCqfE9gHinsIrSL16TPBfrYIeHzqKU90a50jCh54EcrgAUFo5ibzvebgr/I66USQ0CspQp
	IVSoBQK3WswDDIndIraHxoglqOjM1d044PQvu1NY0EHtqQR/XwJ+PeCs0x2dSlApZVw4MPER23PD
	7JekoHxrqTRod/2Gx5nhx5dfAJhqPt7tDMIZxNN/7lOIaparPn7ZQ88drlORC2eLWXowxIq4gHTh
	VN1BSmsHoxYAbPWDTuGQuuecS+aYQUYpfr0YqPQOuuUk5tApK077+2xfOYP+XyWEIwPcE49lvT9N
	y2+wU2KylGGp4yxlALcm6fSlmgk62yfSsfNunDl5d6W91MBUoZw679YAJoMMkhijuXdFOL+khaL2
	s+g3zy4APQuQvSc/BNAYnkl6E8ivYtEHJXa1dihE3zgnKMdNgN8DiIwgA17NykUMvFDQ+LALvXXI
	BuBLAHv/DvBmc/0HzR03PqXmLcQAAAAASUVORK5CYII=
User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Xref: main.gmane.org gmane.emacs.devel:26273
X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:26273

I sometimes have the need for filling a paragraph in the minibuffer.

(let ((debug-ignored-errors nil)
      (debug-on-error t))
  (read-from-minibuffer "Text: "))

Type a few words, hit M-q.

You get an error:

fill-delete-newlines: Text is read-only

When you type a few words, C-q C-j to insert a newline, and type some
more, and then hit M-q, filling works as expected.

I think we should try to make it work without a newline in the
minibuffer, too.  In fact, I think this used to work in earlier
versions.

Why does it happen?

The prompt ends with a space.  When fill-delete-newlines gets called, 
we have a problem at the very end:

  (if (and nosqueeze (not (eq justify 'full)))
      nil
    (canonically-space-region (or squeeze-after (point)) to)
    ;; Remove trailing whitespace.
    ;; Maybe canonically-space-region should do that.
    (goto-char to) (delete-char (- (skip-chars-backward " \t"))))
  (goto-char from))

That is, this tries to delete the space ending the prompt, which
fails.

What should we do?  Should we just skip over read-only text when
filling?

Maybe that is not the whole story, because why is the code being
called on the prompt only?

Edebugging fill-paragraph I note the following:

	(save-excursion
	  ;; To make sure the return value of forward-paragraph is meaningful,
	  ;; we have to start from the beginning of line, otherwise skipping
	  ;; past the last few chars of a paragraph-separator would count as
	  ;; a paragraph (and not skipping any chars at EOB would not count
	  ;; as a paragraph even if it is).
	  (move-to-left-margin)
	  (if (not (zerop (forward-paragraph)))
	      ;; There's no paragraph at or after point: give up.
	      (setq fill-pfx "")
	    (let ((end (point))
		  (beg (progn (backward-paragraph) (point))))
	      (goto-char before)

The call to move-to-left-margin takes us to the beginning of the
prompt.  The forward-paragraph takes us to end of the prompt (end).
Then the next backward-paragraph takes us to the beginning of the
prompt again (beg).  I think this is the bug.

Maybe move-to-left-margin should stop at field boundaries?  I'm not
sure this is the correct solution...

Alex.
-- 
.O.  http://www.emacswiki.org/alex/
..O  Schroeder's fourth law:
OOO  None of your friends and coworkers share your taste in music.