mickeynp / combobulate

Structured Editing and Navigation in Emacs with Tree-Sitter
GNU General Public License v3.0
959 stars 56 forks source link

Option to disable keybindings #46

Open SKyletoft opened 1 year ago

SKyletoft commented 1 year ago

Having an easy option to disable all the keybinds would really help people with non standard keybinds (vim-like, kakoune-like, traditional desktop, entirely custom...) get into using this.

Setting up a full set of evil like binds might be a bit out of scope for this project, but just having a variable to disable it from overriding a bunch of binds on load would be really nice and let us then write keymaps that fit better.

jdtsmith commented 1 year ago

It's easy enough to rebind keys, but I agree. M-left/right are especially problematic, as those are by default bound to left/right-word, very common commands. I also think there's the kernel of a great modal interface already here, e.g. M-h gets you in the door, and then various other single keys could move, duplicate, etc.

SKyletoft commented 1 year ago

The issue isn't rebinding later, is that it overwrites a bunch of binds on load

jdtsmith commented 1 year ago

You can easily remove those overwrites, like this:

  :bind (:map combobulate-key-map
          ("M-<left>" . nil)
          ("M-<right>" . nil))

For deeper key bindings I sometimes use this function from tarsius, which works for direct keymaps and sub-maps too:

(defun my/remove-key (keymap key)
  (define-key keymap key nil)
  (setq key (cl-mapcan (lambda (k)
                         (if (and (integerp k)
                                  (/= (logand k ?\M-\^@) 0))
                             (list ?\e (- k ?\M-\^@))
                           (list k)))
                       key))
  (if (= (length key) 1)
      (delete key keymap)
    (let* ((prefix (vconcat (butlast key)))
           (submap (lookup-key keymap prefix)))
      (delete (last key) submap)
      (when (= (length submap) 1)
        (remove-key keymap prefix)))))

On the topic of structural editing UI, I found this article quite compelling. It advocates for structure editing packages to provide composable functionality that can be mixed and matched, so you can build your own kind of simple modal interface if desired.

ratnesh1729 commented 11 months ago

Is there a way I can rebind the keys .. I am trying something like this as I posted here for my need. But is not working - meaning I press anything apart from M-h the control goes back to which-key, and by pressing M-h it comes back. But I wanted to use M-c for shrinkage effect in expand region

(use-package combobulate
  :after python-ts-mode
  :ensure quelpa
  :quelpa (combobulate :repo "mickeynp/combobulate" :fetcher github)
  :bind (:map combobulate-proffer-map
              ("M-c" . prev))
  ;;(define-key combobulate-proffer-map (kbd "<backtab>") 'prev)
  )
mickeynp commented 11 months ago

Perhaps which-key interferes with the proffer ui?