-;;; flymake.el -- a universal on-the-fly syntax checker
+;;; flymake.el --- a universal on-the-fly syntax checker
;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
;;;; [[ cross-emacs compatibility routines
(defsubst flymake-makehash (&optional test)
+ "Create and return a new hash table using TEST to compare keys.
+It uses the function `make-hash-table' to make a hash-table if
+you use GNU Emacs, otherwise it uses `makehash'."
(if (fboundp 'make-hash-table)
(if test (make-hash-table :test test) (make-hash-table))
(with-no-warnings
(lambda () temporary-file-directory)))
(defun flymake-posn-at-point-as-event (&optional position window dx dy)
- "Return pixel position of top left corner of glyph at POSITION,
-relative to top left corner of WINDOW, as a mouse-1 click
-event (identical to the event that would be triggered by clicking
-mouse button 1 at the top left corner of the glyph).
+ "Return pixel position of top left corner of glyph at POSITION.
+
+The position is relative to top left corner of WINDOW, as a
+mouse-1 click event (identical to the event that would be
+triggered by clicking mouse button 1 at the top left corner of
+the glyph).
POSITION and WINDOW default to the position of point in the
selected window.
(if (featurep 'xemacs) (progn
-(defun flymake-nop ())
+(defun flymake-nop ()
+ "Do nothing."
+ nil)
(defun flymake-make-xemacs-menu (menu-data)
"Return a menu specifier using MENU-DATA."
(count-lines (window-start) (point))))
(defun flymake-selected-frame ()
+ "Return the frame that is now selected."
(if (fboundp 'window-edges)
(selected-frame)
(selected-window)))
:group 'flymake
:type 'integer)
+
+;; (defcustom flymake-log-file-name "~/flymake.log"
+;; "Where to put the flymake log if logging is enabled.
+;;
+;; See `flymake-log-level' if you want to control what is logged."
+;; :group 'flymake
+;; :type 'string)
+
(defun flymake-log (level text &rest args)
"Log a message at level LEVEL.
If LEVEL is higher than `flymake-log-level', the message is
ignored. Otherwise, it is printed using `message'.
TEXT is a format control string, and the remaining arguments ARGS
-are the string substitutions (see `format')."
+are the string substitutions (see the function `format')."
(if (<= level flymake-log-level)
(let* ((msg (apply 'format text args)))
(message "%s" msg)
;;(with-temp-buffer
;; (insert msg)
;; (insert "\n")
- ;; (flymake-save-buffer-in-file "d:/flymake.log" t) ; make log file name customizable
+ ;; (flymake-save-buffer-in-file "~/flymake.log") ; make log file name customizable
;;)
)))
(defun flymake-ins-after (list pos val)
- "Insert VAL into LIST after position POS."
- (let ((tmp (copy-sequence list))) ; (???)
+ "Insert VAL into LIST after position POS.
+POS counts from zero."
+ (let ((tmp (copy-sequence list)))
(setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp)))
tmp))
(defun flymake-set-at (list pos val)
- "Set VAL at position POS in LIST."
- (let ((tmp (copy-sequence list))) ; (???)
+ "Set VAL at position POS in LIST.
+POS counts from zero."
+ (let ((tmp (copy-sequence list)))
(setcar (nthcdr pos tmp) val)
tmp))
"List of currently active flymake processes.")
(defvar flymake-output-residual nil)
-
(make-variable-buffer-local 'flymake-output-residual)
(defgroup flymake nil
(unless (stringp file-name)
(error "Invalid file-name"))
(let ((fnm flymake-allowed-file-name-masks)
- (mode-and-masks nil))
+ (mode-and-masks nil))
(while (and (not mode-and-masks) fnm)
(if (string-match (car (car fnm)) file-name)
(setq mode-and-masks (cdr (car fnm))))
(defvar flymake-find-buildfile-cache (flymake-makehash 'equal))
(defun flymake-get-buildfile-from-cache (dir-name)
+ "Look up DIR-NAME in cache and return its associated value.
+If DIR-NAME is not found, return nil."
(gethash dir-name flymake-find-buildfile-cache))
(defun flymake-add-buildfile-to-cache (dir-name buildfile)
+ "Associate DIR-NAME with BUILDFILE in the buildfile cache."
(puthash dir-name buildfile flymake-find-buildfile-cache))
(defun flymake-clear-buildfile-cache ()
+ "Clear the buildfile cache."
(clrhash flymake-find-buildfile-cache))
(defun flymake-find-buildfile (buildfile-name source-dir-name)
(defun flymake-find-possible-master-files (file-name master-file-dirs masks)
"Find (by name and location) all possible master files.
-Master files include .cpp and .c for .h. Files are searched for
-starting from the .h directory and max max-level parent dirs.
-File contents are not checked."
+
+Name is specified by FILE-NAME and location is specified by
+MASTER-FILE-DIRS. Master files include .cpp and .c for .h.
+Files are searched for starting from the .h directory and max
+max-level parent dirs. File contents are not checked."
(let* ((dirs master-file-dirs)
(files nil)
(done nil))
nil))))
(defun flymake-save-buffer-in-file (file-name)
+ "Save the entire buffer contents into file FILE-NAME.
+Create parent directories as needed."
(make-directory (file-name-directory file-name) 1)
(write-region nil nil file-name nil 566)
(flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
;; :type '(repeat (string number number number))
;;)
-(defvar flymake-warning-re "^[wW]arning"
- "Regexp matching against err-text to detect a warning.")
+(define-obsolete-variable-alias 'flymake-warning-re 'flymake-warning-predicate "24.4")
+(defvar flymake-warning-predicate "^[wW]arning"
+ "Predicate matching against error text to detect a warning.
+Takes a single argument, the error's text and should return non-nil
+if it's a warning.
+Instead of a function, it can also be a regular expression.")
(defun flymake-parse-line (line)
"Parse LINE to see if it is an error or warning.
(line-idx (nth 2 (car patterns))))
(setq raw-file-name (if file-idx (match-string file-idx line) nil))
- (setq line-no (if line-idx (string-to-number (match-string line-idx line)) 0))
+ (setq line-no (if line-idx (string-to-number
+ (match-string line-idx line)) 0))
(setq err-text (if (> (length (car patterns)) 4)
(match-string (nth 4 (car patterns)) line)
- (flymake-patch-err-text (substring line (match-end 0)))))
- (or err-text (setq err-text "<no error text>"))
- (if (and err-text (string-match flymake-warning-re err-text))
- (setq err-type "w")
- )
- (flymake-log 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" file-idx line-idx
- raw-file-name line-no err-text)
+ (flymake-patch-err-text
+ (substring line (match-end 0)))))
+ (if (null err-text)
+ (setq err-text "<no error text>")
+ (when (cond ((stringp flymake-warning-predicate)
+ (string-match flymake-warning-predicate err-text))
+ ((functionp flymake-warning-predicate)
+ (funcall flymake-warning-predicate err-text)))
+ (setq err-type "w")))
+ (flymake-log
+ 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s"
+ file-idx line-idx raw-file-name line-no err-text)
(setq matched t)))
(setq patterns (cdr patterns)))
(if matched