emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102548: Small flymake changes.


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102548: Small flymake changes.
Date: Thu, 02 Dec 2010 09:34:35 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102548
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Thu 2010-12-02 09:34:35 -0800
message:
  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.
modified:
  lisp/ChangeLog
  lisp/progmodes/flymake.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-11-30 17:57:48 +0000
+++ b/lisp/ChangeLog    2010-12-02 17:34:35 +0000
@@ -1,3 +1,11 @@
+2010-12-02  Glenn Morris  <address@hidden>
+
+       * 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.
+
 2010-11-30  Sam Steingold  <address@hidden>
 
        * nxml/nxml-mode.el (nxml-parent-document): Add a variable.

=== modified file 'lisp/progmodes/flymake.el'
--- a/lisp/progmodes/flymake.el 2010-11-07 02:02:54 +0000
+++ b/lisp/progmodes/flymake.el 2010-12-02 17:34:35 +0000
@@ -413,9 +413,11 @@
        (not (equal file-one file-two))))
 
 (defcustom flymake-check-file-limit 8192
-  "Max number of chars to look at when checking possible master file."
+  "Maximum number of chars to look at when checking possible master file.
+Nil means search the entire file."
   :group 'flymake
-  :type 'integer)
+  :type '(choice (const :tag "No limit" nil)
+                 (integer :tag "Characters")))
 
 (defun flymake-check-patch-master-file-buffer
        (master-file-temp-buffer
@@ -431,16 +433,26 @@
 Whether a buffer for MATER-FILE-NAME exists, use it as a source
 instead of reading master file from disk."
   (let* ((source-file-nondir (file-name-nondirectory source-file-name))
+         (source-file-extension (file-name-extension source-file-nondir))
+         (source-file-nonext (file-name-sans-extension source-file-nondir))
          (found                     nil)
         (inc-name                  nil)
         (search-limit              flymake-check-file-limit))
     (setq regexp
           (format regexp       ; "[ \t]*#[ \t]*include[ \t]*\"\\(.*%s\\)\""
-                  (regexp-quote source-file-nondir)))
+                  ;; Hack for tex files, where \include often excludes .tex.
+                  ;; Maybe this is safe generally.
+                  (if (and (> (length source-file-extension) 1)
+                           (string-equal source-file-extension "tex"))
+                      (format "%s\\(?:\\.%s\\)?"
+                              (regexp-quote source-file-nonext)
+                              (regexp-quote source-file-extension))
+                    (regexp-quote source-file-nondir))))
     (unwind-protect
         (with-current-buffer master-file-temp-buffer
-          (when (> search-limit (point-max))
-            (setq search-limit (point-max)))
+          (if (or (not search-limit)
+                  (> search-limit (point-max)))
+              (setq search-limit (point-max)))
           (flymake-log 3 "checking %s against regexp %s"
                        master-file-name regexp)
           (goto-char (point-min))
@@ -451,6 +463,11 @@
 
               (flymake-log 3 "found possible match for %s" source-file-nondir)
               (setq inc-name (match-string 1))
+              (and (> (length source-file-extension) 1)
+                   (string-equal source-file-extension "tex")
+                   (not (string-match (format "\\.%s\\'" source-file-extension)
+                                      inc-name))
+                   (setq inc-name (concat inc-name "." source-file-extension)))
               (when (eq t (compare-strings
                            source-file-nondir nil nil
                            inc-name (- (length inc-name)
@@ -1737,11 +1754,14 @@
 (defun flymake-simple-tex-init ()
   (flymake-get-tex-args (flymake-init-create-temp-buffer-copy 
'flymake-create-temp-inplace)))
 
+;; Perhaps there should be a buffer-local variable flymake-master-file
+;; that people can set to override this stuff.  Could inherit from
+;; the similar AUCTeX variable.
 (defun flymake-master-tex-init ()
   (let* ((temp-master-file-name 
(flymake-init-create-temp-source-and-master-buffer-copy
                                  'flymake-get-include-dirs-dot 
'flymake-create-temp-inplace
                                 '("\\.tex\\'")
-                                "[ \t]*\\input[ \t]*{\\(.*%s\\)}")))
+                                "[ \t]*\\in\\(?:put\\|clude\\)[ 
\t]*{\\(.*%s\\)}")))
     (when temp-master-file-name
       (flymake-get-tex-args temp-master-file-name))))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]