2013-10-30 6 views
6

電気ペアモードで自動ペアリングPython三重引用符を有効にする方法はありますか?電気ペアモードとPython三重引用符

autopair-python-triple-quote-actionを使用して自動ペアモードで設定できます。電気ペアモードでこれを可能にする同様の方法はありますか?

+0

[smartparens](https://github.com/Fuco1/smartparens/wiki)もご覧ください。 – phils

答えて

5

次の操作を行うことができます

(defun python-electric-pair-string-delimiter() 
    (when (and electric-pair-mode 
      (memq last-command-event '(?\" ?\')) 
      (let ((count 0)) 
       (while (eq (char-before (- (point) count)) last-command-event) 
       (setq count (1+ count))) 
       (= count 3))) 
    (save-excursion (insert (make-string 3 last-command-event))))) 

(add-hook 'python-mode-hook 
      (lambda() 
      (add-hook 'post-self-insert-hook 
         #'python-electric-pair-string-delimiter 'append t))) 

それはEmacsのの次のリリースに含まれます。

+0

これは完全に動作します - ありがとうございます! – calvinyoung

関連する問題