all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* filling in the minibuffer
@ 2004-08-16 11:37 Alex Schroeder
  2004-08-18  1:35 ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Schroeder @ 2004-08-16 11:37 UTC (permalink / raw)


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.

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

end of thread, other threads:[~2004-08-22  1:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-16 11:37 filling in the minibuffer Alex Schroeder
2004-08-18  1:35 ` Richard Stallman
2004-08-21 12:08   ` Alex Schroeder
2004-08-22  1:14     ` Stefan Monnier
2004-08-22  1:38       ` Miles Bader

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.