GNU bug report logs - #52864
sgml-tag inserts newlines

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Wed, 29 Dec 2021 03:19:02 UTC

Severity: minor

Fixed in version 29.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52864 in the body.
You can then email your comments to 52864 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 03:19: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, 29 Dec 2021 03:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Subject: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 10:06:17 +0800
C-c C-t runs the command sgml-tag (found in mhtml-mode-map)

Problem is that it inserts newlines.


abc with marked region b

  becomes

a<xxx>b</xxx>
c

  instead of

a<xxx>b</xxx>c

emacs -Q, version "27.1"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 08:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 52864 <at> debbugs.gnu.org
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 10:38:59 +0200
> C-c C-t runs the command sgml-tag (found in mhtml-mode-map)
>
> Problem is that it inserts newlines.

Indeed, it's a problem, so I have such customization:

  (add-hook 'sgml-mode-hook
            (lambda ()
              ;; Don't insert newlines after <tag></tag>
              (setq-local skeleton-end-newline nil)))

Then maybe 'skeleton-end-newline' should be mentioned
in the docstring of 'sgml-tag', or maybe even 'sgml-mode'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 08:54:01 GMT) Full text and rfc822 format available.

Message #11 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 52864 <at> debbugs.gnu.org
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 10:53:18 +0200
>   (add-hook 'sgml-mode-hook
>             (lambda ()
>               ;; Don't insert newlines after <tag></tag>
>               (setq-local skeleton-end-newline nil)))
>
> Then maybe 'skeleton-end-newline' should be mentioned
> in the docstring of 'sgml-tag', or maybe even 'sgml-mode'.

Or better to add a new customizable variable
that defaults to skeleton-end-newline, e.g.

  (defcustom sgml-tag-end-newline skeleton-end-newline
  ...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 15:34:02 GMT) Full text and rfc822 format available.

Message #14 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52864 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 16:32:56 +0100
Juri Linkov <juri <at> linkov.net> writes:

>>   (add-hook 'sgml-mode-hook
>>             (lambda ()
>>               ;; Don't insert newlines after <tag></tag>
>>               (setq-local skeleton-end-newline nil)))
>>
>> Then maybe 'skeleton-end-newline' should be mentioned
>> in the docstring of 'sgml-tag', or maybe even 'sgml-mode'.
>
> Or better to add a new customizable variable
> that defaults to skeleton-end-newline, e.g.
>
>   (defcustom sgml-tag-end-newline skeleton-end-newline
>   ...

Doesn't it depend on what tag you're inserting whether it's likely you
want to have a newline at the end, though?  The more "block"-like tags
would normally be preferably have a newline at the end, while others
don't.

On the other hand, if you're inserting a tag in the middle of the line,
you probably don't want to insert a newline, I think?  So perhaps just
adding that defcustom is the right option...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 18:01:02 GMT) Full text and rfc822 format available.

Message #17 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 52864 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 19:58:50 +0200
>>   (defcustom sgml-tag-end-newline skeleton-end-newline
>
> Doesn't it depend on what tag you're inserting whether it's likely you
> want to have a newline at the end, though?  The more "block"-like tags
> would normally be preferably have a newline at the end, while others
> don't.

All necessary newlines are explicitly defined in skeletons,
e.g. a block-like div:

  (define-skeleton html-div
    "HTML div tag."
    nil
    "<div>" > \n _ \n "</div>" >)

where ‘>’ at the end inserts a newline too and indents.

But non-block tags are defined without newlines, e.g.:

  (define-skeleton html-span
    "HTML span tag."
    nil
    "<span>" > _ "</span>")

and skeleton-end-newline inserts an unrequested newline.

> On the other hand, if you're inserting a tag in the middle of the line,
> you probably don't want to insert a newline, I think?  So perhaps just
> adding that defcustom is the right option...

Given the examples above, I don't know what the default value should it have,
maybe nil?  For example, 'texinfo-mode' does this:

  ;; Prevent skeleton.el from adding a newline to each inserted
  ;; skeleton.  Those which do want a newline do that explicitly in
  ;; their define-skeleton form.
  (setq-local skeleton-end-newline nil)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 18:07:02 GMT) Full text and rfc822 format available.

Message #20 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52864 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 19:06:45 +0100
Juri Linkov <juri <at> linkov.net> writes:

> All necessary newlines are explicitly defined in skeletons,
> e.g. a block-like div:
>
>   (define-skeleton html-div
>     "HTML div tag."
>     nil
>     "<div>" > \n _ \n "</div>" >)
>
> where ‘>’ at the end inserts a newline too and indents.

Oh, I see.

> Given the examples above, I don't know what the default value should it have,
> maybe nil?  For example, 'texinfo-mode' does this:
>
>   ;; Prevent skeleton.el from adding a newline to each inserted
>   ;; skeleton.  Those which do want a newline do that explicitly in
>   ;; their define-skeleton form.
>   (setq-local skeleton-end-newline nil)

It sounds like we should just do the same in sgml-mode without adding
the new defcustom?  I.e., just set skeleton-end-newline to nil in the
mode function.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52864; Package emacs. (Wed, 29 Dec 2021 18:54:02 GMT) Full text and rfc822 format available.

Message #23 received at 52864 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 52864 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#52864: sgml-tag inserts newlines
Date: Wed, 29 Dec 2021 20:52:38 +0200
close 52864 29.0.50
quit

>> For example, 'texinfo-mode' does this:
>>
>>   ;; Prevent skeleton.el from adding a newline to each inserted
>>   ;; skeleton.  Those which do want a newline do that explicitly in
>>   ;; their define-skeleton form.
>>   (setq-local skeleton-end-newline nil)
>
> It sounds like we should just do the same in sgml-mode without adding
> the new defcustom?  I.e., just set skeleton-end-newline to nil in the
> mode function.

So now this is pushed to Emacs 29.




bug marked as fixed in version 29.0.50, send any further explanations to 52864 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 29 Dec 2021 18:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 27 Jan 2022 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 82 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.