[Top][All Lists]

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

RE: Start value in minibuffer

From: Drew Adams
Subject: RE: Start value in minibuffer
Date: Mon, 14 Nov 2005 09:36:59 -0800

    I think you are right and clear! But then the most sensible thing would
    be to make it optional. What about something like:

    (defcustom minibuffer-insert-default-value nil
      "Insert DEFAULT-VALUE into minibuffer.
    If non-nil, `read-from-minibuffer' inserts DEFAULT-VALUE into the
    minibuffer if
    INITIAL-CONTENTS is nil. If the value is 'select, the minibuffer
    contents will
    be selected."
      :type '(choice
        (const :tag "Don't insert default value" nil)
        (const :tag "Insert default value" t)
        (const :tag "Insert and select default value" select)))

There are actually three things we might consider making options:

1. Whether or not the default value is to be inserted in the
   minibuffer as an initial value.

2. If inserted, whether or not to preselect it.

3. Where to leave the cursor - at the beginning or end of the value.

These could be treated independently (3 separate options) or together. The
cursor position matters most for the preselection case, I think.

As an example, in my library, I provide the cursor-position option only in
case of preselection. So, I provide only one option, with these values:

(defcustom icicle-init-value 'insert
  "*Non-nil means to use default value as init value when reading input.
This is used by `completing-read'.  When the default-value argument is
non-nil and the initial-input argument is nil or \"\",  the default
value is inserted in the minibuffer as the initial input.

This has the advantage of not requiring you to use `M-n' to retrieve
the default value.  It has the disadvantage of making you empty the
minibuffer if you do not want to use or edit the default value.

The particular non-nil value determines whether or not the value is
preselected and, if preselected, where the cursor is left: at the
beginning or end of the value.  Possible values:

  nil               - Do not insert default value.
  `insert'          - Insert default value (leave cursor at end).
  `preselect-start' - Insert and preselect default value;
                      leave cursor at beginning.
  `preselect-start' - Insert and preselect default value;
                      leave cursor at end.

Preselection can be useful in Delete Selection mode or PC Selection
mode.  It makes it easy to replace the value by typing characters, or
delete it by hitting `C-d' or `DEL' (backspace).  However, all of the
initial input is lost if you type or hit `C-d' or `DEL'.  That is
inconvenient if you want to keep most of it and edit it only slightly."
  :type '(choice
          (const :tag "Do not insert default value as initial value"
          (const :tag "Insert (and leave cursor at end)"
          (const :tag "Insert, preselect, and leave cursor at beginning"
          (const :tag "Insert, preselect, and leave cursor at end"
  :group 'icicles)

reply via email to

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