diff options
| author | Richard M. Stallman | 1994-03-02 07:57:04 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-02 07:57:04 +0000 |
| commit | b8ca7cc378582397657c3a825131612d4eb2e80f (patch) | |
| tree | 5aa1a4229ede142e0fa37f3a10c58efba4e6377e | |
| parent | da41135a678cea39bd3ef9797b9f989ed5c0f650 (diff) | |
| download | emacs-b8ca7cc378582397657c3a825131612d4eb2e80f.tar.gz emacs-b8ca7cc378582397657c3a825131612d4eb2e80f.zip | |
(makefile-mode): Set local-write-file-hooks, not write-file-hooks.
Version 1.16.
(makefile-mode): Correct `make-variable-buffer-local' to
`make-local-variable'. Set indent-tabs-mode to t.
(makefile-insert-macro-ref): Do not append a space
to the inserted macro reference.
(makefile-insert-macro-ref): Likewise if the reference is to
one of makefile-runtime-macros-list.
(makefile-format-macro-ref): If the name of the macro ref
starts with a '(' or '{' then the enclosing parentheses are not added.
(makefile-warn-suspicious-lines): New function.
Changed mode name to "Makefile" instead of "makefile".
| -rw-r--r-- | lisp/progmodes/make-mode.el | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el index d7b53e62608..042ca570ac1 100644 --- a/lisp/progmodes/make-mode.el +++ b/lisp/progmodes/make-mode.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; makefile.el --- makefile editing commands for Emacs | 1 | ;;; makefile.el --- makefile editing commands for Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Thomas Neumann <tom@smart.bo.open.de> | 5 | ;; Author: Thomas Neumann <tom@smart.bo.open.de> |
| 6 | ;; Eric S. Raymond <esr@snark.thyrsus.com> | 6 | ;; Eric S. Raymond <esr@snark.thyrsus.com> |
| @@ -14,11 +14,10 @@ | |||
| 14 | ;; via M-TAB completion, not by preempting insertion of references. | 14 | ;; via M-TAB completion, not by preempting insertion of references. |
| 15 | ;; Also, the doc strings need fixing: the first line doesn't stand alone, | 15 | ;; Also, the doc strings need fixing: the first line doesn't stand alone, |
| 16 | ;; and other usage is not high quality. Symbol names don't have `...'. | 16 | ;; and other usage is not high quality. Symbol names don't have `...'. |
| 17 | ;; The Mode names is written as makefile-mode instead of Makefile mode. | ||
| 18 | 17 | ||
| 19 | ;; So, for the meantime, this is not the default mode for makefiles. | 18 | ;; So, for the meantime, this is not the default mode for makefiles. |
| 20 | 19 | ||
| 21 | ;; $Id: makefile.el,v 1.11 1994/01/06 09:59:12 rms Exp rms $ | 20 | ;; $Id: makefile.el,v 1.16 1994/02/28 18:05:55 tom Exp $ |
| 22 | 21 | ||
| 23 | ;; This file is part of GNU Emacs. | 22 | ;; This file is part of GNU Emacs. |
| 24 | 23 | ||
| @@ -74,7 +73,7 @@ | |||
| 74 | ;;; Configurable stuff | 73 | ;;; Configurable stuff |
| 75 | ;;; ------------------------------------------------------------ | 74 | ;;; ------------------------------------------------------------ |
| 76 | 75 | ||
| 77 | (defconst makefile-mode-name "makefile" | 76 | (defconst makefile-mode-name "Makefile" |
| 78 | "The \"pretty name\" of makefile-mode, as it appears in the modeline.") | 77 | "The \"pretty name\" of makefile-mode, as it appears in the modeline.") |
| 79 | 78 | ||
| 80 | (defvar makefile-browser-buffer-name "*Macros and Targets*" | 79 | (defvar makefile-browser-buffer-name "*Macros and Targets*" |
| @@ -319,7 +318,7 @@ using makefile-pickup-macros.") | |||
| 319 | ("foreach" "Variable" "List" "Text") | 318 | ("foreach" "Variable" "List" "Text") |
| 320 | ("origin" "Variable") | 319 | ("origin" "Variable") |
| 321 | ("shell" "Command")) | 320 | ("shell" "Command")) |
| 322 | "A list of GNU make 3.62 function names associated with | 321 | "A list of GNU make function names associated with |
| 323 | the prompts for each function. | 322 | the prompts for each function. |
| 324 | This is used in the function makefile-insert-gmake-function .") | 323 | This is used in the function makefile-insert-gmake-function .") |
| 325 | 324 | ||
| @@ -410,14 +409,14 @@ makefile-special-targets-list: | |||
| 410 | at the beginning of a line in makefile-mode." | 409 | at the beginning of a line in makefile-mode." |
| 411 | (interactive) | 410 | (interactive) |
| 412 | (kill-all-local-variables) | 411 | (kill-all-local-variables) |
| 413 | (if (not (memq 'makefile-cleanup-continuations write-file-hooks)) | 412 | (make-local-file 'local-write-file-hooks) |
| 414 | (setq write-file-hooks | 413 | (setq local-write-file-hooks |
| 415 | (append write-file-hooks (list 'makefile-cleanup-continuations)))) | 414 | '(makefile-cleanup-continuations 'makefile-warn-suspicious-lines)) |
| 416 | (make-variable-buffer-local 'makefile-target-table) | 415 | (make-local-variable 'makefile-target-table) |
| 417 | (make-variable-buffer-local 'makefile-macro-table) | 416 | (make-local-variable 'makefile-macro-table) |
| 418 | (make-variable-buffer-local 'makefile-has-prereqs) | 417 | (make-local-variable 'makefile-has-prereqs) |
| 419 | (make-variable-buffer-local 'makefile-need-target-pickup) | 418 | (make-local-variable 'makefile-need-target-pickup) |
| 420 | (make-variable-buffer-local 'makefile-need-macro-pickup) | 419 | (make-local-variable 'makefile-need-macro-pickup) |
| 421 | (make-local-variable 'comment-start) | 420 | (make-local-variable 'comment-start) |
| 422 | (make-local-variable 'comment-end) | 421 | (make-local-variable 'comment-end) |
| 423 | (make-local-variable 'comment-start-skip) | 422 | (make-local-variable 'comment-start-skip) |
| @@ -430,6 +429,7 @@ makefile-special-targets-list: | |||
| 430 | ;; activate keymap | 429 | ;; activate keymap |
| 431 | (use-local-map makefile-mode-map) | 430 | (use-local-map makefile-mode-map) |
| 432 | (set-syntax-table makefile-mode-syntax-table) | 431 | (set-syntax-table makefile-mode-syntax-table) |
| 432 | (setq indent-tabs-mode t) ;real TABs are important in makefiles | ||
| 433 | (run-hooks 'makefile-mode-hook)) | 433 | (run-hooks 'makefile-mode-hook)) |
| 434 | 434 | ||
| 435 | (defun makefile-next-dependency () | 435 | (defun makefile-next-dependency () |
| @@ -502,8 +502,8 @@ Anywhere else just insert a dot." | |||
| 502 | (completing-read "Refer to macro: " makefile-macro-table nil nil nil)))) | 502 | (completing-read "Refer to macro: " makefile-macro-table nil nil nil)))) |
| 503 | (if (not (zerop (length macro-name))) | 503 | (if (not (zerop (length macro-name))) |
| 504 | (if (assoc macro-name makefile-runtime-macros-list) | 504 | (if (assoc macro-name makefile-runtime-macros-list) |
| 505 | (insert (format "$%s " macro-name)) | 505 | (insert (format "$%s" macro-name)) |
| 506 | (insert (makefile-format-macro-ref macro-name) " ")))) | 506 | (insert (makefile-format-macro-ref macro-name))))) |
| 507 | 507 | ||
| 508 | (defun makefile-insert-target (target-name) | 508 | (defun makefile-insert-target (target-name) |
| 509 | "Prepare definition of a new target (dependency line)." | 509 | "Prepare definition of a new target (dependency line)." |
| @@ -924,6 +924,28 @@ and generates the overview, one line per target name." | |||
| 924 | (while (re-search-forward "\\\\[ \t]+$" (point-max) t) | 924 | (while (re-search-forward "\\\\[ \t]+$" (point-max) t) |
| 925 | (replace-match "\\" t t)))))) | 925 | (replace-match "\\" t t)))))) |
| 926 | 926 | ||
| 927 | |||
| 928 | ;;; ------------------------------------------------------------ | ||
| 929 | ;;; Warn of suspicious lines | ||
| 930 | ;;; ------------------------------------------------------------ | ||
| 931 | |||
| 932 | (defun makefile-warn-suspicious-lines () | ||
| 933 | (let ((dont-save nil)) | ||
| 934 | (if (eq major-mode 'makefile-mode) | ||
| 935 | (let ((suspicious | ||
| 936 | (save-excursion | ||
| 937 | (goto-char (point-min)) | ||
| 938 | (re-search-forward | ||
| 939 | "\\(^[\t]+$\\)\\|\\(^[ ]+[\t]\\)" (point-max) t)))) | ||
| 940 | (if suspicious | ||
| 941 | (let ((line-nr (count-lines (point-min) suspicious))) | ||
| 942 | (setq dont-save | ||
| 943 | (not (y-or-n-p | ||
| 944 | (format "Suspicious line %d. Save anyway " | ||
| 945 | line-nr)))))))) | ||
| 946 | dont-save)) | ||
| 947 | |||
| 948 | |||
| 927 | ;;; ------------------------------------------------------------ | 949 | ;;; ------------------------------------------------------------ |
| 928 | ;;; GNU make function support | 950 | ;;; GNU make function support |
| 929 | ;;; ------------------------------------------------------------ | 951 | ;;; ------------------------------------------------------------ |
| @@ -1016,9 +1038,12 @@ This accts according to the value of makefile-tab-after-target-colon ." | |||
| 1016 | (defun makefile-format-macro-ref (macro-name) | 1038 | (defun makefile-format-macro-ref (macro-name) |
| 1017 | "Format a macro reference according to the value of the | 1039 | "Format a macro reference according to the value of the |
| 1018 | configuration variable makefile-use-curly-braces-for-macros-p ." | 1040 | configuration variable makefile-use-curly-braces-for-macros-p ." |
| 1019 | (if makefile-use-curly-braces-for-macros-p | 1041 | (if (or (char-equal ?\( (string-to-char macro-name)) |
| 1020 | (format "${%s}" macro-name) | 1042 | (char-equal ?\{ (string-to-char macro-name))) |
| 1021 | (format "$(%s)" macro-name))) | 1043 | (format "$%s" macro-name) |
| 1044 | (if makefile-use-curly-braces-for-macros-p | ||
| 1045 | (format "${%s}" macro-name) | ||
| 1046 | (format "$(%s)" macro-name)))) | ||
| 1022 | 1047 | ||
| 1023 | (defun makefile-browser-get-state-for-line (n) | 1048 | (defun makefile-browser-get-state-for-line (n) |
| 1024 | (aref makefile-browser-selection-vector (1- n))) | 1049 | (aref makefile-browser-selection-vector (1- n))) |