emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filling in the minibuffer


From: Richard Stallman
Subject: Re: filling in the minibuffer
Date: Tue, 17 Aug 2004 21:35:03 -0400

    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.

It seems to me that a special case check here for the minibuffer,
to leave the prompt alone, is an ok solution.

    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...

It would make sense for move-to-left-margin to special-case
the minibuffer and treat the end of the prompt as the left margin.

Does this patch give good results?

*** indent.el   11 Sep 2003 09:45:48 -0400      1.55
--- indent.el   17 Aug 2004 20:27:18 -0400      
***************
*** 164,177 ****
    (interactive (list (prefix-numeric-value current-prefix-arg) t))
    (beginning-of-line n)
    (skip-chars-forward " \t")
!   (let ((lm (current-left-margin))
!       (cc (current-column)))
!     (cond ((> cc lm)
!          (if (> (move-to-column lm force) lm)
!              ;; If lm is in a tab and we are not forcing, move before tab
!              (backward-char 1)))
!         ((and force (< cc lm))
!          (indent-to-left-margin)))))
  
  ;; This used to be the default indent-line-function,
  ;; used in Fundamental Mode, Text Mode, etc.
--- 164,181 ----
    (interactive (list (prefix-numeric-value current-prefix-arg) t))
    (beginning-of-line n)
    (skip-chars-forward " \t")
!   (if (window-minibuffer-p)
!       (if (save-excursion (beginning-of-line) (bobp))
!         (goto-char (minibuffer-prompt-end))
!       (beginning-of-line))
!     (let ((lm (current-left-margin))
!         (cc (current-column)))
!       (cond ((> cc lm)
!            (if (> (move-to-column lm force) lm)
!                ;; If lm is in a tab and we are not forcing, move before tab
!                (backward-char 1)))
!           ((and force (< cc lm))
!            (indent-to-left-margin))))))
  
  ;; This used to be the default indent-line-function,
  ;; used in Fundamental Mode, Text Mode, etc.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]