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

* bug#52329: Fix alignment of makefile-backslash-region
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2021-12-06 13:54 UTC (permalink / raw)
  To: Fredrik Bergroth; +Cc: 52329

Fredrik Bergroth <fbergroth@gmail.com> writes:

> `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.

Thanks for the patch.

Could you provide a recipe to reproduce this problem, preferably
starting from "emacs -Q"?





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

* bug#52329: Fix alignment of makefile-backslash-region
  2021-12-06 13:54 ` Stefan Kangas
@ 2021-12-06 14:07   ` Fredrik Bergroth
  2022-09-08 14:32     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Fredrik Bergroth @ 2021-12-06 14:07 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 52329

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

Sure!

emacs -Q --eval '(makefile-mode)' --eval '(insert "a\nbbbbb\ncc")' --eval
'(mark-whole-buffer)' --eval "(call-interactively
'makefile-backslash-region)"

This will end up with a bunch of tabs (rather than spaces) after the "a"
and the b:s. If you now change tab-width to 2, the backslashes won't align.

Den mån 6 dec. 2021 kl 14:54 skrev Stefan Kangas <stefan@marxist.se>:

> Fredrik Bergroth <fbergroth@gmail.com> writes:
>
> > `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.
>
> Thanks for the patch.
>
> Could you provide a recipe to reproduce this problem, preferably
> starting from "emacs -Q"?
>

[-- Attachment #2: Type: text/html, Size: 1313 bytes --]

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

* bug#52329: Fix alignment of makefile-backslash-region
  2021-12-06 14:07   ` Fredrik Bergroth
@ 2022-09-08 14:32     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-08 14:32 UTC (permalink / raw)
  To: Fredrik Bergroth; +Cc: 52329, Stefan Kangas

Fredrik Bergroth <fbergroth@gmail.com> writes:

> emacs -Q --eval '(makefile-mode)' --eval '(insert "a\nbbbbb\ncc")' --eval '
> (mark-whole-buffer)' --eval "(call-interactively 'makefile-backslash-region)"
>
> This will end up with a bunch of tabs (rather than spaces) after the
> "a" and the b:s. If you now change tab-width to 2, the backslashes
> won't align.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

The advantage of using TABs for alignment here, though, is that if you
then adjust some of the text slightly, you won't need to adjust the
alignment.

Which is much more common than altering tab-width, so I don't think we
want to do this change, and I'm therefore closing this bug report.





^ permalink raw reply	[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).