unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52329: Fix alignment of makefile-backslash-region
@ 2021-12-06 13:02 Fredrik Bergroth
  2021-12-06 13:54 ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: Fredrik Bergroth @ 2021-12-06 13:02 UTC (permalink / raw)
  To: 52329


[-- Attachment #1.1: Type: text/plain, Size: 243 bytes --]

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!

[-- Attachment #1.2: Type: text/html, Size: 292 bytes --]

[-- Attachment #2: 0001-Fix-alignment-of-makefile-backslash-region.patch --]
[-- Type: text/x-patch, Size: 1479 bytes --]

From 5409fec9e445eb69037e04b86a1fc457d1759610 Mon Sep 17 00:00:00 2001
From: Fredrik Bergroth <fbergroth@gmail.com>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-08 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 13:02 bug#52329: Fix alignment of makefile-backslash-region Fredrik Bergroth
2021-12-06 13:54 ` Stefan Kangas
2021-12-06 14:07   ` Fredrik Bergroth
2022-09-08 14:32     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).