diff options
| author | Glenn Morris | 2010-12-02 09:34:35 -0800 |
|---|---|---|
| committer | Glenn Morris | 2010-12-02 09:34:35 -0800 |
| commit | bd77c2effa8ad5a557200b932a23244624dc524b (patch) | |
| tree | ec55ebf53a41bd32de67b2bbd843e618d706d750 | |
| parent | dd723bbd427e7c399de316fe48f1514fa8b0bf29 (diff) | |
| download | emacs-bd77c2effa8ad5a557200b932a23244624dc524b.tar.gz emacs-bd77c2effa8ad5a557200b932a23244624dc524b.zip | |
Small flymake changes.
* lisp/progmodes/flymake.el (flymake-check-file-limit):
Allow nil to mean "no limit".
(flymake-check-patch-master-file-buffer): Update for above change.
Allow a .tex file-name extension to be optional.
(flymake-master-tex-init): Also match \include statements.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 32 |
2 files changed, 34 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4795e0eda58..135cfe952c7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-12-02 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/flymake.el (flymake-check-file-limit): | ||
| 4 | Allow nil to mean "no limit". | ||
| 5 | (flymake-check-patch-master-file-buffer): Update for above change. | ||
| 6 | Allow a .tex file-name extension to be optional. | ||
| 7 | (flymake-master-tex-init): Also match \include statements. | ||
| 8 | |||
| 1 | 2010-11-30 Sam Steingold <sds@gnu.org> | 9 | 2010-11-30 Sam Steingold <sds@gnu.org> |
| 2 | 10 | ||
| 3 | * nxml/nxml-mode.el (nxml-parent-document): Add a variable. | 11 | * nxml/nxml-mode.el (nxml-parent-document): Add a variable. |
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 6346ab50e96..a90f380d1c3 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -413,9 +413,11 @@ to the beginning of the list (File.h -> File.cpp moved to top)." | |||
| 413 | (not (equal file-one file-two)))) | 413 | (not (equal file-one file-two)))) |
| 414 | 414 | ||
| 415 | (defcustom flymake-check-file-limit 8192 | 415 | (defcustom flymake-check-file-limit 8192 |
| 416 | "Max number of chars to look at when checking possible master file." | 416 | "Maximum number of chars to look at when checking possible master file. |
| 417 | Nil means search the entire file." | ||
| 417 | :group 'flymake | 418 | :group 'flymake |
| 418 | :type 'integer) | 419 | :type '(choice (const :tag "No limit" nil) |
| 420 | (integer :tag "Characters"))) | ||
| 419 | 421 | ||
| 420 | (defun flymake-check-patch-master-file-buffer | 422 | (defun flymake-check-patch-master-file-buffer |
| 421 | (master-file-temp-buffer | 423 | (master-file-temp-buffer |
| @@ -431,16 +433,26 @@ For example, foo.cpp is a master file if it includes foo.h. | |||
| 431 | Whether a buffer for MATER-FILE-NAME exists, use it as a source | 433 | Whether a buffer for MATER-FILE-NAME exists, use it as a source |
| 432 | instead of reading master file from disk." | 434 | instead of reading master file from disk." |
| 433 | (let* ((source-file-nondir (file-name-nondirectory source-file-name)) | 435 | (let* ((source-file-nondir (file-name-nondirectory source-file-name)) |
| 436 | (source-file-extension (file-name-extension source-file-nondir)) | ||
| 437 | (source-file-nonext (file-name-sans-extension source-file-nondir)) | ||
| 434 | (found nil) | 438 | (found nil) |
| 435 | (inc-name nil) | 439 | (inc-name nil) |
| 436 | (search-limit flymake-check-file-limit)) | 440 | (search-limit flymake-check-file-limit)) |
| 437 | (setq regexp | 441 | (setq regexp |
| 438 | (format regexp ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\"" | 442 | (format regexp ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\"" |
| 439 | (regexp-quote source-file-nondir))) | 443 | ;; Hack for tex files, where \include often excludes .tex. |
| 444 | ;; Maybe this is safe generally. | ||
| 445 | (if (and (> (length source-file-extension) 1) | ||
| 446 | (string-equal source-file-extension "tex")) | ||
| 447 | (format "%s\\(?:\\.%s\\)?" | ||
| 448 | (regexp-quote source-file-nonext) | ||
| 449 | (regexp-quote source-file-extension)) | ||
| 450 | (regexp-quote source-file-nondir)))) | ||
| 440 | (unwind-protect | 451 | (unwind-protect |
| 441 | (with-current-buffer master-file-temp-buffer | 452 | (with-current-buffer master-file-temp-buffer |
| 442 | (when (> search-limit (point-max)) | 453 | (if (or (not search-limit) |
| 443 | (setq search-limit (point-max))) | 454 | (> search-limit (point-max))) |
| 455 | (setq search-limit (point-max))) | ||
| 444 | (flymake-log 3 "checking %s against regexp %s" | 456 | (flymake-log 3 "checking %s against regexp %s" |
| 445 | master-file-name regexp) | 457 | master-file-name regexp) |
| 446 | (goto-char (point-min)) | 458 | (goto-char (point-min)) |
| @@ -451,6 +463,11 @@ instead of reading master file from disk." | |||
| 451 | 463 | ||
| 452 | (flymake-log 3 "found possible match for %s" source-file-nondir) | 464 | (flymake-log 3 "found possible match for %s" source-file-nondir) |
| 453 | (setq inc-name (match-string 1)) | 465 | (setq inc-name (match-string 1)) |
| 466 | (and (> (length source-file-extension) 1) | ||
| 467 | (string-equal source-file-extension "tex") | ||
| 468 | (not (string-match (format "\\.%s\\'" source-file-extension) | ||
| 469 | inc-name)) | ||
| 470 | (setq inc-name (concat inc-name "." source-file-extension))) | ||
| 454 | (when (eq t (compare-strings | 471 | (when (eq t (compare-strings |
| 455 | source-file-nondir nil nil | 472 | source-file-nondir nil nil |
| 456 | inc-name (- (length inc-name) | 473 | inc-name (- (length inc-name) |
| @@ -1737,11 +1754,14 @@ Use CREATE-TEMP-F for creating temp copy." | |||
| 1737 | (defun flymake-simple-tex-init () | 1754 | (defun flymake-simple-tex-init () |
| 1738 | (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))) | 1755 | (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))) |
| 1739 | 1756 | ||
| 1757 | ;; Perhaps there should be a buffer-local variable flymake-master-file | ||
| 1758 | ;; that people can set to override this stuff. Could inherit from | ||
| 1759 | ;; the similar AUCTeX variable. | ||
| 1740 | (defun flymake-master-tex-init () | 1760 | (defun flymake-master-tex-init () |
| 1741 | (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy | 1761 | (let* ((temp-master-file-name (flymake-init-create-temp-source-and-master-buffer-copy |
| 1742 | 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace | 1762 | 'flymake-get-include-dirs-dot 'flymake-create-temp-inplace |
| 1743 | '("\\.tex\\'") | 1763 | '("\\.tex\\'") |
| 1744 | "[ \t]*\\input[ \t]*{\\(.*%s\\)}"))) | 1764 | "[ \t]*\\in\\(?:put\\|clude\\)[ \t]*{\\(.*%s\\)}"))) |
| 1745 | (when temp-master-file-name | 1765 | (when temp-master-file-name |
| 1746 | (flymake-get-tex-args temp-master-file-name)))) | 1766 | (flymake-get-tex-args temp-master-file-name)))) |
| 1747 | 1767 | ||