3

First, let me say I am new to orgmode and emacs. I am sure I am not providing all the relevant information for the problem, so please let me know what can I add here.

I am using emacs 26.3, and I use spacemacs.

The problem is:

smartparens is not working well in orgmode. This is what I see when I type the left parenthesis (

When I add a parenthesis after a whitespace) (
When I add a parenthesis with no whitespace() 

when I type \( it works well:

When I add \ and parenthesis after a whitespace \(\)

In both cases the tab key does not work to get me out of the parenthesis.

My user-config has this to load smartparens

  ;; smartparens
  (with-eval-after-load 'smartparens
    (sp-with-modes 'org-mode
      (sp-local-pair "$" "$")
      (sp-local-pair "" "" :actions '(rem))
      (sp-local-pair "=" "=" :actions '(rem))
      (sp-local-pair "" "" :actions '(rem))
      (sp-local-pair "\\left(" "\\right)" :trigger "\\l(" :post-handlers '(sp-latex-insert-spaces-inside-pair))
      (sp-local-pair "\\left[" "\\right]" :trigger "\\l[" :post-handlers '(sp-latex-insert-spaces-inside-pair))
      (sp-local-pair "\\left\\{" "\\right\\}" :trigger "\\l{" :post-handlers '(sp-latex-insert-spaces-inside-pair))
      (sp-local-pair "\\left|" "\\right|" :trigger "\\l|" :post-handlers '(sp-latex-insert-spaces-inside-pair))
      (sp-local-pair "(" ")")
      (sp-local-pair "\\(" "\\)")
      (sp-local-pair "\\[" "\\]")))

  (add-hook 'org-mode-hook 'smartparens-mode)

bobsacameno
  • 171
  • 5
  • It may be that there is an unavoidable conflict with `smartparens` (although the [manual](https://orgmode.org/manual/Conflicts.html#Conflicts) does not mention it). In particular , `TAB` is bound to `org-cycle` in Org mode buffers, so there is probably a conflict there. – NickD Mar 11 '20 at 20:38
  • 1
    What are you trying to do with the `(sp-local-pair "" "" :actions '(rem))` lines? I would suggest you begin with `(require 'smartparens-config)` and move on from there. Also, I don't think sp binds the `TAB` key to anything. Maybe you can try the `sp-up-sexp` command to move out of the parentheses. – jagrg Mar 12 '20 at 00:13
  • @jagrg I tried your advice. I started with removing all the special configuration I had in the `user-config` and put `(require 'smartparens-config)` and it indeed worked. Then I tweaked what I wanted to get the desired behavior. I will post an answer below. Thanks! – bobsacameno Mar 12 '20 at 14:53

1 Answers1

2

The following settings in the user-config in my .spacemacs file makes everything work properly.

  ;; smartparens
  (require 'smartparens-config)
  (sp-local-pair 'org-mode "\\[" "\\]")
  (sp-local-pair 'org-mode "$" "$")
  (sp-local-pair 'org-mode "'" "'" :actions '(rem))
  (sp-local-pair 'org-mode "=" "=" :actions '(rem))
  (sp-local-pair 'org-mode "\\left(" "\\right)" :trigger "\\l(" :post-handlers '(sp-latex-insert-spaces-inside-pair))
  (sp-local-pair 'org-mode "\\left[" "\\right]" :trigger "\\l[" :post-handlers '(sp-latex-insert-spaces-inside-pair))
  (sp-local-pair 'org-mode "\\left\\{" "\\right\\}" :trigger "\\l{" :post-handlers '(sp-latex-insert-spaces-inside-pair))
  (sp-local-pair 'org-mode "\\left|" "\\right|" :trigger "\\l|" :post-handlers '(sp-latex-insert-spaces-inside-pair))

This works well with org-cdlatex-mode and finally my parenthesis are matched correctly!

bobsacameno
  • 171
  • 5