本文介绍了电对模式和Python三重引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以使用 autopair-蟒三重引号动作
。
解决方案
您可以执行以下操作:
(defun python-electric-pair-string-delimiter()
(when(and electric-对模式
(memq last-command-event'(?\?\'))
(let((count 0))
(while(eq ( - (点)计数))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' -self-insert-hook
#'python-electric-pair-string-delimiter'append t)))
它将被包含在下一个版本的Emacs中。
Is there a way to enable auto-pairing Python triple quotes in electric-pair-mode?
This can be configured in autopair-mode using autopair-python-triple-quote-action
. Is there a similar way to enable this in electric-pair-mode?
解决方案
You can do the following:
(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)))
It will be included in the next release of Emacs.
这篇关于电对模式和Python三重引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!