odyssomay / paredit

A paredit mode for lisps in Sublime Text.
104 stars 9 forks source link

Can't fix unbalanced braces #18

Closed taoeffect closed 11 years ago

taoeffect commented 11 years ago
(timbre/set-config!
 [:appenders :my-appender]
 {:doc       "Hello-world appender"
  :min-level :debug
  :enabled?  true
  :async?    false
  :limit-per-msecs nil ; No rate limit
  :fn (fn [{:keys [ap-config level prefix throwable message] :as args}]
        (println "args: " args)
        (println-str "args again: " args)
        (println prefix "Hello world!" message))|)

The opening brace in front of :doc is not balanced. The pipe is positioned where it should be inserted (near the very end).

For the life of me I can't figure out how to insert that damned brace while paredit is running. This shouldn't be possible. Paredit should make my life easier, not more difficult. Not sure if this is a dup of #6.

odyssomay commented 11 years ago

Sorry, I should have documented this already.

The current way is to insert two new brackets with {, then to delete the bracket you don't need with shift+backspace. I'm not sure this is the best solution, but I think it works fairly well. I might add shortcuts that always inserts a single bracket, but I'm not sure that's a good idea. Mostly because beginners will quickly turn to using those shortcuts instead since it's way easier than doing it the paredit way when you're not used to it (I have personally done this a lot).

taoeffect commented 11 years ago

I think that we can at least both agree that your solution for fixing this problem is ... counter-intuitive at best, and that's putting it delicately.

taoeffect commented 11 years ago

Ideally, placing the caret where it is in the code above and hitting } should close the brace. Paredit should figure out that a brace needs to be matched there. Sublime (or one of the plugins I'm using) notices and puts a ? mark in the gutter next to the line with the open brace, so maybe you could piggieback on whatever behavior does that.

odyssomay commented 11 years ago

Oh right, I totally forgot about that. I didn't want to do that since I thought it would have to search the whole file to see if a { is unmatched every time. I think it might be possible without doing that though. I'll think about it.

odyssomay commented 11 years ago

I don't see a ? in the gutter, my guess would be that you have https://github.com/facelessuser/BracketHighlighter installed.

taoeffect commented 11 years ago

Yeah, I do have that installed. Just ran into this again, except with parens this time:

screen shot 2013-07-28 at 5 57 49 pm

odyssomay commented 11 years ago

I just realized this was really easy to do. I feel silly now. :D

Thanks for opening the issue and telling me the right way to do it! :+1:

taoeffect commented 11 years ago

Awesome! Thanks for fixing this! :smiley:

Can you update the version settings for the Sublime package manager? I'd love to test it out! :)

odyssomay commented 11 years ago

It should be updated automatically. Either use Package Control: Upgrade Package in the command palette or restart sublime, that should do it.

taoeffect commented 11 years ago

Hmm, I did the Upgrade Package command, and it gave me a list of packages that could be updated. paredit wasn't one of them. I tried restarting Sublime also but that didn't work...

odyssomay commented 11 years ago

That's really odd. Did you install paredit manually?

taoeffect commented 11 years ago

Nope, through the package manager. Just removed it (using the package manager) and reinstalled it. The version listed for installing it was the same as it was listed when I removed it:

screen shot 2013-07-28 at 6 27 05 pm

odyssomay commented 11 years ago

I see. The reason is probably because Package Control only updates every 30 minutes, if I'm not mistaken. I thought upgrading it manually would circumvent that, but I guess not...

Even so, it should fetch it from the repository, so you can test if the patch made it into your version.

EDIT: When you re-installed it that is.

taoeffect commented 11 years ago

Ah I see. Woo hoo!! It works! Thanks for fixing this so quickly! :-D

odyssomay commented 11 years ago

No problem, thanks for opening the issue. :)

Don't hesitate to open more if you find something else!