smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Adding \left\langle, \right\rangle breaks things in latex

Open ultronozm opened this issue 1 year ago • 3 comments

Expected behavior

Modify smartparens-latex.el to contain the following additional local pair definition:

(sp-local-pair "\\left\\langle" "\\right\\rangle"
                   :post-handlers '(sp-latex-insert-spaces-inside-pair))

Open a LaTeX-mode buffer containing $\left\langle \right\rangle$. Put the cursor in the middle of the brackets and do M-x sp-up-sexp. This should move the point to the rightmost $.

Actual behavior

The point does not move; we are dealt the message "Search failed: there is an unmatched expression somewhere or we are at the beginning/end of file."

Backtraces if necessary (M-x toggle-debug-on-error)

No error.

Environment & version information

  • smartparens version: 1.11.0
  • Active major-mode: LaTeX-mode
  • Smartparens strict mode: nil
  • Emacs version (M-x emacs-version): GNU Emacs 30.0.50 (build 4, aarch64-apple-darwin23.2.0, NS appkit-2487.30 Version 14.2.1 (Build 23C71)) of 2024-02-06
  • Starterkit/Distribution: Vanilla
  • OS: darwin

ultronozm avatar Mar 20 '24 16:03 ultronozm

Sorry, I should have seen in the manual the rule about pairs having to be prefix-free, so please feel free to close this issue -- I'll just note that both \langle, \rangle and \left\langle, \right\rangle appear often for me, so it's a significant issue.

ultronozm avatar Mar 20 '24 17:03 ultronozm

The prefix-free note is not entirely correct anymore. I should revise it.

You can in fact have two pairs, let's say \langle and \rangle and what you have. The pairs then highlight a bit weirdly, but somewhat work. The fact that the navigation doesn't work I would consider a bug, because at the least it should recognize the "inside" pair (langle rangle) and jump out of that. So I think this is a valid report.

image

image

image

Fuco1 avatar Mar 20 '24 18:03 Fuco1

Just FYI, after submitting this report, I worked out some ad-hoc parenthesis-based navigation just for tex modes: https://github.com/ultronozm/tex-parens.el. I'm happy with this, so please feel free to deprioritize my report (at least as far as I'm concerned). I'd also be happy to try to incorporate my solution into smartparens if you thought that it made sense to do so, but it's not clear to me how feasible that would be. Anyway, thanks again for taking a look at this report and noting the issue.

ultronozm avatar Apr 22 '24 14:04 ultronozm