* progmodes/flymake.el (flymake-mode): If the buffer isn't
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Sat, 2 Jul 2011 22:55:41 +0000 (00:55 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sat, 2 Jul 2011 22:55:41 +0000 (00:55 +0200)
associated with a file, refuse to run instead of erroring out
(bug#6084).

lisp/ChangeLog
lisp/progmodes/flymake.el

index ed3ae36..2955592 100644 (file)
@@ -1,5 +1,9 @@
 2011-07-02  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * progmodes/flymake.el (flymake-mode): If the buffer isn't
+       associated with a file, refuse to run instead of erroring out
+       (bug#6084).
+
        * textmodes/fill.el (fill-region): Remove the "Ordinarily" from
        the doc string, since it appears that using `fill-column' always
        controls the width (bug#7845).
index 249c2b5..1c138f0 100644 (file)
@@ -1339,8 +1339,12 @@ With arg, turn Flymake mode on if and only if arg is positive."
 
    ;; Turning the mode ON.
    (flymake-mode
-    (if (not (flymake-can-syntax-check-file buffer-file-name))
-        (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name))
+    (cond
+     ((not buffer-file-name)
+      (message "Flymake unable to run without a buffer file name"))
+     ((not (flymake-can-syntax-check-file buffer-file-name))
+      (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)))
+     (t
       (add-hook 'after-change-functions 'flymake-after-change-function nil t)
       (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
       (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
@@ -1352,7 +1356,7 @@ With arg, turn Flymake mode on if and only if arg is positive."
             (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
 
       (when flymake-start-syntax-check-on-find-file
-        (flymake-start-syntax-check))))
+        (flymake-start-syntax-check)))))
 
    ;; Turning the mode OFF.
    (t