unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Fredrik Bergroth <fbergroth@gmail.com>
To: 52329@debbugs.gnu.org
Subject: bug#52329: Fix alignment of makefile-backslash-region
Date: Mon, 6 Dec 2021 14:02:35 +0100	[thread overview]
Message-ID: <CAEgW6ZRfEuUyXMyVFaS0Dp+z=xjh_G+cCWhkgSU3xgFcn6c_Ng@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2021-12-06 13:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 13:02 Fredrik Bergroth [this message]
2021-12-06 13:54 ` bug#52329: Fix alignment of makefile-backslash-region Stefan Kangas
2021-12-06 14:07   ` Fredrik Bergroth
2022-09-08 14:32     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEgW6ZRfEuUyXMyVFaS0Dp+z=xjh_G+cCWhkgSU3xgFcn6c_Ng@mail.gmail.com' \
    --to=fbergroth@gmail.com \
    --cc=52329@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).