Open WIZARDELF opened 8 years ago
Hi.
I won't be changing the default set. It has been like this since the beginning and people who use it would get broken configuration if we change the bindings. I'm not against alternative layouts, but this is something people will never agree upon so I wouldn't dwell on it much.
@Fuco1 Unfortunately I must disagree.
While you technically have the right to set the defaults as you see fit, M-backspace was defined as backwards kill word ever since emacs was first released. It's also one of the only common associations across operating systems: it has this behaviour in WIndows, OS X and Linux.
Binding it in the first place was an extremely bad choice: it's not motivated by ergonomics (any non-essential binding would give you the same basic modifier + key combo. In fact rebinding it to C-back would make just as much sense, while binding it to M-d and M-S-d would make it ergonomically favourable), it makes little mnemonic sense (sure I can understand the association with forward and back, and maybe deleting, but there was no good reason beyond pure laziness to pick an already taken modifier.
Sure you might get some backlash for reverting it, from ... two people, but at least you won't be carrying over that mistake.
@appetrosyan I think in retrospect I agree, you put forth some good arguments. I'll accept a PR if you want to take a look at this and make the layout batter.
We can rename the default sp-smartparens-bindings
to sp-smartparens-legacy-bindings
and create a new set under the old name that would better fit with the "standards". People then can switch it with relative ease by just toggling the one setting (instead of having to rebind stuff manually).
As for the reasons, I use C-w
to backward kill and virtually never in my life used M-<backspace>
. I also started writing this mode about a week after I started using Emacs so I had little understanding of "conventions" :P Just a little background.
I find that it's almost always the case in Emacs that people just have their own idiosyncratic workflows and sometimes that carries over to the "work destined for public consumption" which might not be the best way to handle things. I've made this "mistake" in many of my works.
C-w
is bound to this "smart" kill function
(defun my-kill-region-or-word (&optional arg)
"Kill active region or one word backward."
(interactive "p")
(if (use-region-p)
(sp-kill-region (region-beginning) (region-end))
(if smartparens-strict-mode
(sp-backward-kill-word arg)
(backward-kill-word arg))))
We're all here to learn.
What I usually do is provide the bare functions, and let the users bind them manually.
I would aslo find a set of non-conflicting keybinds for smartparens and include them in the fork. I'll try to keep the changes minimal, and or, provide means to change the bindings on a whim.
P.S. feel free to assign this issue to me
@appetrosyan I had the exact same approach of not binding anything at first but a surprising amount of people complained about that :D So we created some key-sets like paredit and the one I was using at the time which became the "default".
I can't assing the issue to you, github does not allow that unfortunately :/
@appetrosyan's PR was never merged, but things changed, it seems: sp-unwrap-sexp
and sp-backward-unwrap-sexp
are now only bound in sp-use-paredit-bindings
. Leaving the default behaviour without strict mode OK, with strict mode quite awkward: I can only get rid of parentheses by marking them before deletion, or by doing M-x sp-unwrap-sexp
.
For anyone ending up here: I found the key bindings proposed by @appetrosyan quite good and unused, so that's the workaround I go with:
(define-key smartparens-mode-map
(kbd "M-S-<delete>") 'sp-unwrap-sexp)
(define-key smartparens-mode-map
(kbd "M-S-<backspace>") 'sp-backward-unwrap-sexp)
But I can't help but wonder if I'm not missing a better way - does everyone who uses smartparens just come up with their own keybindings for these?
I have another set of bindings, which I use these days
(use-package smartparens
:ensure t
:diminish smartparens-mode
:init (smartparens-global-mode)
:bind
("M-<backspace>" . sp-backward-kill-sexp)
("M-[ M-[" . sp-backward-slurp-sexp)
("M-] M-]" . sp-forward-slurp-sexp)
("M-[ M-]" . sp-backward-barf-sexp)
("M-] M-[" . sp-forward-barf-sexp)
("M-] M-p" . sp-unwrap-sexp)
("M-[ M-p" . sp-rewrap-sexp))
It could be optimised though.
the default keybinding (defined in smartparens.el) for sp-unwrap-sexp and sp-backward-unwrap-sexp is
M-<delete>
andM-<backspace>
right now. it's annoy for people who get used to useM-<backspace>
to delete the word before point. so, it's better to re-assign the keybinding.M-[
andM-]
are good candidates.