jjbatard · 2022-11-18 17:12
Hello everyone.
I am trying to find a way to replicate the bracket behavior to the dollar sign symbols (just as if `$$` was something like `{}`).
This is because I use `org-mode` to write math notes with a lot of latex sections and most of these latex "windows" are done by surrounding the piece of text with dollar signs.
eg: `$\alpha\beta latex things$`.
Of course the best would be to have a way of setting this to any kind of couple of symbols or symbol combinations.
For example in latex it would be immensely useful to do it on `\{` and `\}`.
Does someone know how to approach this?
I use doom emacs if that matters, but I hope that a solution might be helpful to whoever needs it as well.
Thank you a lot.
graduale · 2022-11-18 18:55
It depends on whether you’re using `electric-pair-mode` or smartparens or something else. If you’re using electric-pair, I thinj the variable to check is `electric-pair-pairs` but I’m not sure.
jjbatard · 2022-11-18 19:43
I checked now, `electric-pair-mode` is set to `nil`, but `smartparens-mode` is set to `t`.
I guess that means I'm using smartparens.
[deleted] · 2022-11-18 19:46
[deleted]
github-alphapapa · 2022-11-18 21:52
IIUC you'd probably want to look into using syntax tables. They're documented in the Elisp manual.
jjbatard · 2022-11-19 06:29
Update:
This seem to be exactly how you do that (if you know how) if you use smartparens.
https://smartparens.readthedocs.io/en/latest/pair-management.html#el.function.sp-pair
Well, I don't know how to do that in doom emacs.
I've tried putting this in my `~/.doom.d/config.el`:
```
(sp-pair "\{" "\}" :autoskip) ;; latex literal brackets (included by default)
(sp-pair "$" "$" :autoskip) ;; latex inline math mode. Pairs can have same opening and closing string
```
And this managed to break everything, the elisp compiler seemed deeply disturbed by `:autoskip` and emacs stopped recognizing my org file as it (I edit the `config.el` file in org mode than `babel-tangle` it). So I've deleted the `sp-pair` commands.
Any suggestions on where/how to do this `sp-pair` thing? Or if that's the right thing to do in the first place (must be, right?).
I'd like to do all of that in the `~/.doom.d/confifg.el` file, because I want all of my configuration stuff clustered in one place in case I accidentally nuke everything everywhere.
jjbatard · 2022-11-19 06:39
Here it is:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Blinking.html
So to have $$ behave like brackets I may want to do this:
```
(defun interactive-blink-matching-open $$
"Indicate momentarily the start of parenthesized sexp before point."
(interactive)
(let ((blink-matching-paren-distance
(buffer-size))
(blink-matching-paren t))
(blink-matching-open)))
```
Is that right?
UnlikelyTear · 2022-11-19 08:22
The documentation you posted doesn't have :autoskip in it. Where does it come from?
jjbatard · 2022-11-19 17:04
It was some option it's supposed to get, I'm sorry I don't remember
MunsterPlop · 2022-11-19 18:51
The documentation says `autoskip` is an action that should be used like this:
(sp-pair "(" ")" :actions '(autoskip))