aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/make-mode.el122
2 files changed, 56 insertions, 73 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3689508aa52..4e7b8905796 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12010-03-24 Stefan Monnier <monnier@iro.umontreal.ca> 12010-03-24 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 Misc cleanup.
4 * progmodes/make-mode.el (makefile-bsdmake-rule-action-regex):
5 Use replace-regexp-in-string.
6 (makefile-mode-abbrev-table): Merge defvar and define-abbrev-table.
7 (makefile-imake-mode-syntax-table): Move init into defvar.
8 (makefile-mode): Use define-derived-mode.
9
3 * progmodes/make-mode.el (makefile-rule-action-regex): Backtrack less. 10 * progmodes/make-mode.el (makefile-rule-action-regex): Backtrack less.
4 (makefile-make-font-lock-keywords): Adjust rule since submatch 1 may 11 (makefile-make-font-lock-keywords): Adjust rule since submatch 1 may
5 not be present any more. 12 not be present any more.
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index 594462d5125..7a1aa3e70f4 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -281,8 +281,7 @@ not be enclosed in { } or ( )."
281 "Regex used to highlight makepp rule action lines in font lock mode.") 281 "Regex used to highlight makepp rule action lines in font lock mode.")
282 282
283(defconst makefile-bsdmake-rule-action-regex 283(defconst makefile-bsdmake-rule-action-regex
284 (progn (string-match "-@" makefile-rule-action-regex) 284 (replace-regexp-in-string "-@" "-+@" makefile-rule-action-regex)
285 (replace-match "-+@" t t makefile-rule-action-regex))
286 "Regex used to highlight BSD rule action lines in font lock mode.") 285 "Regex used to highlight BSD rule action lines in font lock mode.")
287 286
288;; Note that the first and second subexpression is used by font lock. Note 287;; Note that the first and second subexpression is used by font lock. Note
@@ -521,25 +520,25 @@ not be enclosed in { } or ( )."
521 ("Macro Assignment" ,makefile-macroassign-regex 1)) 520 ("Macro Assignment" ,makefile-macroassign-regex 1))
522 "Imenu generic expression for Makefile mode. See `imenu-generic-expression'.") 521 "Imenu generic expression for Makefile mode. See `imenu-generic-expression'.")
523 522
524;;; ------------------------------------------------------------ 523;; ------------------------------------------------------------
525;;; The following configurable variables are used in the 524;; The following configurable variables are used in the
526;;; up-to-date overview . 525;; up-to-date overview .
527;;; The standard configuration assumes that your `make' program 526;; The standard configuration assumes that your `make' program
528;;; can be run in question/query mode using the `-q' option, this 527;; can be run in question/query mode using the `-q' option, this
529;;; means that the command 528;; means that the command
530;;; 529;;
531;;; make -q foo 530;; make -q foo
532;;; 531;;
533;;; should return an exit status of zero if the target `foo' is 532;; should return an exit status of zero if the target `foo' is
534;;; up to date and a nonzero exit status otherwise. 533;; up to date and a nonzero exit status otherwise.
535;;; Many makes can do this although the docs/manpages do not mention 534;; Many makes can do this although the docs/manpages do not mention
536;;; it. Try it with your favourite one. GNU make, System V make, and 535;; it. Try it with your favourite one. GNU make, System V make, and
537;;; Dennis Vadura's DMake have no problems. 536;; Dennis Vadura's DMake have no problems.
538;;; Set the variable `makefile-brave-make' to the name of the 537;; Set the variable `makefile-brave-make' to the name of the
539;;; make utility that does this on your system. 538;; make utility that does this on your system.
540;;; To understand what this is all about see the function definition 539;; To understand what this is all about see the function definition
541;;; of `makefile-query-by-make-minus-q' . 540;; of `makefile-query-by-make-minus-q' .
542;;; ------------------------------------------------------------ 541;; ------------------------------------------------------------
543 542
544(defcustom makefile-brave-make "make" 543(defcustom makefile-brave-make "make"
545 "*How to invoke make, for `makefile-query-targets'. 544 "*How to invoke make, for `makefile-query-targets'.
@@ -574,11 +573,8 @@ The function must satisfy this calling convention:
574 573
575;;; --- end of up-to-date-overview configuration ------------------ 574;;; --- end of up-to-date-overview configuration ------------------
576 575
577(defvar makefile-mode-abbrev-table nil 576(define-abbrev-table 'makefile-mode-abbrev-table ()
578 "Abbrev table in use in Makefile buffers.") 577 "Abbrev table in use in Makefile buffers.")
579(if makefile-mode-abbrev-table
580 ()
581 (define-abbrev-table 'makefile-mode-abbrev-table ()))
582 578
583(defvar makefile-mode-map 579(defvar makefile-mode-map
584 (let ((map (make-sparse-keymap)) 580 (let ((map (make-sparse-keymap))
@@ -706,15 +702,13 @@ The function must satisfy this calling convention:
706 (modify-syntax-entry ?\n "> " st) 702 (modify-syntax-entry ?\n "> " st)
707 st)) 703 st))
708 704
709(defvar makefile-imake-mode-syntax-table (copy-syntax-table 705(defvar makefile-imake-mode-syntax-table
710 makefile-mode-syntax-table)) 706 (let ((st (make-syntax-table makefile-mode-syntax-table)))
711(if makefile-imake-mode-syntax-table 707 (modify-syntax-entry ?/ ". 14" st)
712 () 708 (modify-syntax-entry ?* ". 23" st)
713 (modify-syntax-entry ?/ ". 14" makefile-imake-mode-syntax-table) 709 (modify-syntax-entry ?# "'" st)
714 (modify-syntax-entry ?* ". 23" makefile-imake-mode-syntax-table) 710 (modify-syntax-entry ?\n ". b" st)
715 (modify-syntax-entry ?# "'" makefile-imake-mode-syntax-table) 711 st))
716 (modify-syntax-entry ?\n ". b" makefile-imake-mode-syntax-table))
717
718 712
719;;; ------------------------------------------------------------ 713;;; ------------------------------------------------------------
720;;; Internal variables. 714;;; Internal variables.
@@ -774,7 +768,7 @@ The function must satisfy this calling convention:
774;;; ------------------------------------------------------------ 768;;; ------------------------------------------------------------
775 769
776;;;###autoload 770;;;###autoload
777(defun makefile-mode () 771(define-derived-mode makefile-mode nil "Makefile"
778 "Major mode for editing standard Makefiles. 772 "Major mode for editing standard Makefiles.
779 773
780If you are editing a file for a different make, try one of the 774If you are editing a file for a different make, try one of the
@@ -858,9 +852,6 @@ Makefile mode can be configured by modifying the following variables:
858 List of special targets. You will be offered to complete 852 List of special targets. You will be offered to complete
859 on one of those in the minibuffer whenever you enter a `.'. 853 on one of those in the minibuffer whenever you enter a `.'.
860 at the beginning of a line in Makefile mode." 854 at the beginning of a line in Makefile mode."
861
862 (interactive)
863 (kill-all-local-variables)
864 (add-hook 'write-file-functions 855 (add-hook 'write-file-functions
865 'makefile-warn-suspicious-lines nil t) 856 'makefile-warn-suspicious-lines nil t)
866 (add-hook 'write-file-functions 857 (add-hook 'write-file-functions
@@ -874,59 +865,44 @@ Makefile mode can be configured by modifying the following variables:
874 (make-local-variable 'makefile-need-macro-pickup) 865 (make-local-variable 'makefile-need-macro-pickup)
875 866
876 ;; Font lock. 867 ;; Font lock.
877 (make-local-variable 'font-lock-defaults) 868 (set (make-local-variable 'font-lock-defaults)
878 (setq font-lock-defaults 869 ;; SYNTAX-BEGIN set to backward-paragraph to avoid slow-down
879 ;; SYNTAX-BEGIN set to backward-paragraph to avoid slow-down 870 ;; near the end of a large buffer, due to parse-partial-sexp's
880 ;; near the end of a large buffer, due to parse-partial-sexp's 871 ;; trying to parse all the way till the beginning of buffer.
881 ;; trying to parse all the way till the beginning of buffer. 872 '(makefile-font-lock-keywords
882 '(makefile-font-lock-keywords 873 nil nil
883 nil nil 874 ((?$ . "."))
884 ((?$ . ".")) 875 backward-paragraph
885 backward-paragraph 876 (font-lock-syntactic-keywords
886 (font-lock-syntactic-keywords 877 . makefile-font-lock-syntactic-keywords)))
887 . makefile-font-lock-syntactic-keywords)))
888 878
889 ;; Add-log. 879 ;; Add-log.
890 (make-local-variable 'add-log-current-defun-function) 880 (set (make-local-variable 'add-log-current-defun-function)
891 (setq add-log-current-defun-function 'makefile-add-log-defun) 881 'makefile-add-log-defun)
892 882
893 ;; Imenu. 883 ;; Imenu.
894 (make-local-variable 'imenu-generic-expression) 884 (set (make-local-variable 'imenu-generic-expression)
895 (setq imenu-generic-expression makefile-imenu-generic-expression) 885 makefile-imenu-generic-expression)
896 886
897 ;; Dabbrev. 887 ;; Dabbrev.
898 (make-local-variable 'dabbrev-abbrev-skip-leading-regexp) 888 (set (make-local-variable 'dabbrev-abbrev-skip-leading-regexp) "\\$")
899 (setq dabbrev-abbrev-skip-leading-regexp "\\$")
900 889
901 ;; Other abbrevs. 890 ;; Other abbrevs.
902 (setq local-abbrev-table makefile-mode-abbrev-table) 891 (setq local-abbrev-table makefile-mode-abbrev-table)
903 892
904 ;; Filling. 893 ;; Filling.
905 (make-local-variable 'fill-paragraph-function) 894 (set (make-local-variable 'fill-paragraph-function) 'makefile-fill-paragraph)
906 (setq fill-paragraph-function 'makefile-fill-paragraph)
907 895
908 ;; Comment stuff. 896 ;; Comment stuff.
909 (make-local-variable 'comment-start) 897 (set (make-local-variable 'comment-start) "#")
910 (setq comment-start "#") 898 (set (make-local-variable 'comment-end) "")
911 (make-local-variable 'comment-end) 899 (set (make-local-variable 'comment-start-skip) "#+[ \t]*")
912 (setq comment-end "")
913 (make-local-variable 'comment-start-skip)
914 (setq comment-start-skip "#+[ \t]*")
915 900
916 ;; Make sure TAB really inserts \t. 901 ;; Make sure TAB really inserts \t.
917 (set (make-local-variable 'indent-line-function) 'indent-to-left-margin) 902 (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
918 903
919 ;; become the current major mode
920 (setq major-mode 'makefile-mode)
921 (setq mode-name "Makefile")
922
923 ;; Activate keymap and syntax table.
924 (use-local-map makefile-mode-map)
925 (set-syntax-table makefile-mode-syntax-table)
926
927 ;; Real TABs are important in makefiles 904 ;; Real TABs are important in makefiles
928 (setq indent-tabs-mode t) 905 (setq indent-tabs-mode t))
929 (run-mode-hooks 'makefile-mode-hook))
930 906
931;; These should do more than just differentiate font-lock. 907;; These should do more than just differentiate font-lock.
932;;;###autoload 908;;;###autoload