Open paldepind opened 8 years ago
To wrap something in brackets you can select it with C-M-<space>
and then hit [
. That'll give you [a]
.
In general SHM works on a complete tree. If you're trying to type one opening delimiter then the closing one you're going to have a bad time.
To wrap something in brackets you can select it with C-M-
and then hit [. That'll give you [a].
At some point when writing the above post trying that actually occurred to me. It does work but doesn't seem very intuitive to me.
It still seems to me like some parts of shm is making my existing typing habits useless without any gains. It tries to guess what I'm doing and unfortunately it's sometimes wrong.
In the above case it decided that I actually didn't meant to delete anything even though I pressed backspace
. Assuming that a user pressed the wrong key and simply ignoring it is not good UI IMO.
Here is another example: At one point I accidentally typed a =
instead of a +
. When trying to delete the =
shm decided that it knew better and converted my editing command into a movement command (the gliding feature). Why would it do that? If I wanted to move backwards I would have typed backward-char
or backward-word
. How should I correct add n m = n = m
with the cursor right after the last =
.
I love the parts of shm that makes typing Haskell easier! I don't understand the parts where it wants to protect me from myself.
Another question. It is correct that when typing something like (foo bar)
you have to press )
twice at the end to move the cursor to after the )
. Is that intentional?
Today I accidentally wrote this:
eqToBool :: Eq a => a -> ->
That is, I mistakenly typed two ->
s in a row. Gliding prevented me from deleting the last ->
with backspace. Again the gliding behaviour seems to break my editing habits with no benefit.
Found this issue while trying to understand why insertion of brackets/braces was suddenly broken! I actually just installed spacemacs/emacs/shm at this point, just followed this example: https://www.reddit.com/r/haskell/comments/3kr6m3/update_i_got_spacemacs_working_using_stack_with/ At some point I'll probably be able to appreciate this feature, but for now I find this feature of this otherwise great plugin too distracting while trying to write some code :)
@paldepind : I have managed to disable this by adding the following to my .spacemacs [WARNING: it works for me after a quick test, but it could also break other things!]
(defun insert-closing-parenthesis ()
"Insert closing parenthesis."
(interactive)
(shm-insert-string ")"))
(defun insert-closing-bracket ()
"Insert closing bracket."
(interactive)
(shm-insert-string "]"))
(defun insert-closing-braces ()
"Insert closing braces."
(interactive)
(shm-insert-string "}"))
(with-eval-after-load 'shm
(define-key shm-map (kbd ")") 'insert-closing-parenthesis)
(define-key shm-map (kbd "]") 'insert-closing-bracket)
(define-key shm-map (kbd "}") 'insert-closing-braces))
I occasionally have the same problem to. My workaround is to use delete-char
until the syntax tree is valid again, then get back to normal.
It seems that delete-char
is not touched by shm, so by using it you either confuse or un-confuse shm.
@maerten You can just press C-q then the character you actually want. So to insert a closing parenthesis, bracket or brace, just type C-q ) or C-q ] or C-q }.
Hello @chrisdone
First of all thanks for the great work you have done for both the Haskell and the Emacs communities.
I'm finding that shm is working against me more often than it is helping me. I'm wondering if it's because I'm doing it wrong.
Just now I was trying to edit this simple piece of code:
I had just changed the definition of the function and wanted to update the signature accordingly. I did something like this:
shm/close-paren
) until the entire type class constraint was selected.shm/delete
. This left me with this (my cursor being right before thea
)a
in brackets I typed[
. This gave me both and opening and a closing bracket. So I deleted the closing bracket withdelete-char
and moved over thea
.]
to insert a closing bracket. But instead the cursor moved one character backwards (due to the end of of node behaviour of]
).[a
and type it again. I deleted thea
just fine, but the[
could not be deleted.At this point shm had prevented me both from inserting the closing bracket and from deleting the opening bracket. I often end up in such situations unable to do what I want.
In the end I managed to get rid of the opening bracket with some other editing commands.