]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/make-mode.el
Add new function dom-remove-node
[gnu-emacs] / lisp / progmodes / make-mode.el
index 478eb592a22df6810d08d65050e1c84516d55b9f..fb7142082943812d3c850f02c3afbbba956e4493 100644 (file)
@@ -1,10 +1,10 @@
 ;;; make-mode.el --- makefile editing commands for Emacs -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992, 1994, 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: Thomas Neumann <tom@smart.bo.open.de>
 ;;     Eric S. Raymond <esr@snark.thyrsus.com>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Adapted-By: ESR
 ;; Keywords: unix, tools
 
     (t (:reverse-video t)))
   "Face to use for highlighting leading spaces in Font-Lock mode."
   :group 'makefile)
-(define-obsolete-face-alias 'makefile-space-face 'makefile-space "22.1")
 
 (defface makefile-targets
   ;; This needs to go along both with foreground and background colors (i.e. shell)
@@ -241,7 +240,7 @@ to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\"."
   "List of special targets.
 You will be offered to complete on one of those in the minibuffer whenever
 you enter a \".\" at the beginning of a line in `makefile-mode'."
-  :type '(repeat (list string))
+  :type '(repeat string)
   :group 'makefile)
 (put 'makefile-special-targets-list 'risky-local-variable t)
 
@@ -291,7 +290,7 @@ not be enclosed in { } or ( )."
   ;; (spanning potentially several lines).
   ;; "^ *\\([^ \n\t][^:#= \t\n]*\\)[ \t]*\\(?:!=[ \t]*\\(\\(?:.+\\\\\n\\)*.+\\)\\|[*:+]?[:?]?=[ \t]*\\(\\(?:.*\\\\\n\\)*.*\\)\\)"
   ;; What about the define statement?  What about differentiating this for makepp?
-  "\\(?:^\\|^export\\|^override\\|:\\|: *override\\) *\\([^ \n\t][^:#= \t\n]*\\)[ \t]*\\(?:!=\\|[*:+]?[:?]?=\\)"
+  "\\(?:^\\|^export\\|^override\\|:\\|:[ \t]*override\\)[ \t]*\\([^ \n\t][^:#= \t\n]*\\)[ \t]*\\(?:!=\\|[*:+]?[:?]?=\\)"
   "Regex used to find macro assignment lines in a makefile.")
 
 (defconst makefile-var-use-regex
@@ -712,7 +711,9 @@ The function must satisfy this calling convention:
     (modify-syntax-entry ?\` "\"    " st)
     (modify-syntax-entry ?#  "<     " st)
     (modify-syntax-entry ?\n ">     " st)
-    st))
+    (modify-syntax-entry ?= "." st)
+    st)
+  "Syntax table used in `makefile-mode'.")
 
 (defvar makefile-imake-mode-syntax-table
   (let ((st (make-syntax-table makefile-mode-syntax-table)))
@@ -879,41 +880,42 @@ Makefile mode can be configured by modifying the following variables:
   (make-local-variable 'makefile-need-macro-pickup)
 
   ;; Font lock.
-  (set (make-local-variable 'font-lock-defaults)
-       ;; SYNTAX-BEGIN set to backward-paragraph to avoid slow-down
-       ;; near the end of a large buffer, due to parse-partial-sexp's
-       ;; trying to parse all the way till the beginning of buffer.
-       '(makefile-font-lock-keywords
-         nil nil
-         ((?$ . "."))
-         backward-paragraph))
-  (set (make-local-variable 'syntax-propertize-function)
-       makefile-syntax-propertize-function)
+  (setq-local font-lock-defaults
+             ;; Set SYNTAX-BEGIN to backward-paragraph to avoid
+             ;; slow-down near the end of a large buffer, due to
+             ;; `parse-partial-sexp' trying to parse all the way till
+             ;; the beginning of buffer.
+             '(makefile-font-lock-keywords
+               nil nil
+               ((?$ . "."))
+               backward-paragraph))
+  (setq-local syntax-propertize-function
+             makefile-syntax-propertize-function)
 
   ;; Add-log.
-  (set (make-local-variable 'add-log-current-defun-function)
-       'makefile-add-log-defun)
+  (setq-local add-log-current-defun-function
+             'makefile-add-log-defun)
 
   ;; Imenu.
-  (set (make-local-variable 'imenu-generic-expression)
-       makefile-imenu-generic-expression)
+  (setq-local imenu-generic-expression
+             makefile-imenu-generic-expression)
 
   ;; Dabbrev.
-  (set (make-local-variable 'dabbrev-abbrev-skip-leading-regexp) "\\$")
+  (setq-local dabbrev-abbrev-skip-leading-regexp "\\$")
 
   ;; Other abbrevs.
   (setq local-abbrev-table makefile-mode-abbrev-table)
 
   ;; Filling.
-  (set (make-local-variable 'fill-paragraph-function) 'makefile-fill-paragraph)
+  (setq-local fill-paragraph-function 'makefile-fill-paragraph)
 
   ;; Comment stuff.
-  (set (make-local-variable 'comment-start) "#")
-  (set (make-local-variable 'comment-end) "")
-  (set (make-local-variable 'comment-start-skip) "#+[ \t]*")
+  (setq-local comment-start "#")
+  (setq-local comment-end "")
+  (setq-local comment-start-skip "#+[ \t]*")
 
   ;; Make sure TAB really inserts \t.
-  (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
+  (setq-local indent-line-function 'indent-to-left-margin)
 
   ;; Real TABs are important in makefiles
   (setq indent-tabs-mode t))
@@ -934,8 +936,7 @@ Makefile mode can be configured by modifying the following variables:
 ;;;###autoload
 (define-derived-mode makefile-makepp-mode makefile-mode "Makeppfile"
   "An adapted `makefile-mode' that knows about makepp."
-  (set (make-local-variable 'makefile-rule-action-regex)
-       makefile-makepp-rule-action-regex)
+  (setq-local makefile-rule-action-regex makefile-makepp-rule-action-regex)
   (setq font-lock-defaults
        `(makefile-makepp-font-lock-keywords ,@(cdr font-lock-defaults))
        imenu-generic-expression
@@ -945,11 +946,9 @@ Makefile mode can be configured by modifying the following variables:
 ;;;###autoload
 (define-derived-mode makefile-bsdmake-mode makefile-mode "BSDmakefile"
   "An adapted `makefile-mode' that knows about BSD make."
-  (set (make-local-variable 'makefile-dependency-regex)
-       makefile-bsdmake-dependency-regex)
-  (set (make-local-variable 'makefile-dependency-skip) "^:!")
-  (set (make-local-variable 'makefile-rule-action-regex)
-       makefile-bsdmake-rule-action-regex)
+  (setq-local makefile-dependency-regex makefile-bsdmake-dependency-regex)
+  (setq-local makefile-dependency-skip "^:!")
+  (setq-local makefile-rule-action-regex makefile-bsdmake-rule-action-regex)
   (setq font-lock-defaults
        `(makefile-bsdmake-font-lock-keywords ,@(cdr font-lock-defaults))))
 
@@ -957,7 +956,7 @@ Makefile mode can be configured by modifying the following variables:
 (define-derived-mode makefile-imake-mode makefile-mode "Imakefile"
   "An adapted `makefile-mode' that knows about imake."
   :syntax-table makefile-imake-mode-syntax-table
-  (set (make-local-variable 'syntax-propertize-function) nil)
+  (setq-local syntax-propertize-function nil)
   (setq font-lock-defaults
         `(makefile-imake-font-lock-keywords ,@(cdr font-lock-defaults))))
 
@@ -1215,26 +1214,23 @@ definition and conveniently use this command."
   (save-excursion
     (goto-char from)
     (let ((column makefile-backslash-column)
-          (endmark (make-marker)))
-      (move-marker endmark to)
+          (endmark (copy-marker to)))
       ;; Compute the smallest column number past the ends of all the lines.
-      (if makefile-backslash-align
-         (progn
-           (if (not delete-flag)
-               (while (< (point) to)
-                 (end-of-line)
-                 (if (= (preceding-char) ?\\)
-                     (progn (forward-char -1)
-                            (skip-chars-backward " \t")))
-                 (setq column (max column (1+ (current-column))))
-                 (forward-line 1)))
-           ;; Adjust upward to a tab column, if that doesn't push
-           ;; past the margin.
-           (if (> (% column tab-width) 0)
-               (let ((adjusted (* (/ (+ column tab-width -1) tab-width)
-                                  tab-width)))
-                 (if (< adjusted (window-width))
-                     (setq column adjusted))))))
+      (when (and makefile-backslash-align (not delete-flag))
+        (while (< (point) to)
+          (end-of-line)
+          (if (= (preceding-char) ?\\)
+              (progn (forward-char -1)
+                     (skip-chars-backward " \t")))
+          (setq column (max column (1+ (current-column))))
+         (forward-line 1))
+        ;; Adjust upward to a tab column, if that doesn't push
+        ;; past the margin.
+        (if (> (% column tab-width) 0)
+            (let ((adjusted (* (/ (+ column tab-width -1) tab-width)
+                               tab-width)))
+              (if (< adjusted (window-width))
+                 (setq column adjusted)))))
       ;; Don't modify blank lines at start of region.
       (goto-char from)
       (while (and (< (point) endmark) (eolp))
@@ -1275,9 +1271,9 @@ definition and conveniently use this command."
 
 ;; Filling
 
-(defun makefile-fill-paragraph (_arg)
-  ;; Fill comments, backslashed lines, and variable definitions
-  ;; specially.
+(defun makefile-fill-paragraph (_justify)
+  "Function used for `fill-paragraph-function' in Makefile mode.
+Fill comments, backslashed lines, and variable definitions specially."
   (save-excursion
     (beginning-of-line)
     (cond
@@ -1297,17 +1293,20 @@ definition and conveniently use this command."
               (end-of-line 0)
               (while (= (preceding-char) ?\\)
                 (end-of-line 0))
-              (forward-char)
-              (point)))
+              ;; Maybe we hit bobp, in which case we are not at EOL.
+              (if (eolp)
+                  (1+ (point))
+                 (point))))
            (end
             (save-excursion
-              (while (= (preceding-char) ?\\)
+              (while (and (= (preceding-char) ?\\)
+                          (not (eobp)))
                 (end-of-line 2))
               (point))))
        (save-restriction
          (narrow-to-region beginning end)
          (makefile-backslash-region (point-min) (point-max) t)
-         ;; Backslashed newlines are marked as puncutations, so when
+         ;; Backslashed newlines are marked as punctuation, so when
          ;; fill-delete-newlines turns the LF into SPC, we end up with spaces
          ;; which back-to-indentation (called via fill-newline ->
          ;; fill-indent-to-left-margin -> indent-line-to) thinks are real code
@@ -1455,7 +1454,7 @@ definition and conveniently use this command."
 
 (defun makefile-browser-insert-continuation ()
   "Insert a makefile continuation.
-In the makefile buffer, go to (end-of-line), insert a \'\\\'
+In the makefile buffer, go to (end-of-line), insert a `\\'
 character, insert a new blank line, go to that line and indent by one TAB.
 This is most useful in the process of creating continued lines when copying
 large dependencies from the browser to the client buffer.
@@ -1502,13 +1501,13 @@ Insertion takes place at point."
   (if (zerop (+ (length targets) (length macros)))
       (progn
        (beep)
-       (message "No macros or targets to browse! Consider running 'makefile-pickup-everything\'"))
+       (message "No macros or targets to browse! Consider running `makefile-pickup-everything'"))
     (let ((browser-buffer (get-buffer-create makefile-browser-buffer-name)))
        (pop-to-buffer browser-buffer)
        (makefile-browser-fill targets macros)
        (shrink-window-if-larger-than-buffer)
-       (set (make-local-variable 'makefile-browser-selection-vector)
-            (make-vector (+ (length targets) (length macros)) nil))
+       (setq-local makefile-browser-selection-vector
+                   (make-vector (+ (length targets) (length macros)) nil))
        (makefile-browser-start-interaction))))
 
 (defun makefile-switch-to-browser ()