aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeiffer2005-05-17 20:45:26 +0000
committerDaniel Pfeiffer2005-05-17 20:45:26 +0000
commit0b11ce59ee4b7635e207466badfcbff97da80848 (patch)
treeab0760a943bad9c8981c6b72b2e805a913815cf8
parent0451361cf9ffebdf5d859be7b818aa2db8224cea (diff)
downloademacs-0b11ce59ee4b7635e207466badfcbff97da80848.tar.gz
emacs-0b11ce59ee4b7635e207466badfcbff97da80848.zip
(makefile-dependency-skip): New variable.
(makefile-previous-dependency): Inline the new matcher, because it is too complex to work in both directions. (makefile-match-dependency): Eliminate `backward' arg (see above). Completely reimplemented so as to not sometimes go into an endless loop. It should also be more efficient, because first it only searches for `:', instead of applying the very complex regexp.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/progmodes/make-mode.el41
2 files changed, 40 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2cbb9196005..e9b5ddc832d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12005-05-17 Daniel Pfeiffer <occitan@esperanto.org>
2
3 * progmodes/make-mode.el (makefile-dependency-skip): New variable.
4 (makefile-previous-dependency): Inline the new matcher, because it
5 is too complex to work in both directions.
6 (makefile-match-dependency): Eliminate `backward' arg (see above).
7 Completely reimplemented so as to not sometimes go into an endless
8 loop. It should also be more efficient, because first it only
9 searches for `:', instead of applying the very complex regexp.
10
12005-05-17 Reiner Steib <Reiner.Steib@gmx.de> 112005-05-17 Reiner Steib <Reiner.Steib@gmx.de>
2 12
3 * dired.el (dired-mode): Simplify. 13 * dired.el (dired-mode): Simplify.
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index 8467310d1da..399f5376d58 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -262,6 +262,9 @@ not be enclosed in { } or ( )."
262 "^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)" 262 "^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)"
263 "Regex used to find dependency lines in a makefile.") 263 "Regex used to find dependency lines in a makefile.")
264 264
265(defvar makefile-dependency-skip "^:"
266 "Characters to skip to find a line that might be a dependency.")
267
265(defvar makefile-rule-action-regex 268(defvar makefile-rule-action-regex
266 "^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)" 269 "^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)"
267 "Regex used to highlight rule action lines in font lock mode.") 270 "Regex used to highlight rule action lines in font lock mode.")
@@ -857,6 +860,7 @@ Makefile mode can be configured by modifying the following variables:
857 (set (make-local-variable 'makefile-dependency-regex) 860 (set (make-local-variable 'makefile-dependency-regex)
858 ;; Identical to default, except allows `!' instead of `:'. 861 ;; Identical to default, except allows `!' instead of `:'.
859 "^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\([:!]\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)") 862 "^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\([:!]\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)")
863 (set (make-local-variable 'makefile-dependency-skip) "^:!")
860 (set (make-local-variable 'makefile-rule-action-regex) 864 (set (make-local-variable 'makefile-rule-action-regex)
861 "^\t[ \t]*\\([-+@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)") 865 "^\t[ \t]*\\([-+@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)")
862 (setq font-lock-defaults 866 (setq font-lock-defaults
@@ -874,18 +878,26 @@ Makefile mode can be configured by modifying the following variables:
874 (interactive) 878 (interactive)
875 (let ((here (point))) 879 (let ((here (point)))
876 (end-of-line) 880 (end-of-line)
877 (if (makefile-match-dependency (point-max)) 881 (if (makefile-match-dependency nil)
878 (progn (beginning-of-line) t) ; indicate success 882 (progn (beginning-of-line) t) ; indicate success
879 (goto-char here) nil))) 883 (goto-char here) nil)))
880 884
881(defun makefile-previous-dependency () 885(defun makefile-previous-dependency ()
882 "Move point to the beginning of the previous dependency line." 886 "Move point to the beginning of the previous dependency line."
883 (interactive) 887 (interactive)
884 (let ((here (point))) 888 (let ((pt (point)))
885 (beginning-of-line) 889 (beginning-of-line)
886 (if (makefile-match-dependency (point-min) t) 890 ;; makefile-match-dependency done backwards:
887 (progn (beginning-of-line) t) ; indicate success 891 (catch 'found
888 (goto-char here) nil))) 892 (while (and (< (skip-chars-backward makefile-dependency-skip) 0)
893 (not (bobp)))
894 (backward-char)
895 (or (get-text-property (point) 'face)
896 (beginning-of-line)
897 (if (looking-at makefile-dependency-regex)
898 (throw 'found t))))
899 (goto-char pt)
900 nil)))
889 901
890 902
891 903
@@ -1683,16 +1695,23 @@ The anchor must have matched the opening parens in the first group."
1683 ((string= s "{{") "\\(.*?\\)[ \t]*}}"))) 1695 ((string= s "{{") "\\(.*?\\)[ \t]*}}")))
1684 (if s (looking-at s)))) 1696 (if s (looking-at s))))
1685 1697
1686(defun makefile-match-dependency (bound &optional backward) 1698(defun makefile-match-dependency (bound)
1687 "Search for `makefile-dependency-regex' up to BOUND. 1699 "Search for `makefile-dependency-regex' up to BOUND.
1688Optionally search BACKWARD.
1689Checks that the colon has not already been fontified, else we 1700Checks that the colon has not already been fontified, else we
1690matched in a rule action." 1701matched in a rule action."
1691 (catch 'found 1702 (catch 'found
1692 (while (funcall (if backward 're-search-backward 're-search-forward) 1703 (let ((pt (point)))
1693 makefile-dependency-regex bound t) 1704 (while (and (> (skip-chars-forward makefile-dependency-skip bound) 0)
1694 (or (get-text-property (match-beginning 2) 'face) 1705 (not (eobp)))
1695 (throw 'found t))))) 1706 (forward-char)
1707 (or (get-text-property (1- (point)) 'face)
1708 (when (save-excursion
1709 (beginning-of-line)
1710 (looking-at makefile-dependency-regex))
1711 (end-of-line)
1712 (throw 'found (point)))))
1713 (goto-char pt))
1714 nil))
1696 1715
1697(defun makefile-match-action (bound) 1716(defun makefile-match-action (bound)
1698 (catch 'found 1717 (catch 'found