虽然我真的很喜欢PyCharm,但我想在emacs中真正学会如何做到这一点。当我清理pep8违规特别是长线违规时,我非常感谢PyCharm能够自动引用该行的结尾或添加我通常在emacs中手动执行的任何操作。 emacs中是否有插件可以执行相同的操作?例如:
自:
output_string += '<table border="1"><tr><th>Column</th> <th>Type</th> <th>Required</th></tr>'
当我进行新行时,它会自动添加所需的行尾:
output_string += '<table border="1"><tr><th>Column</th> <th>Type</th> ' \
88 '<th>Required</th></tr>'
答案 0 :(得分:1)
添加到您的设置:
(defun python-newline ()
(interactive)
(let ((char (car (inside-string?))))
(if char
(progn
(insert (format "%c \\" char))
(newline-and-indent)
(insert (format "%c" char)))
(newline))))
(add-hook
'python-mode-hook
(lambda()
;; ...
(define-key python-mode-map (kbd "RET") 'python-newline)))
(defun inside-string? ()
(interactive)
(let ((p (nth 8 (syntax-ppss))))
(memq (char-after p) '(?\" ?\'))))