Skip to content

Commit

Permalink
tweak(electric-pair): more rules for Org-mode and Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Nov 21, 2023
1 parent 0712396 commit 3cd3a7d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions core/me-builtin.el
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,28 @@ current line.")
(backward-word)
(looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))))

(use-package elec-pair
:straight (:type built-in)
:hook (minemacs-after-startup . electric-pair-mode)
:hook (org-mode . +electric-pair-tweaks-h)
:init
(defun +electric-pair-tweaks-h ()
;; Org mode tweaks
(when (and electric-pair-mode (derived-mode-p 'org-mode))
;; Disable auto-pairing of "<" in `org-mode' when using `electric-pair-mode'
(setq-local electric-pair-inhibit-predicate
`(lambda (char)
(if (char-equal char ?<) t (,electric-pair-inhibit-predicate char)))))
(setq-local electric-pair-pairs (append electric-pair-pairs (alist-get major-mode +electric-pair-mode-pairs-alist))))

(defvar +electric-pair-mode-pairs-alist
'((org-mode . ((?= . ?=) (?~ . ?~) (?* . ?*) (?/ . ?/) (?` . ?')))
(markdown-mode . ((?` . ?`) (?* . ?*)))))

;; Add the hooks to the concerned modes
(dolist (mode (mapcar #'car +electric-pair-mode-pairs-alist))
(add-hook (intern (format "%s-hook" mode)) #'+electric-pair-tweaks-h)))

(use-package oc-csl
:straight (:type built-in)
:after oc
Expand Down Expand Up @@ -1703,10 +1725,6 @@ Useful for quickly switching to an open buffer."
("C--" . text-scale-decrease)
("C-=" . text-scale-adjust)))

(use-package elec-pair
:straight (:type built-in)
:hook (minemacs-after-startup . electric-pair-mode))


(provide 'me-builtin)

Expand Down

0 comments on commit 3cd3a7d

Please sign in to comment.