From a0d5f0a6765e271d0f8c6b52d1ec7d72093de276 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Sat, 17 Apr 2021 21:12:27 +0800 Subject: [PATCH] Confirm fix for paring plugins --- langs/docstr-python.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/langs/docstr-python.el b/langs/docstr-python.el index 1d99004..d779ac1 100644 --- a/langs/docstr-python.el +++ b/langs/docstr-python.el @@ -147,10 +147,16 @@ (defun docstr-trigger-python (&rest _) "Trigger document string inside Python." (when (and (memq major-mode docstr-python-modes) - ;; TODO: For some reason, '(nth 4 (syntax-ppss))' doesn't work. docstr-mode (docstr-util-looking-back "\"\"\"" 3) - (looking-at-p "\"\"\"")) + ;; This should avoid pairing plugins inserting document string + ;; twice by accident. e.g. `electric-pair-mode', `smartparens', + ;; etc. + ;; + ;; See #5. + (not (docstr-util-looking-back "\"\"\"\"" 4))) + ;; If no pairing, help complete it! + (unless (looking-at-p "\"\"\"") (save-excursion (insert "\"\"\""))) (docstr--insert-doc-string (docstr-python--parse)))) (provide 'docstr-python)