2

I got an error from flymake-get-file-name-mode-and-masks "Invalid file name" when I have called py-execute-region (bind to C-c |). Also void buffer with name like /tmp/python-3434.py appears.

My flymake setup:

(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)

1 Answer 1

4

I had this same problem, and solved it by making emacs not load flymake for temporary buffers passed to the interpreter. I

The relevant bits of my flymake setup for Python:

(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)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.