[Top][All Lists]

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

RE: Ignoring entries starting with space

From: Drew Adams
Subject: RE: Ignoring entries starting with space
Date: Fri, 26 Jun 2009 12:02:02 -0700

It is better not to have the key that does this also exit the minibuffer.

That is, it is better to have exiting be independent of this. There can be
multiple ways to exit, including, with customization, multiple keys for exiting
in different ways. This action is logically independent from exiting, and it
should be kept independent, so that you can combine it with any possible exit
My own preference for this kind of thing is to have a user option, say
`save-input-in-history-flag', and then to have a simple command to toggle it,
bound in a minibuffer keymap. That is, just this:

(defcustom save-input-in-history-flag t
  "Non-nil means save minibuffer input in a history variable."
  :type 'boolean :group 'whatever)

(defun toggle-save-input-in-history ()
  (setq save-input-in-history-flag
        (not save-input-in-history-flag)))
Code can also bind the variable, to change behavior locally.

The key binding for such a command need not be one that is particularly
easy/quick or repeatable. This is not something that you will do very often or
something that you will repeat multiple times. A key with prefix `C-x' would be
fine for this. 

A design question is whether this action should affect only the current
minibuffer input or also subsequent inputting. I would keep it simple and do as
described above: a simple toggle, which affects the global state. In that case,
for a one-off you would need to toggle twice.

Another possibility that I'd favor is to use not a boolean flag but a regexp, to
be matched against the input that is returned. If it matches, then the input is
not saved.

The advantage of this approach is that a command could bind the variable to a
particular regexp (e.g. that matches a whitespace prefix), to save all inputs
except those that match (e.g. start with a space). This approach gives the
command additional control.

A toggle could still work with a regexp-valued option. Turning such filtering
off could be done with a nil value or a regexp that matches everything. To turn
it back on, we would need to have saved the last non-match-everything value.

reply via email to

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