【问题标题】:flymake and python-execute-regionflymake 和 python-execute-region
【发布时间】:2010-05-19 17:20:30
【问题描述】:

当我调用 py-execute-region(绑定到 C-c |)时,flymake-get-file-name-mode-and-masks “无效文件名”出现错误。还会出现名称为 /tmp/python-3434.py 的 void 缓冲区。

我的flymake设置:

(when (load "flymake" t)
 (defun flymake-pylint-init ()
 (let* ((temp-file (flymake-init-create-temp-buffer-copy
                    'flymake-create-temp-inplace))
        (local-file (file-relative-name
                     temp-file
                     (file-name-directory buffer-file-name))))
   (list "epylint" (list local-file))))

(add-to-list 'flymake-allowed-file-name-masks '("\.py\'" flymake-pylint-init))) (add-hook 'python-mode-hook 'flymake-mode)

【问题讨论】:

    标签: python emacs


    【解决方案1】:

    我遇到了同样的问题,并通过使 emacs 不为传递给解释器的临时缓冲区加载 flymake 来解决它。我

    我为 Python 设置的 flymake 的相关位:

    (when (load "flymake" t)
      (defun flymake-python-init ()
        (let* ((temp-file (flymake-init-create-temp-buffer-copy
                         'flymake-create-temp-inplace))
             (local-file (file-relative-name
                          temp-file
                          (file-name-directory buffer-file-name))))
        (list "pyflymake" (list local-file)))) ; substitute epylint for this
      (push '(".+\\.py$" flymake-python-init) flymake-allowed-file-name-masks))
    
    (add-hook 'python-mode-hook
              (lambda ()
                ; Activate flymake unless buffer is a tmp buffer for the interpreter
                (unless (eq buffer-file-name nil) (flymake-mode t)) ; this should fix your problem
                ;; Bind a few keys for navigating errors
                (local-set-key (kbd "C-c w") 'show-fly-err-at-point) ; remove these if you want
                (local-set-key (kbd "M-n") 'flymake-goto-next-error)
                (local-set-key (kbd "M-p") 'flymake-goto-prev-error)))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-19
      • 1970-01-01
      • 2020-07-14
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-11
      相关资源
      最近更新 更多