262 |
"^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)" |
"^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)" |
263 |
"Regex used to find dependency lines in a makefile.") |
"Regex used to find dependency lines in a makefile.") |
264 |
|
|
265 |
|
(defvar makefile-dependency-skip "^:" |
266 |
|
"Characters to skip to find a line that might be a dependency.") |
267 |
|
|
268 |
(defvar makefile-rule-action-regex |
(defvar makefile-rule-action-regex |
269 |
"^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)" |
"^\t[ \t]*\\([-@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)" |
270 |
"Regex used to highlight rule action lines in font lock mode.") |
"Regex used to highlight rule action lines in font lock mode.") |
860 |
(set (make-local-variable 'makefile-dependency-regex) |
(set (make-local-variable 'makefile-dependency-regex) |
861 |
;; Identical to default, except allows `!' instead of `:'. |
;; Identical to default, except allows `!' instead of `:'. |
862 |
"^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\([:!]\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)") |
"^ *\\(\\(?: *\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\| *[^ \n$#:=]+\\)+?\\)[ \t]*\\([:!]\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(.+\\)\\)?\\)") |
863 |
|
(set (make-local-variable 'makefile-dependency-skip) "^:!") |
864 |
(set (make-local-variable 'makefile-rule-action-regex) |
(set (make-local-variable 'makefile-rule-action-regex) |
865 |
"^\t[ \t]*\\([-+@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)") |
"^\t[ \t]*\\([-+@]*\\)[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)") |
866 |
(setq font-lock-defaults |
(setq font-lock-defaults |
878 |
(interactive) |
(interactive) |
879 |
(let ((here (point))) |
(let ((here (point))) |
880 |
(end-of-line) |
(end-of-line) |
881 |
(if (makefile-match-dependency (point-max)) |
(if (makefile-match-dependency nil) |
882 |
(progn (beginning-of-line) t) ; indicate success |
(progn (beginning-of-line) t) ; indicate success |
883 |
(goto-char here) nil))) |
(goto-char here) nil))) |
884 |
|
|
885 |
(defun makefile-previous-dependency () |
(defun makefile-previous-dependency () |
886 |
"Move point to the beginning of the previous dependency line." |
"Move point to the beginning of the previous dependency line." |
887 |
(interactive) |
(interactive) |
888 |
(let ((here (point))) |
(let ((pt (point))) |
889 |
(beginning-of-line) |
(beginning-of-line) |
890 |
(if (makefile-match-dependency (point-min) t) |
;; makefile-match-dependency done backwards: |
891 |
(progn (beginning-of-line) t) ; indicate success |
(catch 'found |
892 |
(goto-char here) nil))) |
(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))) |
901 |
|
|
902 |
|
|
903 |
|
|
1695 |
((string= s "{{") "\\(.*?\\)[ \t]*}}"))) |
((string= s "{{") "\\(.*?\\)[ \t]*}}"))) |
1696 |
(if s (looking-at s)))) |
(if s (looking-at s)))) |
1697 |
|
|
1698 |
(defun makefile-match-dependency (bound &optional backward) |
(defun makefile-match-dependency (bound) |
1699 |
"Search for `makefile-dependency-regex' up to BOUND. |
"Search for `makefile-dependency-regex' up to BOUND. |
|
Optionally search BACKWARD. |
|
1700 |
Checks that the colon has not already been fontified, else we |
Checks that the colon has not already been fontified, else we |
1701 |
matched in a rule action." |
matched in a rule action." |
1702 |
(catch 'found |
(catch 'found |
1703 |
(while (funcall (if backward 're-search-backward 're-search-forward) |
(let ((pt (point))) |
1704 |
makefile-dependency-regex bound t) |
(while (and (> (skip-chars-forward makefile-dependency-skip bound) 0) |
1705 |
(or (get-text-property (match-beginning 2) 'face) |
(not (eobp))) |
1706 |
(throw 'found t))))) |
(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)) |
1715 |
|
|
1716 |
(defun makefile-match-action (bound) |
(defun makefile-match-action (bound) |
1717 |
(catch 'found |
(catch 'found |