]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/make-mode.el
Spelling fixes.
[gnu-emacs] / lisp / progmodes / make-mode.el
index b4ca1ba665f453a98977185fa99e71fe9efeb791..20673866bc4f6dd331994b159414fd51e0d1ba0b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; make-mode.el --- makefile editing commands for Emacs -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992, 1994, 1999-201 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1999-2013 Free Software Foundation, Inc.
 
 ;; Author: Thomas Neumann <tom@smart.bo.open.de>
 ;;     Eric S. Raymond <esr@snark.thyrsus.com>
   :version "22.1")
 
 (defcustom makefile-browser-buffer-name "*Macros and Targets*"
-  "*Name of the macro- and target browser buffer."
+  "Name of the macro- and target browser buffer."
   :type 'string
   :group 'makefile)
 
 (defcustom makefile-target-colon ":"
-  "*String to append to all target names inserted by `makefile-insert-target'.
+  "String to append to all target names inserted by `makefile-insert-target'.
 \":\" or \"::\" are common values."
   :type 'string
   :group 'makefile)
 
 (defcustom makefile-macro-assign " = "
-  "*String to append to all macro names inserted by `makefile-insert-macro'.
+  "String to append to all macro names inserted by `makefile-insert-macro'.
 The normal value should be \" = \", since this is what
 standard make expects.  However, newer makes such as dmake
 allow a larger variety of different macro assignments, so you
@@ -149,69 +149,69 @@ might prefer to use \" += \" or \" := \" ."
   :group 'makefile)
 
 (defcustom makefile-electric-keys nil
-  "*If non-nil, Makefile mode should install electric keybindings.
+  "If non-nil, Makefile mode should install electric keybindings.
 Default is nil."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-use-curly-braces-for-macros-p nil
-  "*Controls the style of generated macro references.
+  "Controls the style of generated macro references.
 Non-nil means macro references should use curly braces, like `${this}'.
 nil means use parentheses, like `$(this)'."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-tab-after-target-colon t
-  "*If non-nil, insert a TAB after a target colon.
+  "If non-nil, insert a TAB after a target colon.
 Otherwise, a space is inserted.
 The default is t."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-browser-leftmost-column 10
-  "*Number of blanks to the left of the browser selection mark."
+  "Number of blanks to the left of the browser selection mark."
   :type 'integer
   :group 'makefile)
 
 (defcustom makefile-browser-cursor-column 10
-  "*Column the cursor goes to when it moves up or down in the Makefile browser."
+  "Column the cursor goes to when it moves up or down in the Makefile browser."
   :type 'integer
   :group 'makefile)
 
 (defcustom makefile-backslash-column 48
-  "*Column in which `makefile-backslash-region' inserts backslashes."
+  "Column in which `makefile-backslash-region' inserts backslashes."
   :type 'integer
   :group 'makefile)
 
 (defcustom makefile-backslash-align t
-  "*If non-nil, `makefile-backslash-region' will align backslashes."
+  "If non-nil, `makefile-backslash-region' will align backslashes."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-browser-selected-mark "+  "
-  "*String used to mark selected entries in the Makefile browser."
+  "String used to mark selected entries in the Makefile browser."
   :type 'string
   :group 'makefile)
 
 (defcustom makefile-browser-unselected-mark "   "
-  "*String used to mark unselected entries in the Makefile browser."
+  "String used to mark unselected entries in the Makefile browser."
   :type 'string
   :group 'makefile)
 
 (defcustom makefile-browser-auto-advance-after-selection-p t
-  "*If non-nil, cursor will move after item is selected in Makefile browser."
+  "If non-nil, cursor will move after item is selected in Makefile browser."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-pickup-everything-picks-up-filenames-p nil
-  "*If non-nil, `makefile-pickup-everything' picks up filenames as targets.
+  "If non-nil, `makefile-pickup-everything' picks up filenames as targets.
 This means it calls `makefile-pickup-filenames-as-targets'.
 Otherwise filenames are omitted."
   :type 'boolean
   :group 'makefile)
 
 (defcustom makefile-cleanup-continuations nil
-  "*If non-nil, automatically clean up continuation lines when saving.
+  "If non-nil, automatically clean up continuation lines when saving.
 A line is cleaned up by removing all whitespace following a trailing
 backslash.  This is done silently.
 IMPORTANT: Please note that enabling this option causes Makefile mode
@@ -220,7 +220,7 @@ to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\"."
   :group 'makefile)
 
 (defcustom makefile-mode-hook nil
-  "*Normal hook run by `makefile-mode'."
+  "Normal hook run by `makefile-mode'."
   :type 'hook
   :group 'makefile)
 
@@ -247,7 +247,7 @@ you enter a \".\" at the beginning of a line in `makefile-mode'."
 
 (defcustom makefile-runtime-macros-list
   '(("@") ("&") (">") ("<") ("*") ("^") ("+") ("?") ("%") ("$"))
-  "*List of macros that are resolved by make at runtime.
+  "List of macros that are resolved by make at runtime.
 If you insert a macro reference using `makefile-insert-macro-ref', the name
 of the macro is checked against this list.  If it can be found its name will
 not be enclosed in { } or ( )."
@@ -553,14 +553,14 @@ not be enclosed in { } or ( )."
 ;; ------------------------------------------------------------
 
 (defcustom makefile-brave-make "make"
-  "*How to invoke make, for `makefile-query-targets'.
+  "How to invoke make, for `makefile-query-targets'.
 This should identify a `make' command that can handle the `-q' option."
   :type 'string
   :group 'makefile)
 
 (defcustom makefile-query-one-target-method-function
   'makefile-query-by-make-minus-q
-  "*Function to call to determine whether a make target is up to date.
+  "Function to call to determine whether a make target is up to date.
 The function must satisfy this calling convention:
 
 * As its first argument, it must accept the name of the target to
@@ -579,7 +579,7 @@ The function must satisfy this calling convention:
   'makefile-query-one-target-method-function)
 
 (defcustom makefile-up-to-date-buffer-name "*Makefile Up-to-date overview*"
-  "*Name of the Up-to-date overview buffer."
+  "Name of the Up-to-date overview buffer."
   :type 'string
   :group 'makefile)
 
@@ -879,41 +879,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 +935,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 +945,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 +955,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 +1213,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 +1270,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,8 +1292,10 @@ 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) ?\\)
@@ -1307,6 +1304,12 @@ definition and conveniently use this command."
        (save-restriction
          (narrow-to-region beginning end)
          (makefile-backslash-region (point-min) (point-max) t)
+         ;; 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
+         ;; (bug#13179).
+         (remove-text-properties (point-min) (point-max) '(syntax-table))
          (let ((fill-paragraph-function nil)
                 ;; Adjust fill-column to allow space for the backslash.
                 (fill-column (- fill-column 1)))
@@ -1493,7 +1496,6 @@ Insertion takes place at point."
   (setq buffer-read-only t))
 
 (defun makefile-browse (targets macros)
-  (interactive)
   (if (zerop (+ (length targets) (length macros)))
       (progn
        (beep)
@@ -1502,8 +1504,8 @@ Insertion takes place at point."
        (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 ()