]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/make-mode.el
Update copyright year to 2015
[gnu-emacs] / lisp / progmodes / make-mode.el
index 8e8cd74c7be703b6bdc14267a83675f33b18d312..fc0be60fb596b9a1ba0dc7fbcc9b5ef4c11fea84 100644 (file)
@@ -1,10 +1,10 @@
 ;;; 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-2015 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
 
@@ -241,7 +241,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)
 
@@ -712,7 +712,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)))
@@ -1213,26 +1215,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))
@@ -1273,9 +1272,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
@@ -1295,16 +1294,25 @@ 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 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)))