aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorXue Fuqiao2013-05-25 09:26:12 +0800
committerXue Fuqiao2013-05-25 09:26:12 +0800
commit5d028165eaee1c5d0e59859199f8c6a51230eb97 (patch)
treee9a4ea6772d628b7590faaf47f8728f896f5ea60 /lisp
parent7a1d7ba7d22e9d82fdde0bc6e9fcc5152a7c9670 (diff)
downloademacs-5d028165eaee1c5d0e59859199f8c6a51230eb97.tar.gz
emacs-5d028165eaee1c5d0e59859199f8c6a51230eb97.zip
Refine the documentation of Flymake
* progmodes/flymake.el (flymake-save-buffer-in-file) (flymake-makehash, flymake-posn-at-point-as-event, flymake-nop) (flymake-selected-frame, flymake-log, flymake-ins-after) (flymake-set-at, flymake-get-buildfile-from-cache) (flymake-add-buildfile-to-cache, flymake-clear-buildfile-cache) (flymake-find-possible-master-files, flymake-save-buffer-in-file): Refine the doc string. (flymake-get-file-name-mode-and-masks): Reformat. (flymake-get-real-file-name-function): Fix a minor bug. * flymake.texi: Changing from one space between sentences to two.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/flymake.el61
2 files changed, 55 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e12652e7cbd..3cb0535ce5e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12013-05-25 Xue Fuqiao <xfq.free@gmail.com>
2
3 * progmodes/flymake.el (flymake-save-buffer-in-file)
4 (flymake-makehash, flymake-posn-at-point-as-event, flymake-nop)
5 (flymake-selected-frame, flymake-log, flymake-ins-after)
6 (flymake-set-at, flymake-get-buildfile-from-cache)
7 (flymake-add-buildfile-to-cache, flymake-clear-buildfile-cache)
8 (flymake-find-possible-master-files, flymake-save-buffer-in-file):
9 Refine the doc string.
10 (flymake-get-file-name-mode-and-masks): Reformat.
11 (flymake-get-real-file-name-function): Fix a minor bug.
12
12013-05-24 Juri Linkov <juri@jurta.org> 132013-05-24 Juri Linkov <juri@jurta.org>
2 14
3 * progmodes/grep.el (grep-mode-font-lock-keywords): 15 * progmodes/grep.el (grep-mode-font-lock-keywords):
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 79bccd138ee..aed62b27450 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1,4 +1,4 @@
1;;; flymake.el -- a universal on-the-fly syntax checker 1;;; flymake.el --- a universal on-the-fly syntax checker
2 2
3;; Copyright (C) 2003-2013 Free Software Foundation, Inc. 3;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 4
@@ -68,6 +68,9 @@
68 68
69;;;; [[ cross-emacs compatibility routines 69;;;; [[ cross-emacs compatibility routines
70(defsubst flymake-makehash (&optional test) 70(defsubst flymake-makehash (&optional test)
71 "Create and return a new hash table using TEST to compare keys.
72It uses the function `make-hash-table' to make a hash-table if
73you use GNU Emacs, otherwise it uses `makehash'."
71 (if (fboundp 'make-hash-table) 74 (if (fboundp 'make-hash-table)
72 (if test (make-hash-table :test test) (make-hash-table)) 75 (if test (make-hash-table :test test) (make-hash-table))
73 (with-no-warnings 76 (with-no-warnings
@@ -106,10 +109,12 @@ Zero-length substrings at the beginning and end of the list are omitted."
106 (lambda () temporary-file-directory))) 109 (lambda () temporary-file-directory)))
107 110
108(defun flymake-posn-at-point-as-event (&optional position window dx dy) 111(defun flymake-posn-at-point-as-event (&optional position window dx dy)
109 "Return pixel position of top left corner of glyph at POSITION, 112 "Return pixel position of top left corner of glyph at POSITION.
110relative to top left corner of WINDOW, as a mouse-1 click 113
111event (identical to the event that would be triggered by clicking 114The position is relative to top left corner of WINDOW, as a
112mouse button 1 at the top left corner of the glyph). 115mouse-1 click event (identical to the event that would be
116triggered by clicking mouse button 1 at the top left corner of
117the glyph).
113 118
114POSITION and WINDOW default to the position of point in the 119POSITION and WINDOW default to the position of point in the
115selected window. 120selected window.
@@ -164,7 +169,8 @@ See `x-popup-menu' for the menu specifier format."
164 169
165(if (featurep 'xemacs) (progn 170(if (featurep 'xemacs) (progn
166 171
167(defun flymake-nop ()) 172(defun flymake-nop ()
173 "Do nothing.")
168 174
169(defun flymake-make-xemacs-menu (menu-data) 175(defun flymake-make-xemacs-menu (menu-data)
170 "Return a menu specifier using MENU-DATA." 176 "Return a menu specifier using MENU-DATA."
@@ -187,6 +193,7 @@ See `x-popup-menu' for the menu specifier format."
187 (count-lines (window-start) (point)))) 193 (count-lines (window-start) (point))))
188 194
189(defun flymake-selected-frame () 195(defun flymake-selected-frame ()
196 "Return the frame that is now selected."
190 (if (fboundp 'window-edges) 197 (if (fboundp 'window-edges)
191 (selected-frame) 198 (selected-frame)
192 (selected-window))) 199 (selected-window)))
@@ -217,31 +224,42 @@ See `x-popup-menu' for the menu specifier format."
217 :group 'flymake 224 :group 'flymake
218 :type 'integer) 225 :type 'integer)
219 226
227
228;; (defcustom flymake-log-file-name "~/flymake.log"
229;; "Where to put the flymake log if logging is enabled.
230;;
231;; See `flymake-log-level' if you want to control what is logged."
232;; :group 'flymake
233;; :type 'string)
234
220(defun flymake-log (level text &rest args) 235(defun flymake-log (level text &rest args)
221 "Log a message at level LEVEL. 236 "Log a message at level LEVEL.
222If LEVEL is higher than `flymake-log-level', the message is 237If LEVEL is higher than `flymake-log-level', the message is
223ignored. Otherwise, it is printed using `message'. 238ignored. Otherwise, it is printed using `message'.
224TEXT is a format control string, and the remaining arguments ARGS 239TEXT is a format control string, and the remaining arguments ARGS
225are the string substitutions (see `format')." 240are the string substitutions (see the function `format')."
226 (if (<= level flymake-log-level) 241 (if (<= level flymake-log-level)
227 (let* ((msg (apply 'format text args))) 242 (let* ((msg (apply 'format text args)))
228 (message "%s" msg) 243 (message "%s" msg)
229 ;;(with-temp-buffer 244 ;;(with-temp-buffer
230 ;; (insert msg) 245 ;; (insert msg)
231 ;; (insert "\n") 246 ;; (insert "\n")
232 ;; (flymake-save-buffer-in-file "d:/flymake.log" t) ; make log file name customizable 247 ;; (flymake-save-buffer-in-file "~/flymake.log") ; make log file name customizable
233 ;;) 248 ;;)
234 ))) 249 )))
235 250
236(defun flymake-ins-after (list pos val) 251(defun flymake-ins-after (list pos val)
237 "Insert VAL into LIST after position POS." 252 "Insert VAL into LIST after position POS.
238 (let ((tmp (copy-sequence list))) ; (???) 253POS counts from zero."
254 (let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST
239 (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp))) 255 (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp)))
240 tmp)) 256 tmp))
241 257
242(defun flymake-set-at (list pos val) 258(defun flymake-set-at (list pos val)
243 "Set VAL at position POS in LIST." 259)
244 (let ((tmp (copy-sequence list))) ; (???) 260"Set VAL at position POS in LIST.
261POS counts from zero."
262(let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST
245 (setcar (nthcdr pos tmp) val) 263 (setcar (nthcdr pos tmp) val)
246 tmp)) 264 tmp))
247 265
@@ -249,7 +267,6 @@ are the string substitutions (see `format')."
249 "List of currently active flymake processes.") 267 "List of currently active flymake processes.")
250 268
251(defvar flymake-output-residual nil) 269(defvar flymake-output-residual nil)
252
253(make-variable-buffer-local 'flymake-output-residual) 270(make-variable-buffer-local 'flymake-output-residual)
254 271
255(defgroup flymake nil 272(defgroup flymake nil
@@ -310,7 +327,7 @@ NAME is the file name function to use, default `flymake-get-real-file-name'."
310 (unless (stringp file-name) 327 (unless (stringp file-name)
311 (error "Invalid file-name")) 328 (error "Invalid file-name"))
312 (let ((fnm flymake-allowed-file-name-masks) 329 (let ((fnm flymake-allowed-file-name-masks)
313 (mode-and-masks nil)) 330 (mode-and-masks nil))
314 (while (and (not mode-and-masks) fnm) 331 (while (and (not mode-and-masks) fnm)
315 (if (string-match (car (car fnm)) file-name) 332 (if (string-match (car (car fnm)) file-name)
316 (setq mode-and-masks (cdr (car fnm)))) 333 (setq mode-and-masks (cdr (car fnm))))
@@ -336,18 +353,22 @@ Return nil if we cannot, non-nil if we can."
336 'flymake-simple-cleanup)) 353 'flymake-simple-cleanup))
337 354
338(defun flymake-get-real-file-name-function (file-name) 355(defun flymake-get-real-file-name-function (file-name)
339 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name)) 356 (or (nth 4 (flymake-get-file-name-mode-and-masks file-name))
340 'flymake-get-real-file-name)) 357 'flymake-get-real-file-name))
341 358
342(defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) 359(defvar flymake-find-buildfile-cache (flymake-makehash 'equal))
343 360
344(defun flymake-get-buildfile-from-cache (dir-name) 361(defun flymake-get-buildfile-from-cache (dir-name)
362 "Look up DIR-NAME in cache and return its associated value.
363If DIR-NAME is not found, return nil."
345 (gethash dir-name flymake-find-buildfile-cache)) 364 (gethash dir-name flymake-find-buildfile-cache))
346 365
347(defun flymake-add-buildfile-to-cache (dir-name buildfile) 366(defun flymake-add-buildfile-to-cache (dir-name buildfile)
367 "Associate DIR-NAME with BUILDFILE in the buildfile cache."
348 (puthash dir-name buildfile flymake-find-buildfile-cache)) 368 (puthash dir-name buildfile flymake-find-buildfile-cache))
349 369
350(defun flymake-clear-buildfile-cache () 370(defun flymake-clear-buildfile-cache ()
371 "Clear the buildfile cache."
351 (clrhash flymake-find-buildfile-cache)) 372 (clrhash flymake-find-buildfile-cache))
352 373
353(defun flymake-find-buildfile (buildfile-name source-dir-name) 374(defun flymake-find-buildfile (buildfile-name source-dir-name)
@@ -394,9 +415,11 @@ Return t if so, nil if not."
394 415
395(defun flymake-find-possible-master-files (file-name master-file-dirs masks) 416(defun flymake-find-possible-master-files (file-name master-file-dirs masks)
396 "Find (by name and location) all possible master files. 417 "Find (by name and location) all possible master files.
397Master files include .cpp and .c for .h. Files are searched for 418
398starting from the .h directory and max max-level parent dirs. 419Name is specified by FILE-NAME and location is specified by
399File contents are not checked." 420MASTER-FILE-DIRS. Master files include .cpp and .c for .h.
421Files are searched for starting from the .h directory and max
422max-level parent dirs. File contents are not checked."
400 (let* ((dirs master-file-dirs) 423 (let* ((dirs master-file-dirs)
401 (files nil) 424 (files nil)
402 (done nil)) 425 (done nil))
@@ -593,6 +616,8 @@ Find master file, patch and save it."
593 nil)))) 616 nil))))
594 617
595(defun flymake-save-buffer-in-file (file-name) 618(defun flymake-save-buffer-in-file (file-name)
619 "Save the entire buffer contents into file FILE-NAME.
620Create parent directories as needed."
596 (make-directory (file-name-directory file-name) 1) 621 (make-directory (file-name-directory file-name) 1)
597 (write-region nil nil file-name nil 566) 622 (write-region nil nil file-name nil 566)
598 (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name)) 623 (flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))