all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: Philip Kaludercic <philipk@posteo.net>, 69647@debbugs.gnu.org
Subject: bug#69647: [PATCH 1/2] Delete trailing whitespace when formatting LSP documentation
Date: Fri, 8 Mar 2024 13:36:45 -0800	[thread overview]
Message-ID: <a110a087-ef75-40e1-d557-ca8e58b9bae8@gmail.com> (raw)
In-Reply-To: <CALDnm50gADLH=0CBoiUntig81QBOqoY58B=R4RPyJy2SE9SwPA@mail.gmail.com>

On 3/8/2024 1:02 PM, João Távora wrote:
> And that's probably the ideal solution too.  But as far as I remember,
> markdown-view-mode (or whatever it's called) is not used for viewing the
> documentation.  it is used somewhere in the pipeline to render the text in a
> buffer which is then yanked using `buffer-substring` (with properties).

Yep. 'eglot--format-markup' uses 'gfm-view-mode' in a temp buffer and 
returns it as a string after calling 'buffer-string'. That should be 
fine though. For example, last year I fixed a similar issue with Eglot's 
usage of Markdown mode where backslash escapes still showed up in the 
Eldoc buffer:

   https://github.com/joaotavora/eglot/issues/188
   https://github.com/jrblevin/markdown-mode/pull/756
   https://github.com/jrblevin/markdown-mode/issues/766

I expect that something similar could be done for the trailing spaces case.

> So I don't know how that'd work.  Maybe Philip's patch can be tweaked to leave
> those specific bits of trailing whitespace alone?

I think we should leave the trailing whitespace alone in Eglot entirely; 
the underline that Philip mentioned in the original report is from 
'markdown-line-break-face', which Markdown mode uses[1] to fontify only 
the trailing whitespace that means "insert a line break".

> And do we really want to preserve the LSP server's notion of a line
> break anyway?  It has no concept of how wide the  Emacs window is.
> I'd say paragraphs yes, line breaks no.
I think we do in this case, yes. (Although I guess this depends on how 
Markdown mode handles things.) These are "hard" line breaks 
corresponding to the "<br>" tag when you convert Markdown->HTML, so they 
should always get turned into a newline.

Normally if I have some text like "foo bar\nbaz" in Markdown, that 
should get rendered as "foo bar baz": the newline is just there to make 
the source text readable, but it's treated like a space. 
'markdown-view-mode' (and 'gfm-view-mode') don't do this though, so a 
soft newline stays a newline in the "view" output. This also means that 
the Markdown line break sequence ("  \n") isn't necessary in 
'markdown-view-mode' to get a line break. Just the "\n" is sufficient. 
(In this sense, we could remove the "  " and there'd be no issues with 
the *current* version of markdown-mode.)

If I were going to make a complete fix for this, I'd do most of it in 
markdown-mode and would do the following things:

1. Translate "\n" to " " in 'markdown-view-mode'
2. Translate "  \n" to "\n" in 'markdown-view-mode'
3. Turn on 'visual-line-mode' in the ElDoc buffer to get soft line wrapping

However, as a partial fix, you could probably just set 
'markdown-line-break-face' to be invisible when 
'markdown-hide-markup[-in-view-modes]' is non-nil somewhere in Markdown 
mode. I think that would be easy, although I tried to do this and the 
obvious method didn't work, so who knows?

[1] Or *should* use, anyway. I haven't tested all possible cases.





  reply	other threads:[~2024-03-08 21:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 15:48 bug#69647: [PATCH 1/2] Delete trailing whitespace when formatting LSP documentation Philip Kaludercic
2024-03-08 20:41 ` João Távora
2024-03-08 20:54 ` Jim Porter
2024-03-08 21:02   ` João Távora
2024-03-08 21:36     ` Jim Porter [this message]
2024-03-09  3:08       ` Jim Porter
2024-03-09  9:02         ` Philip Kaludercic
2024-03-09 18:28           ` Jim Porter
2024-03-09 18:46             ` Philip Kaludercic
2024-03-11  3:50             ` Jim Porter
2024-03-22  8:49               ` Philip Kaludercic

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

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

  git send-email \
    --in-reply-to=a110a087-ef75-40e1-d557-ca8e58b9bae8@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=69647@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=philipk@posteo.net \
    /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 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.