expez / evil-smartparens

Evil integration for Smartparens
GNU General Public License v3.0
134 stars 17 forks source link

Safe operators stop before unmatched apostrophe in elisp comments when using smartparens-config #38

Closed braham-snyder closed 7 years ago

braham-snyder commented 7 years ago

With smartparens-strict-mode and (require 'smartparens-config), safe operators can behave incorrectly on unmatched apostrophes in emacs lisp comments. For example, dd (with point anywhere) on the following line:

;; doesn't that

leaves:

't that

Seems to be caused by the `' pair, here in smartparens-config:

(sp-with-modes (-difference sp-lisp-modes sp-clojure-modes)
  ;; also only use the pseudo-quote inside strings where it serve as
  ;; hyperlink.
  (sp-local-pair "`" "'"
                 :when '(sp-in-string-p
                         sp-in-comment-p)
                 :unless '(sp-lisp-invalid-hyperlink-p)
                 :skip-match (lambda (ms mb me)
                               (cond
                                ((equal ms "'")
                                 (or (sp-lisp-invalid-hyperlink-p "`" 'navigate '_)
                                     (not (sp-point-in-string-or-comment))))
                                (t (not (sp-point-in-string-or-comment)))))))
expez commented 7 years ago

Use evil-sp-override, bound to o in visual-state, to get around this edge-case.

If you want to pursue this further, the issue belongs over in the smartparens repo.

expez commented 7 years ago

Let me add a bit more details. The problem happens because ' is the closing half of a pair, so when this token appears on its own smartparens says 'this region is unbalanced' and evil-smartparens shrinks the region in an attempt at DWIM.

How can we differentiate between a failed pair insertion and the use of ' in text? We would have to do semantic analysis to find out the meaning behind the text. Nevermind that this is hard, but it would also be so costly to do that it would leave the package unusable for the general case.

This is why I said this was an 'edge case', that we probably shouldn't invest much time in.

braham-snyder commented 7 years ago

fair enough--it just wasn't clear to me what your stance on this was since I didn't see it documented anywhere