emacs-devel
[Top][All Lists]
Advanced

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

RE: transient


From: Drew Adams
Subject: RE: transient
Date: Tue, 19 May 2020 15:53:59 -0700 (PDT)

> > Icicles key completion is similar, but there are
> > notable differences:
> >
> > 1. You can use it on-demand (as well as just
> >    automatically) - complete only when you want
> >    to, and without a delay.
> 
> What binding do you use here?  Won't it conflict with
> other keybindings?

Are you sure you really want to know? ;-)

tl;dr:

By default, the key (`S-TAB' by default) doesn't
get bound in any keymaps where it's already bound.

___

Option:

 `icicle-key-complete-keys' is a variable defined in `icicles-opt.el'.
 Its value is ([backtab])

 Documentation:
 Key sequences to use for `icicle-complete-keys'.
 A list of values that each has the same form as a key-sequence
 argument to `define-key'.  It is a list mainly in order to accommodate
 different keyboards - for example, `S-tab' and `S-iso-lefttab'.

(IOW the key to complete keys is `S-TAB' only by default.)
___

These options are also relevant here:

1.
 `icicle-key-complete-keys-for-minibuffer' is a variable defined in 
`icicles-opt.el'.
 Its value is ([M-backtab] [ESC backtab])

 Documentation:
 Key sequences to use for `icicle-complete-keys' in the minibuffer.
 A list of values that each has the same form as a key-sequence
 argument to `define-key'.

 Note: Some operating systems intercept `M-S-TAB' for their own use.
 For some versions of MS Windows, you can use
 (w32-register-hot-key [M-S-tab]) to allow Emacs to use `M-S-TAB'.

[The reason for this is that by default `S-TAB' is also used
in Icicles in the minibuffer completion maps, to complete
minibuffer input.  So by default, _key_ completion in the
minibuffer itself (yes, it's possible) uses `M-S-TAB'.]

2.
 `icicle-keymaps-for-key-completion' is a variable defined in `icicles-opt.el'.
 Its value is (...)

 Documentation:
 List of keymaps in which to bind `S-TAB' to `icicle-complete-keys'.
 List elements are symbols that are bound to keymaps.

 Each keymap should have at least one prefix key.  `S-TAB' is bound in
 each keymap, so that you can use it to complete the prefix keys.

 If one of the keymaps is not defined when Icicle mode is entered, then
 it is ignored.  If you later define it, then just exit and reenter
 Icicle mode, to bind `S-TAB' in the newly defined map.  For example,
 use `M-x icy-mode' twice after entering Calendar mode, to be able to
 complete `calendar-mode' prefix keys such as `A'.

 Do not add `global-map' or any keymaps, such as `ctl-x-map', that are
 accessible from the global keymap to the list - they are already
 treated, by default.

 Do not add any of the translation keymaps, `function-key-map',
 `key-translation-map', or `iso-transl-ctl-x-8-map' to the list - that
 will not work.

[These are keymaps inaccessible from `global-map',
as maps accessible from it are already included.]

3.
 `icicle-complete-key-anyway-flag' is a variable defined in `icicles-opt.el'.
 Its value is nil

 Documentation:
 Non-nil means bind `S-TAB' for key completion even if already
 bound.  If nil, then each of the keys in `icicle-key-complete-keys' is
 bound to `icicle-complete-keys' in each keymap of
 `icicle-keymaps-for-key-completion' only if `S-TAB' is not already
 bound in the keymap.

 Note: the keys in `icicle-key-complete-keys' are always bound to
 `icicle-complete-keys' in `icicle-mode-map'.  This option affects only
 the binding of those keys in `icicle-keymaps-for-key-completion'.

[Besides the keymaps defined by that option, keymaps
reachable from `global-map' with this function get the
`S-TAB' binding, IF either they don't already have
`S-TAB' bound OR option `icicle-complete-key-anyway-flag'
is non-nil.
This is the reason behind the "Do not add `global-map'..."
part of the `icicle-keymaps-for-key-completion' doc string.]

(defun icicle-bind-key-completion-keys-in-keymaps-from (map &optional keys)
  "Bind keys in `icicle-key-complete-keys' to `icicle-complete-keys'.
Each key in `icicle-complete-keys' (or optional arg KEYS, if non-nil)
is bound in all keymaps accessible from keymap MAP."
  (dolist (key+map  (accessible-keymaps map))
    (let ((map  (cdr key+map)))
      (when (keymapp map)
        (dolist (key  (or keys  icicle-key-complete-keys))
          (when (or icicle-complete-key-anyway-flag
                    (not (lookup-key map key)))
            (condition-case nil
               (define-key map key 'icicle-complete-keys)
             (error nil))))))))

The same kind of treatment happens in reverse when
you turn `icy-mode' off: key-completion keys are
unbound.  (Yes, it can't be perfect.  For example,
the set of keymaps accessible from the then current
global map might be different, or their keys might
be different.)

See this part of the doc:

https://www.emacswiki.org/emacs/Icicles_-_Key_Completion#KeymapsInaccessibleFromGlobalMap

Search that same page for "option" to see the above
options and others having to do with key completion
described in context.



reply via email to

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