[Top][All Lists]

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

Re: Start value in minibuffer

From: Juri Linkov
Subject: Re: Start value in minibuffer
Date: Mon, 14 Nov 2005 02:55:11 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>> BTW, shouldn't pc-selection-mode do that?
> .. and delete-selection-mode and cua-mode as well.

There is one essential difference between pc-selection-mode,
delete-selection-mode and cua-mode.  pc-selection-mode
deactivates the mark after point movements.

For some time I tried to use the code below with delete-selection-mode.
It copies the default value from the prompt to the input area and
selects it.  But it is inconvenient when after starting to move point
to edit the default value, the selection doesn't become deactivated.
This is not like other GUI applications (e.g. many GTK applications)
work after selecting a field.  Perhaps this should be treated
specially in delete-selection-mode.

;; Prerequisites:
(minibuffer-electric-default-mode 1) ; hide default after copying it
(transient-mark-mode 1)
(delete-selection-mode 1)
(put 'previous-history-element 'delete-selection t)
(put 'next-history-element 'delete-selection t)
(put 'minibuffer-complete 'delete-selection t)
(put 'minibuffer-complete-and-exit 'delete-selection t)
(put 'exit-minibuffer 'delete-selection t)

(defun minibuffer-setup-default-value ()
  (when (and (= (length (minibuffer-contents-no-properties)) 0)
               (re-search-backward "\\( (default\\> \\(.*\\))\\):? \\'" nil t)))
    (push-mark (point) nil t)
    (insert (match-string-no-properties 2))))
(add-hook 'minibuffer-setup-hook 'minibuffer-setup-default-value)

Juri Linkov

reply via email to

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