all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#52864: sgml-tag inserts newlines
@ 2021-12-29  2:06 積丹尼 Dan Jacobson
  2021-12-29  8:38 ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: 積丹尼 Dan Jacobson @ 2021-12-29  2:06 UTC (permalink / raw)
  To: 52864

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"





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29  2:06 bug#52864: sgml-tag inserts newlines 積丹尼 Dan Jacobson
@ 2021-12-29  8:38 ` Juri Linkov
  2021-12-29  8:53   ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-29  8:38 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 52864

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





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29  8:38 ` Juri Linkov
@ 2021-12-29  8:53   ` Juri Linkov
  2021-12-29 15:32     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-29  8:53 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 52864

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





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29  8:53   ` Juri Linkov
@ 2021-12-29 15:32     ` Lars Ingebrigtsen
  2021-12-29 17:58       ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-29 15:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52864, 積丹尼 Dan Jacobson

Juri Linkov <juri@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





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29 15:32     ` Lars Ingebrigtsen
@ 2021-12-29 17:58       ` Juri Linkov
  2021-12-29 18:06         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2021-12-29 17:58 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 52864, 積丹尼 Dan Jacobson

>>   (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)





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29 17:58       ` Juri Linkov
@ 2021-12-29 18:06         ` Lars Ingebrigtsen
  2021-12-29 18:52           ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-29 18:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52864, 積丹尼 Dan Jacobson

Juri Linkov <juri@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





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

* bug#52864: sgml-tag inserts newlines
  2021-12-29 18:06         ` Lars Ingebrigtsen
@ 2021-12-29 18:52           ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2021-12-29 18:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 52864, 積丹尼 Dan Jacobson

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.





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

end of thread, other threads:[~2021-12-29 18:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-29  2:06 bug#52864: sgml-tag inserts newlines 積丹尼 Dan Jacobson
2021-12-29  8:38 ` Juri Linkov
2021-12-29  8:53   ` Juri Linkov
2021-12-29 15:32     ` Lars Ingebrigtsen
2021-12-29 17:58       ` Juri Linkov
2021-12-29 18:06         ` Lars Ingebrigtsen
2021-12-29 18:52           ` Juri Linkov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.