diff options
| author | Stefan Monnier | 2002-09-19 01:21:46 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-09-19 01:21:46 +0000 |
| commit | e006b3cd93b56b93ec65e884a8c19efc7b3e0dbe (patch) | |
| tree | 6aaa0c2e1f6b3655cfb3df62076d57711158b1f1 /lisp | |
| parent | 8421685fdfa899a016d9878fdc2dca47cce337d4 (diff) | |
| download | emacs-e006b3cd93b56b93ec65e884a8c19efc7b3e0dbe.tar.gz emacs-e006b3cd93b56b93ec65e884a8c19efc7b3e0dbe.zip | |
(makefile-cleanup-continuations-p): Rename to makefile-cleanup-continuations.
(makefile-mode): Use write-file-functions.
(makefile-fill-paragraph): Use match-string-no-properties.
(makefile-fill-paragraph): Use line-end-position.
(makefile-add-log-defun): Simplify.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/make-mode.el | 73 |
1 files changed, 30 insertions, 43 deletions
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el index b2b8b5194e1..ad635c0c3e4 100644 --- a/lisp/progmodes/make-mode.el +++ b/lisp/progmodes/make-mode.el | |||
| @@ -192,7 +192,7 @@ Otherwise filenames are omitted." | |||
| 192 | :type 'boolean | 192 | :type 'boolean |
| 193 | :group 'makefile) | 193 | :group 'makefile) |
| 194 | 194 | ||
| 195 | (defcustom makefile-cleanup-continuations-p t | 195 | (defcustom makefile-cleanup-continuations t |
| 196 | "*If non-nil, automatically clean up continuation lines when saving. | 196 | "*If non-nil, automatically clean up continuation lines when saving. |
| 197 | A line is cleaned up by removing all whitespace following a trailing | 197 | A line is cleaned up by removing all whitespace following a trailing |
| 198 | backslash. This is done silently. | 198 | backslash. This is done silently. |
| @@ -545,7 +545,7 @@ Makefile mode can be configured by modifying the following variables: | |||
| 545 | (i.e. it calls `makefile-pickup-filenames-as-targets'), otherwise | 545 | (i.e. it calls `makefile-pickup-filenames-as-targets'), otherwise |
| 546 | filenames are omitted. | 546 | filenames are omitted. |
| 547 | 547 | ||
| 548 | `makefile-cleanup-continuations-p': | 548 | `makefile-cleanup-continuations': |
| 549 | If this variable is set to a non-nil value then Makefile mode | 549 | If this variable is set to a non-nil value then Makefile mode |
| 550 | will assure that no line in the file ends with a backslash | 550 | will assure that no line in the file ends with a backslash |
| 551 | (the continuation character) followed by any whitespace. | 551 | (the continuation character) followed by any whitespace. |
| @@ -565,9 +565,10 @@ Makefile mode can be configured by modifying the following variables: | |||
| 565 | 565 | ||
| 566 | (interactive) | 566 | (interactive) |
| 567 | (kill-all-local-variables) | 567 | (kill-all-local-variables) |
| 568 | (make-local-variable 'local-write-file-hooks) | 568 | (add-hook 'write-file-functions |
| 569 | (setq local-write-file-hooks | 569 | 'makefile-warn-suspicious-lines nil t) |
| 570 | '(makefile-cleanup-continuations makefile-warn-suspicious-lines)) | 570 | (add-hook 'write-file-functions |
| 571 | 'makefile-cleanup-continuations nil t) | ||
| 571 | (make-local-variable 'makefile-target-table) | 572 | (make-local-variable 'makefile-target-table) |
| 572 | (make-local-variable 'makefile-macro-table) | 573 | (make-local-variable 'makefile-macro-table) |
| 573 | (make-local-variable 'makefile-has-prereqs) | 574 | (make-local-variable 'makefile-has-prereqs) |
| @@ -749,7 +750,7 @@ Anywhere else just self-inserts." | |||
| 749 | (setq makefile-has-prereqs nil) | 750 | (setq makefile-has-prereqs nil) |
| 750 | (save-excursion | 751 | (save-excursion |
| 751 | (goto-char (point-min)) | 752 | (goto-char (point-min)) |
| 752 | (while (re-search-forward makefile-dependency-regex (point-max) t) | 753 | (while (re-search-forward makefile-dependency-regex nil t) |
| 753 | (makefile-add-this-line-targets))) | 754 | (makefile-add-this-line-targets))) |
| 754 | (message "Read targets OK."))) | 755 | (message "Read targets OK."))) |
| 755 | 756 | ||
| @@ -783,7 +784,7 @@ Anywhere else just self-inserts." | |||
| 783 | (setq makefile-macro-table nil) | 784 | (setq makefile-macro-table nil) |
| 784 | (save-excursion | 785 | (save-excursion |
| 785 | (goto-char (point-min)) | 786 | (goto-char (point-min)) |
| 786 | (while (re-search-forward makefile-macroassign-regex (point-max) t) | 787 | (while (re-search-forward makefile-macroassign-regex nil t) |
| 787 | (makefile-add-this-line-macro) | 788 | (makefile-add-this-line-macro) |
| 788 | (forward-line 1))) | 789 | (forward-line 1))) |
| 789 | (message "Read macros OK."))) | 790 | (message "Read macros OK."))) |
| @@ -792,15 +793,15 @@ Anywhere else just self-inserts." | |||
| 792 | (save-excursion | 793 | (save-excursion |
| 793 | (beginning-of-line) | 794 | (beginning-of-line) |
| 794 | (skip-chars-forward " \t") | 795 | (skip-chars-forward " \t") |
| 795 | (if (not (eolp)) | 796 | (unless (eolp) |
| 796 | (let* ((start-of-macro-name (point)) | 797 | (let* ((start-of-macro-name (point)) |
| 797 | (line-number (1+ (count-lines (point-min) (point)))) | 798 | (line-number (1+ (count-lines (point-min) (point)))) |
| 798 | (macro-name (progn | 799 | (macro-name (progn |
| 799 | (skip-chars-forward "^ \t:#=*") | 800 | (skip-chars-forward "^ \t:#=*") |
| 800 | (buffer-substring start-of-macro-name (point))))) | 801 | (buffer-substring start-of-macro-name (point))))) |
| 801 | (if (makefile-remember-macro macro-name) | 802 | (if (makefile-remember-macro macro-name) |
| 802 | (message "Picked up macro \"%s\" from line %d" | 803 | (message "Picked up macro \"%s\" from line %d" |
| 803 | macro-name line-number)))))) | 804 | macro-name line-number)))))) |
| 804 | 805 | ||
| 805 | (defun makefile-pickup-everything (arg) | 806 | (defun makefile-pickup-everything (arg) |
| 806 | "Notice names of all macros and targets in Makefile. | 807 | "Notice names of all macros and targets in Makefile. |
| @@ -1014,8 +1015,7 @@ definition and conveniently use this command." | |||
| 1014 | ;; Found a comment. Set the fill prefix, and find the paragraph | 1015 | ;; Found a comment. Set the fill prefix, and find the paragraph |
| 1015 | ;; boundaries by searching for lines that look like comment-only | 1016 | ;; boundaries by searching for lines that look like comment-only |
| 1016 | ;; lines. | 1017 | ;; lines. |
| 1017 | (let ((fill-prefix (buffer-substring-no-properties (match-beginning 0) | 1018 | (let ((fill-prefix (match-string-no-properties 0)) |
| 1018 | (match-end 0))) | ||
| 1019 | (fill-paragraph-function nil)) | 1019 | (fill-paragraph-function nil)) |
| 1020 | (save-excursion | 1020 | (save-excursion |
| 1021 | (save-restriction | 1021 | (save-restriction |
| @@ -1038,13 +1038,8 @@ definition and conveniently use this command." | |||
| 1038 | 1038 | ||
| 1039 | ;; Must look for backslashed-region before looking for variable | 1039 | ;; Must look for backslashed-region before looking for variable |
| 1040 | ;; assignment. | 1040 | ;; assignment. |
| 1041 | ((save-excursion | 1041 | ((or (eq (char-before (line-end-position 1)) ?\\) |
| 1042 | (end-of-line) | 1042 | (eq (char-before (line-end-position 0)) ?\\)) |
| 1043 | (or | ||
| 1044 | (= (preceding-char) ?\\) | ||
| 1045 | (progn | ||
| 1046 | (end-of-line -1) | ||
| 1047 | (= (preceding-char) ?\\)))) | ||
| 1048 | ;; A backslash region. Find beginning and end, remove | 1043 | ;; A backslash region. Find beginning and end, remove |
| 1049 | ;; backslashes, fill, and then reapply backslahes. | 1044 | ;; backslashes, fill, and then reapply backslahes. |
| 1050 | (end-of-line) | 1045 | (end-of-line) |
| @@ -1370,11 +1365,11 @@ and generates the overview, one line per target name." | |||
| 1370 | 1365 | ||
| 1371 | (defun makefile-cleanup-continuations () | 1366 | (defun makefile-cleanup-continuations () |
| 1372 | (if (eq major-mode 'makefile-mode) | 1367 | (if (eq major-mode 'makefile-mode) |
| 1373 | (if (and makefile-cleanup-continuations-p | 1368 | (if (and makefile-cleanup-continuations |
| 1374 | (not buffer-read-only)) | 1369 | (not buffer-read-only)) |
| 1375 | (save-excursion | 1370 | (save-excursion |
| 1376 | (goto-char (point-min)) | 1371 | (goto-char (point-min)) |
| 1377 | (while (re-search-forward "\\\\[ \t]+$" (point-max) t) | 1372 | (while (re-search-forward "\\\\[ \t]+$" nil t) |
| 1378 | (replace-match "\\" t t)))))) | 1373 | (replace-match "\\" t t)))))) |
| 1379 | 1374 | ||
| 1380 | 1375 | ||
| @@ -1522,22 +1517,14 @@ If it isn't in one, return nil." | |||
| 1522 | ;; Scan back line by line, noticing when we come to a | 1517 | ;; Scan back line by line, noticing when we come to a |
| 1523 | ;; variable or rule definition, and giving up when we see | 1518 | ;; variable or rule definition, and giving up when we see |
| 1524 | ;; a line that is not part of either of those. | 1519 | ;; a line that is not part of either of those. |
| 1525 | (while (not found) | 1520 | (while (not (or (setq found |
| 1526 | (cond | 1521 | (when (or (looking-at makefile-macroassign-regex) |
| 1527 | ((looking-at makefile-macroassign-regex) | 1522 | (looking-at makefile-dependency-regex)) |
| 1528 | (setq found (buffer-substring-no-properties (match-beginning 1) | 1523 | (match-string-no-properties 1))) |
| 1529 | (match-end 1)))) | 1524 | ;; Don't keep looking across a blank line or comment. |
| 1530 | ((looking-at makefile-dependency-regex) | 1525 | (looking-at "$\\|#") |
| 1531 | (setq found (buffer-substring-no-properties (match-beginning 1) | 1526 | (not (zerop (forward-line -1)))))) |
| 1532 | (match-end 1)))) | 1527 | found))) |
| 1533 | ;; Don't keep looking across a blank line or comment. Give up. | ||
| 1534 | ((looking-at "$\\|#") | ||
| 1535 | (setq found 'bobp)) | ||
| 1536 | ((bobp) | ||
| 1537 | (setq found 'bobp))) | ||
| 1538 | (or found | ||
| 1539 | (forward-line -1))) | ||
| 1540 | (if (stringp found) found)))) | ||
| 1541 | 1528 | ||
| 1542 | (provide 'make-mode) | 1529 | (provide 'make-mode) |
| 1543 | 1530 | ||