[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
filling in the minibuffer
From: |
Alex Schroeder |
Subject: |
filling in the minibuffer |
Date: |
Mon, 16 Aug 2004 13:37:44 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
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.
- filling in the minibuffer,
Alex Schroeder <=