tonini / alchemist.el

Elixir Tooling Integration Into Emacs
http://www.alchemist-elixir.org
906 stars 103 forks source link

Latest update of spacemacs puts too many "end"s #276

Closed pdilyard closed 7 years ago

pdilyard commented 7 years ago

Not exactly sure what changed, but I updated spacemacs today, and now I get too many closing end keywords.

Example:

  case test do
    {:ok, x} ->
      x
    {:ok, y} ->
      y
    {:ok, z} ->
      z
  end
  end
  end
  end
tonini commented 7 years ago

Hi @pdilyard

Alchemist has nothing to do with adding end or closing blocks in general. You need to have a look at which packages are you using for open/closing blocks, like smartparens for example, I guess spacemacs comes with it by default but I'm not sure at all.

Thanks though for the report.

pdilyard commented 7 years ago

I figured this was the case - thanks!

michalmuskala commented 7 years ago

@pdilyard did you find a solution for that one?

pdilyard commented 7 years ago

I posted an issue here: https://github.com/syl20bnr/spacemacs/issues/8030

I'm not exactly sure what changed, I don't see anything in the changelog of spacemacs that seems related. I suppose it could be an update to smartparens or something along those lines.

gausby commented 7 years ago

I suggested them removing the ruby-end-package from their Elixir-layer some time ago, and they did—but it seems that they have recreated the behavior using smartparens: https://github.com/syl20bnr/spacemacs/blob/b7e51d70aa3fb81df2da6dc16d9652a002ba5e6b/layers/%2Blang/elixir/packages.el#L157-L172

pdilyard commented 7 years ago

For anyone interested, this is what I'm doing atm for a quick fix:

Open ~/.emacs.d/layers/+lang/elixir/packages.el, and find the elixir/pre-init-smartparens function, and comment out the part that matches end with ->. Here's what I've got:

(defun elixir/pre-init-smartparens ()
  (spacemacs|use-package-add-hook smartparens
    :post-config
    (progn
      ;; (sp-with-modes '(elixir-mode)
      ;;   (sp-local-pair
      ;;    "->" "end"
      ;;    :when '(("RET"))
      ;;    :post-handlers '(:add spacemacs//elixir-do-end-close-action)
      ;;    :actions '(insert)))
      (sp-with-modes '(elixir-mode)
        (sp-local-pair
         "do" "end"
         :when '(("SPC" "RET"))
         :post-handlers '(:add spacemacs//elixir-do-end-close-action)
         :actions '(insert))))))

Hopefully we'll come to a resolution that's a little smarter than just ignoring all arrows that need a matching end, but for now I'd rather have this than a bunch of extra ends. See https://github.com/syl20bnr/spacemacs/issues/8030 for more details.