Subject: bug#52329: Fix alignment of makefile-backslash-region

From: Fredrik Bergroth <[email-masked]>
Date: Mon, 6 Dec 2021 14:02:35 +0100

Hi,

`makefile-backslash-region' is inserting tabs rather than spaces (due to
the major mode setting indent-tabs-mode).
The backslashes won't align properly (unless everyone agrees on a
tab-width). I attached a patch that fixes this.

Cheers!
From 5409fec9e445eb69037e04b86a1fc457d1759610 Mon Sep 17 00:00:00 2001
From: Fredrik Bergroth <[email-masked]>
Date: Mon, 6 Dec 2021 13:47:01 +0100
Subject: [PATCH] Fix alignment of makefile-backslash-region

* lisp/progmodes/make-mode.el (makefile-append-backslash): Ensure
`indent-to' will use spaces.
---
 lisp/progmodes/make-mode.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index df17b87c01..b2e2d8b65c 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1224,13 +1224,15 @@ makefile-backslash-region
 
 (defun makefile-append-backslash (column)
   (end-of-line)
-  ;; Note that "\\\\" is needed to get one backslash.
-  (if (= (preceding-char) ?\\)
-      (progn (forward-char -1)
-             (delete-horizontal-space)
-             (indent-to column (if makefile-backslash-align nil 1)))
-    (indent-to column (if makefile-backslash-align nil 1))
-    (insert "\\")))
+  ;; Ensure `indent-to' will use spaces.
+  (let ((indent-tabs-mode nil))
+    ;; Note that "\\\\" is needed to get one backslash.
+    (if (= (preceding-char) ?\\)
+        (progn (forward-char -1)
+               (delete-horizontal-space)
+               (indent-to column (if makefile-backslash-align nil 1)))
+      (indent-to column (if makefile-backslash-align nil 1))
+      (insert "\\"))))
 
 (defun makefile-delete-backslash ()
   (end-of-line)
-- 
2.17.1