[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/smartparens 79a338db11: feat(org): disable pairing of sing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/smartparens 79a338db11: feat(org): disable pairing of single quote in lisp org source blocks |
Date: |
Mon, 29 May 2023 07:00:56 -0400 (EDT) |
branch: elpa/smartparens
commit 79a338db115f441cd47bb91e6f75816c5e78a772
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
feat(org): disable pairing of single quote in lisp org source blocks
Fixes #1017
---
smartparens-config.el | 15 +++++++++++++++
test/smartparens-org-test.el | 12 ++++++++++++
2 files changed, 27 insertions(+)
diff --git a/smartparens-config.el b/smartparens-config.el
index 282a974bcc..7bfcfe08a3 100644
--- a/smartparens-config.el
+++ b/smartparens-config.el
@@ -76,6 +76,21 @@ ID, ACTION, CONTEXT."
;; disable ', it's the quote character!
(sp-local-pair "'" nil :actions nil))
+(eval-after-load 'org
+ '(progn
+ (defun sp-lisp-in-lisp-src-block-p (_id _action _context)
+ (when (org-in-src-block-p)
+ (let* ((el (org-element-at-point))
+ (lang (org-element-property :language el))
+ (mode (intern (concat
+ (if (string= lang "elisp") "emacs-lisp" lang)
+ "-mode"))))
+ (memq mode sp-lisp-modes))))
+
+ ;; Disable ' pairing in lisp org source blocks
+ (sp-local-pair 'org-mode "'" "'"
+ :unless '(:add sp-lisp-in-lisp-src-block-p))))
+
(sp-with-modes (-difference sp-lisp-modes sp-clojure-modes)
;; also only use the pseudo-quote inside strings where it serve as
;; hyperlink.
diff --git a/test/smartparens-org-test.el b/test/smartparens-org-test.el
index 45a87c592e..0f6cbfe29c 100644
--- a/test/smartparens-org-test.el
+++ b/test/smartparens-org-test.el
@@ -153,3 +153,15 @@
(org-mode)
(execute-kbd-macro "foo = bar")
(sp-buffer-equals "foo = bar")))
+
+(ert-deftest sp-test-org-do-not-pair-quote-in-elisp-block ()
+ (sp-test-with-temp-buffer "#+begin_src elisp
+|
+#+end_src
+"
+ (org-mode)
+ (execute-kbd-macro "'asd")
+ (sp-buffer-equals "#+begin_src elisp
+'asd|
+#+end_src
+")))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/smartparens 79a338db11: feat(org): disable pairing of single quote in lisp org source blocks,
ELPA Syncer <=