GNU bug report logs -
#79630
indent-for-tab-command should respect HTML <pre>
Previous Next
To reply to this bug, email your comments to 79630 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79630; Package
emacs.
(Wed, 15 Oct 2025 10:54:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org.
(Wed, 15 Oct 2025 10:54:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
C-x h TAB wipes out precious <PRE> section indentation in HTML
documents. html-tidy would never do such a thing.
emacs-version "30.1"
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79630; Package
emacs.
(Wed, 15 Oct 2025 12:21:06 GMT)
Full text and
rfc822 format available.
Message #8 received at 79630 <at> debbugs.gnu.org (full text, mbox):
> From: Dan Jacobson <jidanni <at> jidanni.org>
> Date: Wed, 15 Oct 2025 18:52:44 +0800
>
> C-x h TAB wipes out precious <PRE> section indentation in HTML
> documents. html-tidy would never do such a thing.
> emacs-version "30.1"
I cannot reproduce this in "emacs -Q" and with some random HTML file
that has <pre> in it. Please provide a file with which it could be
reproduced, and all the necessary steps starting from "emacs -Q".
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79630; Package
emacs.
(Wed, 15 Oct 2025 12:57:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 79630 <at> debbugs.gnu.org (full text, mbox):
>>>>> "EZ" == Eli Zaretskii <eliz <at> gnu.org> writes:
EZ> I cannot reproduce this in "emacs -Q" and with some random HTML file
EZ> that has <pre> in it. Please provide a file with which it could be
EZ> reproduced, and all the necessary steps starting from "emacs -Q".
$ cat v.html
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<pre>
This is a line with a lot of blanks at the beginning.
</pre>
</body>
</html>
$ emacs -nw -Q v.html #Then C-x h TAB and then save the file
$ cat v.html
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<pre>
This is a line with a lot of blanks at the beginning.
</pre>
</body>
</html>
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79630; Package
emacs.
(Wed, 15 Oct 2025 13:44:04 GMT)
Full text and
rfc822 format available.
Message #14 received at 79630 <at> debbugs.gnu.org (full text, mbox):
> From: Dan Jacobson <jidanni <at> jidanni.org>
> Cc: 79630 <at> debbugs.gnu.org
> Date: Wed, 15 Oct 2025 20:56:11 +0800
>
> >>>>> "EZ" == Eli Zaretskii <eliz <at> gnu.org> writes:
> EZ> I cannot reproduce this in "emacs -Q" and with some random HTML file
> EZ> that has <pre> in it. Please provide a file with which it could be
> EZ> reproduced, and all the necessary steps starting from "emacs -Q".
>
> $ cat v.html
> <!DOCTYPE html>
> <html>
> <head>
> <title>test</title>
> </head>
> <body>
> <pre>
> This is a line with a lot of blanks at the beginning.
> </pre>
> </body>
> </html>
> $ emacs -nw -Q v.html #Then C-x h TAB and then save the file
> $ cat v.html
> <!DOCTYPE html>
> <html>
> <head>
> <title>test</title>
> </head>
> <body>
> <pre>
> This is a line with a lot of blanks at the beginning.
> </pre>
> </body>
> </html>
If you want TAB to preserve whitespace in <pre> blocks, then this
seems to be a missing feature. Patches welcome.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79630; Package
emacs.
(Wed, 15 Oct 2025 15:16:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 79630 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Wed, 15 Oct 2025 16:43:08 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Dan Jacobson <jidanni <at> jidanni.org>
>> Cc: 79630 <at> debbugs.gnu.org
>> Date: Wed, 15 Oct 2025 20:56:11 +0800
>>
>> >>>>> "EZ" == Eli Zaretskii <eliz <at> gnu.org> writes:
>> EZ> I cannot reproduce this in "emacs -Q" and with some random HTML file
>> EZ> that has <pre> in it. Please provide a file with which it could be
>> EZ> reproduced, and all the necessary steps starting from "emacs -Q".
>>
>> $ cat v.html
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <title>test</title>
>> </head>
>> <body>
>> <pre>
>> This is a line with a lot of blanks at the beginning.
>> </pre>
>> </body>
>> </html>
>> $ emacs -nw -Q v.html #Then C-x h TAB and then save the file
>> $ cat v.html
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <title>test</title>
>> </head>
>> <body>
>> <pre>
>> This is a line with a lot of blanks at the beginning.
>> </pre>
>> </body>
>> </html>
>
> If you want TAB to preserve whitespace in <pre> blocks, then this
> seems to be a missing feature. Patches welcome.
The following patch preserves the whitespace in the <pre> block of the
above test case and I guess it should work for <pre> blocks in general,
but I haven't tried it with any other examples.
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 2accd31bc36..af808eaf3cc 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1718,6 +1718,8 @@ sgml-calculate-indent
(skip-chars-forward " \t\n")
(< (point) here) (sgml-at-indentation-p))
(current-column))
+ ((and context (string= (sgml-tag-name (car context)) "pre"))
+ nil)
;; ;; If the parsing failed, try to recover.
;; ((and (null context) (bobp)
;; (not (eq (char-after here) ?<)))
[Message part 3 (text/plain, inline)]
Steve Berman
This bug report was last modified 20 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.