aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2006-01-10 18:46:07 +0000
committerStefan Monnier2006-01-10 18:46:07 +0000
commit587d108e557e9f22a35dd46f6acccc9894fec14a (patch)
tree886068d0888075d6a1666d781d40b6e805bb90ee
parentb8f7f3be80c182ea4b6f112eb1e1193ed78233eb (diff)
downloademacs-587d108e557e9f22a35dd46f6acccc9894fec14a.tar.gz
emacs-587d108e557e9f22a35dd46f6acccc9894fec14a.zip
(flymake-split-string): Remove >1 empty strings at beg/end of the result.
(flymake-find-buildfile, flymake-find-possible-master-files): Use expand-file-name. (flymake-fix-file-name): Don't replace \ with / and don't remove ./ since expand-file-name does it for us. Use directory-file-name. (flymake-ler-get-full-file, flymake-ler-get-file, flymake-ler-get-line) (flymake-ler-get-type, flymake-ler-get-text) (flymake-ler-make-ler): Remove. Replace by defstruct. Update callers. (flymake-current-line-no): Remove spurious interactive spec. (flymake-delete-temp-directory): Remove unused var `slash-pos'. (flymake-check-include): Remove arg inc-path merged into inc-name. (flymake-check-patch-master-file-buffer): Fit in 80 columns. Arg regexp-list replaced by a simple regexp. (flymake-master-make-header-init, flymake-master-tex-init): Correspondingly replace regexp-list with a regexp. Fix regexp.
-rw-r--r--lisp/ChangeLog19
-rw-r--r--lisp/progmodes/flymake.el242
2 files changed, 129 insertions, 132 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1eecc5adb86..c4110ca1ae6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,22 @@
12006-01-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/flymake.el (flymake-split-string): Remove more than one
4 empty string at beg/end of the result.
5 (flymake-find-buildfile, flymake-find-possible-master-files):
6 Use expand-file-name.
7 (flymake-fix-file-name): Don't replace \ with / and don't remove ./
8 since expand-file-name does it for us. Use directory-file-name.
9 (flymake-ler-get-full-file, flymake-ler-get-file, flymake-ler-get-line)
10 (flymake-ler-get-type, flymake-ler-get-text)
11 (flymake-ler-make-ler): Remove. Replace by defstruct. Update callers.
12 (flymake-current-line-no): Remove spurious interactive spec.
13 (flymake-delete-temp-directory): Remove unused var `slash-pos'.
14 (flymake-check-include): Remove arg inc-path merged into inc-name.
15 (flymake-check-patch-master-file-buffer): Fit in 80 columns.
16 Arg regexp-list replaced by a simple regexp.
17 (flymake-master-make-header-init, flymake-master-tex-init):
18 Correspondingly replace regexp-list with a regexp. Fix regexp.
19
12006-01-10 Simon Josefsson <jas@extundo.com> 202006-01-10 Simon Josefsson <jas@extundo.com>
2 21
3 * mail/smtpmail.el (smtpmail-try-auth-methods): Add comment 22 * mail/smtpmail.el (smtpmail-try-auth-methods): Add comment
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 44da366cbb6..cfb7856575b 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -92,11 +92,10 @@
92 "Split STR into a list of substrings bounded by PATTERN. 92 "Split STR into a list of substrings bounded by PATTERN.
93Zero-length substrings at the beginning and end of the list are omitted." 93Zero-length substrings at the beginning and end of the list are omitted."
94 (let ((split (split-string str pattern))) 94 (let ((split (split-string str pattern)))
95 (if (and (> (length split) 0) (= 0 (length (elt split 0)))) 95 (while (equal (car split) "") (setq split (cdr split)))
96 (setq split (cdr split))) 96 (setq split (nreverse split))
97 (if (and (> (length split) 0) (= 0 (length (elt split (1- (length split)))))) 97 (while (equal (car split) "") (setq split (cdr split)))
98 (setq split (nreverse (cdr (nreverse split))))) 98 (nreverse split)))))
99 split))))
100 99
101(defalias 'flymake-get-temp-dir 100(defalias 'flymake-get-temp-dir
102 (if (fboundp 'temp-directory) 101 (if (fboundp 'temp-directory)
@@ -319,12 +318,10 @@ Return its file name if found, or nil if not found."
319 (or (flymake-get-buildfile-from-cache source-dir-name) 318 (or (flymake-get-buildfile-from-cache source-dir-name)
320 (let* ((dirs flymake-buildfile-dirs) 319 (let* ((dirs flymake-buildfile-dirs)
321 (buildfile-dir nil) 320 (buildfile-dir nil)
322 (buildfile nil)
323 (found nil)) 321 (found nil))
324 (while (and (not found) dirs) 322 (while (and (not found) dirs)
325 (setq buildfile-dir (concat source-dir-name (car dirs))) 323 (setq buildfile-dir (concat source-dir-name (car dirs)))
326 (setq buildfile (concat buildfile-dir "/" buildfile-name)) 324 (when (file-exists-p (expand-file-name buildfile-name buildfile-dir))
327 (when (file-exists-p buildfile)
328 (setq found t)) 325 (setq found t))
329 (setq dirs (cdr dirs))) 326 (setq dirs (cdr dirs)))
330 (if found 327 (if found
@@ -339,12 +336,10 @@ Return its file name if found, or nil if not found."
339(defun flymake-fix-file-name (name) 336(defun flymake-fix-file-name (name)
340 "Replace all occurences of '\' with '/'." 337 "Replace all occurences of '\' with '/'."
341 (when name 338 (when name
342 (let* ((new-name (flymake-replace-regexp-in-string "[\\]" "/" (expand-file-name name))) 339 (setq name (expand-file-name name))
343 (last-char (elt new-name (1- (length new-name))))) 340 (setq name (abbreviate-file-name name))
344 (setq new-name (flymake-replace-regexp-in-string "\\./" "" new-name)) 341 (setq name (directory-file-name name))
345 (if (equal "/" (char-to-string last-char)) 342 name))
346 (setq new-name (substring new-name 0 (1- (length new-name)))))
347 new-name)))
348 343
349(defun flymake-same-files (file-name-one file-name-two) 344(defun flymake-same-files (file-name-one file-name-two)
350 "Check if FILE-NAME-ONE and FILE-NAME-TWO point to same file. 345 "Check if FILE-NAME-ONE and FILE-NAME-TWO point to same file.
@@ -375,8 +370,7 @@ File contents are not checked."
375 (done nil)) 370 (done nil))
376 371
377 (while (and (not done) dirs) 372 (while (and (not done) dirs)
378 (let* ((dir (concat (flymake-fix-file-name (file-name-directory file-name)) 373 (let* ((dir (expand-file-name (car dirs) (file-name-directory file-name)))
379 "/" (car dirs)))
380 (masks masks)) 374 (masks masks))
381 (while (and (file-exists-p dir) (not done) masks) 375 (while (and (file-exists-p dir) (not done) masks)
382 (let* ((mask (car masks)) 376 (let* ((mask (car masks))
@@ -412,53 +406,58 @@ to the beginning of the list (File.h -> File.cpp moved to top)."
412 :group 'flymake 406 :group 'flymake
413 :type 'integer) 407 :type 'integer)
414 408
415(defun flymake-check-patch-master-file-buffer (master-file-temp-buffer 409(defun flymake-check-patch-master-file-buffer
416 master-file-name patched-master-file-name 410 (master-file-temp-buffer
417 source-file-name patched-source-file-name 411 master-file-name patched-master-file-name
418 include-dirs regexp-list) 412 source-file-name patched-source-file-name
413 include-dirs regexp)
419 "Check if MASTER-FILE-NAME is a master file for SOURCE-FILE-NAME. 414 "Check if MASTER-FILE-NAME is a master file for SOURCE-FILE-NAME.
420For .cpp master file this means it includes SOURCE-FILE-NAME (.h). 415For .cpp master file this means it includes SOURCE-FILE-NAME (.h).
421If yes, patch a copy of MASTER-FILE-NAME to include PATCHED-SOURCE-FILE-NAME 416If yes, patch a copy of MASTER-FILE-NAME to include PATCHED-SOURCE-FILE-NAME
422instead of SOURCE-FILE-NAME. 417instead of SOURCE-FILE-NAME.
423Whether a buffer for MATER-FILE-NAME exists, use it as a source 418Whether a buffer for MATER-FILE-NAME exists, use it as a source
424instead of reading master file from disk." 419instead of reading master file from disk."
425 (let* ((found nil) 420 (let* ((source-file-nondir (file-name-nondirectory source-file-name))
426 (regexp (format (nth 0 regexp-list) ; "[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 421 (found nil)
427 (file-name-nondirectory source-file-name)))
428 (path-idx (nth 1 regexp-list))
429 (name-idx (nth 2 regexp-list))
430 (inc-path nil)
431 (inc-name nil) 422 (inc-name nil)
432 (search-limit flymake-check-file-limit)) 423 (search-limit flymake-check-file-limit))
433 (save-excursion 424 (setq regexp
434 (unwind-protect 425 (format regexp ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\""
435 (progn 426 (regexp-quote source-file-nondir)))
436 (set-buffer master-file-temp-buffer) 427 (unwind-protect
437 (when (> search-limit (point-max)) 428 (with-current-buffer master-file-temp-buffer
438 (setq search-limit (point-max))) 429 (when (> search-limit (point-max))
439 (flymake-log 3 "checking %s against regexp %s" master-file-name regexp) 430 (setq search-limit (point-max)))
440 (goto-char (point-min)) 431 (flymake-log 3 "checking %s against regexp %s"
441 (while (and (< (point) search-limit) (re-search-forward regexp search-limit t)) 432 master-file-name regexp)
442 (let* ((match-beg (match-beginning name-idx)) 433 (goto-char (point-min))
443 (match-end (match-end name-idx))) 434 (while (and (< (point) search-limit)
444 435 (re-search-forward regexp search-limit t))
445 (flymake-log 3 "found possible match for %s" (file-name-nondirectory source-file-name)) 436 (let ((match-beg (match-beginning 1))
446 (setq inc-path (match-string path-idx)) 437 (match-end (match-end 1)))
447 (setq inc-name (match-string name-idx)) 438
448 (when (string= inc-name (file-name-nondirectory source-file-name)) 439 (flymake-log 3 "found possible match for %s" source-file-nondir)
449 (flymake-log 3 "inc-path=%s inc-name=%s" inc-path inc-name) 440 (setq inc-name (match-string 1))
450 (when (flymake-check-include source-file-name inc-path inc-name include-dirs) 441 (when (eq t (compare-strings
451 (setq found t) 442 source-file-nondir nil nil
452 ;; replace-match is not used here as it fails in 443 inc-name (- (length inc-name)
453 ;; XEmacs with 'last match not a buffer' error as 444 (length source-file-nondir)) nil))
454 ;; check-includes calls replace-in-string 445 (flymake-log 3 "inc-name=%s" inc-name)
455 (flymake-replace-region match-beg match-end 446 (when (flymake-check-include source-file-name inc-name
456 (file-name-nondirectory patched-source-file-name)))) 447 include-dirs)
457 (forward-line 1))) 448 (setq found t)
458 (when found 449 ;; replace-match is not used here as it fails in
459 (flymake-save-buffer-in-file patched-master-file-name))) 450 ;; XEmacs with 'last match not a buffer' error as
460 ;;+(flymake-log 3 "killing buffer %s" (buffer-name master-file-temp-buffer)) 451 ;; check-includes calls replace-in-string
461 (kill-buffer master-file-temp-buffer))) 452 (flymake-replace-region
453 match-beg match-end
454 (file-name-nondirectory patched-source-file-name))))
455 (forward-line 1)))
456 (when found
457 (flymake-save-buffer-in-file patched-master-file-name)))
458 ;;+(flymake-log 3 "killing buffer %s"
459 ;; (buffer-name master-file-temp-buffer))
460 (kill-buffer master-file-temp-buffer))
462 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found) 461 ;;+(flymake-log 3 "check-patch master file %s: %s" master-file-name found)
463 (when found 462 (when found
464 (flymake-log 2 "found master file %s" master-file-name)) 463 (flymake-log 2 "found master file %s" master-file-name))
@@ -487,23 +486,19 @@ instead of reading master file from disk."
487 (insert-buffer-substring buffer) 486 (insert-buffer-substring buffer)
488 (current-buffer))) 487 (current-buffer)))
489 488
490(defun flymake-check-include (source-file-name inc-path inc-name include-dirs) 489(defun flymake-check-include (source-file-name inc-name include-dirs)
491 "Check if SOURCE-FILE-NAME can be found in include path. 490 "Check if SOURCE-FILE-NAME can be found in include path.
492Return t if it can be found via include path using INC-PATH and INC-NAME." 491Return t if it can be found via include path using INC-NAME."
493 (if (file-name-absolute-p inc-path) 492 (if (file-name-absolute-p inc-name)
494 (flymake-same-files source-file-name (concat inc-path "/" inc-name)) 493 (flymake-same-files source-file-name inc-name)
495 (let* ((file-name nil) 494 (while (and include-dirs
496 (found nil)) 495 (not (flymake-same-files
497 (while (and (not found) include-dirs) 496 source-file-name
498 (setq file-name (concat (file-name-directory source-file-name) 497 (concat (file-name-directory source-file-name)
499 "/" (car include-dirs))) 498 "/" (car include-dirs)
500 (if (> (length inc-path) 0) 499 "/" inc-name))))
501 (setq file-name (concat file-name "/" inc-path))) 500 (setq include-dirs (cdr include-dirs)))
502 (setq file-name (concat file-name "/" inc-name)) 501 include-dirs))
503 (when (flymake-same-files source-file-name file-name)
504 (setq found t))
505 (setq include-dirs (cdr include-dirs)))
506 found)))
507 502
508(defun flymake-find-buffer-for-file (file-name) 503(defun flymake-find-buffer-for-file (file-name)
509 "Check if there exists a buffer visiting FILE-NAME. 504 "Check if there exists a buffer visiting FILE-NAME.
@@ -512,7 +507,7 @@ Return t if so, nil if not."
512 (if buffer-name 507 (if buffer-name
513 (get-buffer buffer-name)))) 508 (get-buffer buffer-name))))
514 509
515(defun flymake-create-master-file (source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp-list) 510(defun flymake-create-master-file (source-file-name patched-source-file-name get-incl-dirs-f create-temp-f masks include-regexp)
516 "Save SOURCE-FILE-NAME with a different name. 511 "Save SOURCE-FILE-NAME with a different name.
517Find master file, patch and save it." 512Find master file, patch and save it."
518 (let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks)) 513 (let* ((possible-master-files (flymake-find-possible-master-files source-file-name flymake-master-file-dirs masks))
@@ -537,7 +532,7 @@ Find master file, patch and save it."
537 source-file-name 532 source-file-name
538 patched-source-file-name 533 patched-source-file-name
539 (funcall get-incl-dirs-f (file-name-directory master-file-name)) 534 (funcall get-incl-dirs-f (file-name-directory master-file-name))
540 include-regexp-list)) 535 include-regexp))
541 (setq idx (1+ idx))) 536 (setq idx (1+ idx)))
542 (if found 537 (if found
543 (list master-file-name patched-master-file-name) 538 (list master-file-name patched-master-file-name)
@@ -662,45 +657,31 @@ It's flymake process filter."
662(defun flymake-er-get-line-err-info-list (err-info) 657(defun flymake-er-get-line-err-info-list (err-info)
663 (nth 1 err-info)) 658 (nth 1 err-info))
664 659
665;; getters/setters for line-err-info: (file, line, type, text). 660(defstruct (flymake-ler
666(defun flymake-ler-make-ler (file line type text &optional full-file) 661 (:constructor nil)
667 (list file line type text full-file)) 662 (:constructor flymake-ler-make-ler (file line type text &optional full-file)))
668 663 file line type text full-file)
669(defun flymake-ler-get-file (line-err-info)
670 (nth 0 line-err-info))
671
672(defun flymake-ler-get-line (line-err-info)
673 (nth 1 line-err-info))
674
675(defun flymake-ler-get-type (line-err-info)
676 (nth 2 line-err-info))
677
678(defun flymake-ler-get-text (line-err-info)
679 (nth 3 line-err-info))
680
681(defun flymake-ler-get-full-file (line-err-info)
682 (nth 4 line-err-info))
683 664
684(defun flymake-ler-set-file (line-err-info file) 665(defun flymake-ler-set-file (line-err-info file)
685 (flymake-ler-make-ler file 666 (flymake-ler-make-ler file
686 (flymake-ler-get-line line-err-info) 667 (flymake-ler-line line-err-info)
687 (flymake-ler-get-type line-err-info) 668 (flymake-ler-type line-err-info)
688 (flymake-ler-get-text line-err-info) 669 (flymake-ler-text line-err-info)
689 (flymake-ler-get-full-file line-err-info))) 670 (flymake-ler-full-file line-err-info)))
690 671
691(defun flymake-ler-set-full-file (line-err-info full-file) 672(defun flymake-ler-set-full-file (line-err-info full-file)
692 (flymake-ler-make-ler (flymake-ler-get-file line-err-info) 673 (flymake-ler-make-ler (flymake-ler-file line-err-info)
693 (flymake-ler-get-line line-err-info) 674 (flymake-ler-line line-err-info)
694 (flymake-ler-get-type line-err-info) 675 (flymake-ler-type line-err-info)
695 (flymake-ler-get-text line-err-info) 676 (flymake-ler-text line-err-info)
696 full-file)) 677 full-file))
697 678
698(defun flymake-ler-set-line (line-err-info line) 679(defun flymake-ler-set-line (line-err-info line)
699 (flymake-ler-make-ler (flymake-ler-get-file line-err-info) 680 (flymake-ler-make-ler (flymake-ler-file line-err-info)
700 line 681 line
701 (flymake-ler-get-type line-err-info) 682 (flymake-ler-type line-err-info)
702 (flymake-ler-get-text line-err-info) 683 (flymake-ler-text line-err-info)
703 (flymake-ler-get-full-file line-err-info))) 684 (flymake-ler-full-file line-err-info)))
704 685
705(defun flymake-get-line-err-count (line-err-info-list type) 686(defun flymake-get-line-err-count (line-err-info-list type)
706 "Return number of errors of specified TYPE. 687 "Return number of errors of specified TYPE.
@@ -710,7 +691,7 @@ Value of TYPE is either \"e\" or \"w\"."
710 (err-count 0)) 691 (err-count 0))
711 692
712 (while (< idx count) 693 (while (< idx count)
713 (when (equal type (flymake-ler-get-type (nth idx line-err-info-list))) 694 (when (equal type (flymake-ler-type (nth idx line-err-info-list)))
714 (setq err-count (1+ err-count))) 695 (setq err-count (1+ err-count)))
715 (setq idx (1+ idx))) 696 (setq idx (1+ idx)))
716 err-count)) 697 err-count))
@@ -809,7 +790,7 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
809 (line-end (flymake-line-end-position)) 790 (line-end (flymake-line-end-position))
810 (beg line-beg) 791 (beg line-beg)
811 (end line-end) 792 (end line-end)
812 (tooltip-text (flymake-ler-get-text (nth 0 line-err-info-list))) 793 (tooltip-text (flymake-ler-text (nth 0 line-err-info-list)))
813 (face nil)) 794 (face nil))
814 795
815 (goto-char line-beg) 796 (goto-char line-beg)
@@ -852,7 +833,7 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
852 (setq line-err-info (flymake-parse-line (nth idx lines))) 833 (setq line-err-info (flymake-parse-line (nth idx lines)))
853 (when line-err-info 834 (when line-err-info
854 (setq real-file-name (funcall get-real-file-name-f 835 (setq real-file-name (funcall get-real-file-name-f
855 (flymake-ler-get-file line-err-info))) 836 (flymake-ler-file line-err-info)))
856 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) 837 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
857 838
858 (if (flymake-same-files real-file-name source-file-name) 839 (if (flymake-same-files real-file-name source-file-name)
@@ -984,12 +965,12 @@ Return its components if so, nil otherwise."
984 '(nil 0))) 965 '(nil 0)))
985 966
986(defun flymake-line-err-info-is-less-or-equal (line-one line-two) 967(defun flymake-line-err-info-is-less-or-equal (line-one line-two)
987 (or (string< (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) 968 (or (string< (flymake-ler-type line-one) (flymake-ler-type line-two))
988 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) 969 (and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
989 (not (flymake-ler-get-file line-one)) (flymake-ler-get-file line-two)) 970 (not (flymake-ler-file line-one)) (flymake-ler-file line-two))
990 (and (string= (flymake-ler-get-type line-one) (flymake-ler-get-type line-two)) 971 (and (string= (flymake-ler-type line-one) (flymake-ler-type line-two))
991 (or (and (flymake-ler-get-file line-one) (flymake-ler-get-file line-two)) 972 (or (and (flymake-ler-file line-one) (flymake-ler-file line-two))
992 (and (not (flymake-ler-get-file line-one)) (not (flymake-ler-get-file line-two))))))) 973 (and (not (flymake-ler-file line-one)) (not (flymake-ler-file line-two)))))))
993 974
994(defun flymake-add-line-err-info (line-err-info-list line-err-info) 975(defun flymake-add-line-err-info (line-err-info-list line-err-info)
995 "Update LINE-ERR-INFO-LIST with the error LINE-ERR-INFO. 976 "Update LINE-ERR-INFO-LIST with the error LINE-ERR-INFO.
@@ -1012,7 +993,7 @@ The updated value of LINE-ERR-INFO-LIST is returned."
1012Returns the updated value of ERR-INFO-LIST. 993Returns the updated value of ERR-INFO-LIST.
1013For the format of ERR-INFO-LIST, see `flymake-err-info'. 994For the format of ERR-INFO-LIST, see `flymake-err-info'.
1014For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." 995For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1015 (let* ((line-no (if (flymake-ler-get-file line-err-info) 1 (flymake-ler-get-line line-err-info))) 996 (let* ((line-no (if (flymake-ler-file line-err-info) 1 (flymake-ler-line line-err-info)))
1016 (info-and-pos (flymake-find-err-info err-info-list line-no)) 997 (info-and-pos (flymake-find-err-info err-info-list line-no))
1017 (exists (car info-and-pos)) 998 (exists (car info-and-pos))
1018 (pos (nth 1 info-and-pos)) 999 (pos (nth 1 info-and-pos))
@@ -1048,7 +1029,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1048 (inc-count (length inc-lines))) 1029 (inc-count (length inc-lines)))
1049 (while (> inc-count 0) 1030 (while (> inc-count 0)
1050 (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines))) 1031 (when (not (string-match "^INCLUDE_DIRS=.*" (nth (1- inc-count) inc-lines)))
1051 (setq inc-dirs (cons (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))) 1032 (push (flymake-replace-regexp-in-string "\"" "" (nth (1- inc-count) inc-lines)) inc-dirs))
1052 (setq inc-count (1- inc-count))))) 1033 (setq inc-count (1- inc-count)))))
1053 (flymake-add-project-include-dirs-to-cache basedir inc-dirs) 1034 (flymake-add-project-include-dirs-to-cache basedir inc-dirs)
1054 inc-dirs))) 1035 inc-dirs)))
@@ -1202,11 +1183,12 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1202 1183
1203(defun flymake-on-timer-event (buffer) 1184(defun flymake-on-timer-event (buffer)
1204 "Start a syntax check for buffer BUFFER if necessary." 1185 "Start a syntax check for buffer BUFFER if necessary."
1205 (when (bufferp buffer) 1186 (when (buffer-live-p buffer)
1206 (with-current-buffer buffer 1187 (with-current-buffer buffer
1207 (when (and (not flymake-is-running) 1188 (when (and (not flymake-is-running)
1208 flymake-last-change-time 1189 flymake-last-change-time
1209 (> (flymake-float-time) (+ flymake-no-changes-timeout flymake-last-change-time))) 1190 (> (- (flymake-float-time) flymake-last-change-time)
1191 flymake-no-changes-timeout))
1210 1192
1211 (setq flymake-last-change-time nil) 1193 (setq flymake-last-change-time nil)
1212 (flymake-log 3 "starting syntax check as more than 1 second passed since last change") 1194 (flymake-log 3 "starting syntax check as more than 1 second passed since last change")
@@ -1214,10 +1196,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1214 1196
1215(defun flymake-current-line-no () 1197(defun flymake-current-line-no ()
1216 "Return number of current line in current buffer." 1198 "Return number of current line in current buffer."
1217 (interactive) 1199 (count-lines (point-min) (if (eobp) (point) (1+ (point)))))
1218 (let ((beg (point-min))
1219 (end (if (= (point) (point-max)) (point) (1+ (point)))))
1220 (count-lines beg end)))
1221 1200
1222(defun flymake-count-lines () 1201(defun flymake-count-lines ()
1223 "Return number of lines in buffer BUFFER." 1202 "Return number of lines in buffer BUFFER."
@@ -1245,10 +1224,10 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1245 (let* ((count (length line-err-info-list)) 1224 (let* ((count (length line-err-info-list))
1246 (menu-item-text nil)) 1225 (menu-item-text nil))
1247 (while (> count 0) 1226 (while (> count 0)
1248 (setq menu-item-text (flymake-ler-get-text (nth (1- count) line-err-info-list))) 1227 (setq menu-item-text (flymake-ler-text (nth (1- count) line-err-info-list)))
1249 (let* ((file (flymake-ler-get-file (nth (1- count) line-err-info-list))) 1228 (let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
1250 (full-file (flymake-ler-get-full-file (nth (1- count) line-err-info-list))) 1229 (full-file (flymake-ler-full-file (nth (1- count) line-err-info-list)))
1251 (line (flymake-ler-get-line (nth (1- count) line-err-info-list)))) 1230 (line (flymake-ler-line (nth (1- count) line-err-info-list))))
1252 (if file 1231 (if file
1253 (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")"))) 1232 (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")")))
1254 (setq menu-items (cons (list menu-item-text 1233 (setq menu-items (cons (list menu-item-text
@@ -1503,8 +1482,7 @@ With arg, turn Flymake mode on if and only if arg is positive."
1503(defun flymake-delete-temp-directory (dir-name) 1482(defun flymake-delete-temp-directory (dir-name)
1504 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error." 1483 "Attempt to delete temp dir created by `flymake-create-temp-with-folder-structure', do not fail on error."
1505 (let* ((temp-dir (flymake-get-temp-dir)) 1484 (let* ((temp-dir (flymake-get-temp-dir))
1506 (suffix (substring dir-name (1+ (length temp-dir)))) 1485 (suffix (substring dir-name (1+ (length temp-dir)))))
1507 (slash-pos nil))
1508 1486
1509 (while (> (length suffix) 0) 1487 (while (> (length suffix) 0)
1510 (setq suffix (directory-file-name suffix)) 1488 (setq suffix (directory-file-name suffix))
@@ -1615,14 +1593,14 @@ Return full-name. Names are real, not patched."
1615 "NOMK" (format "No buildfile (%s) found for %s" 1593 "NOMK" (format "No buildfile (%s) found for %s"
1616 buildfile-name source-file-name))))) 1594 buildfile-name source-file-name)))))
1617 1595
1618(defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp-list) 1596(defun flymake-init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp)
1619 "Find master file (or buffer), create it's copy along with a copy of the source file." 1597 "Find master file (or buffer), create it's copy along with a copy of the source file."
1620 (let* ((source-file-name buffer-file-name) 1598 (let* ((source-file-name buffer-file-name)
1621 (temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)) 1599 (temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f))
1622 (master-and-temp-master (flymake-create-master-file 1600 (master-and-temp-master (flymake-create-master-file
1623 source-file-name temp-source-file-name 1601 source-file-name temp-source-file-name
1624 get-incl-dirs-f create-temp-f 1602 get-incl-dirs-f create-temp-f
1625 master-file-masks include-regexp-list))) 1603 master-file-masks include-regexp)))
1626 1604
1627 (if (not master-and-temp-master) 1605 (if (not master-and-temp-master)
1628 (progn 1606 (progn
@@ -1680,12 +1658,12 @@ Use CREATE-TEMP-F for creating temp copy."
1680(defun flymake-simple-make-init () 1658(defun flymake-simple-make-init ()
1681 (flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline)) 1659 (flymake-simple-make-init-impl 'flymake-create-temp-inplace t t "Makefile" 'flymake-get-make-cmdline))
1682 1660
1683(defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp-list) 1661(defun flymake-master-make-init (get-incl-dirs-f master-file-masks include-regexp)
1684 "Create make command line for a source file checked via master file compilation." 1662 "Create make command line for a source file checked via master file compilation."
1685 (let* ((make-args nil) 1663 (let* ((make-args nil)
1686 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy 1664 (temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1687 get-incl-dirs-f 'flymake-create-temp-inplace 1665 get-incl-dirs-f 'flymake-create-temp-inplace
1688 master-file-masks include-regexp-list))) 1666 master-file-masks include-regexp)))
1689 (when temp-master-file-name 1667 (when temp-master-file-name
1690 (let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile"))) 1668 (let* ((buildfile-dir (flymake-init-find-buildfile-dir temp-master-file-name "Makefile")))
1691 (if buildfile-dir 1669 (if buildfile-dir
@@ -1700,7 +1678,7 @@ Use CREATE-TEMP-F for creating temp copy."
1700(defun flymake-master-make-header-init () 1678(defun flymake-master-make-header-init ()
1701 (flymake-master-make-init 'flymake-get-include-dirs 1679 (flymake-master-make-init 'flymake-get-include-dirs
1702 '("\\.cpp\\'" "\\.c\\'") 1680 '("\\.cpp\\'" "\\.c\\'")
1703 '("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))) 1681 "[ \t]*#[ \t]*include[ \t]*\"\\([[:word:]0-9/\\_.]*%s\\)\""))
1704 1682
1705;;;; .java/make specific 1683;;;; .java/make specific
1706(defun flymake-simple-make-java-init () 1684(defun flymake-simple-make-java-init ()
@@ -1737,7 +1715,7 @@ Use CREATE-TEMP-F for creating temp copy."
1737 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy 1715 (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy
1738 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace 1716 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace
1739 '("\\.tex\\'") 1717 '("\\.tex\\'")
1740 '("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2)))) 1718 "[ \t]*\\input[ \t]*{\\(.*%s\\)}")))
1741 (when temp-master-file-name 1719 (when temp-master-file-name
1742 (flymake-get-tex-args temp-master-file-name)))) 1720 (flymake-get-tex-args temp-master-file-name))))
1743 1721