unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Mark Hepburn <mark@markhepburn.com>
Cc: 72681@debbugs.gnu.org
Subject: bug#72681: 31.0.50; visual-wrap-prefix-mode interacts badly with plain lists in org-mode
Date: Sat, 17 Aug 2024 13:29:45 -0700	[thread overview]
Message-ID: <418fb258-c318-9aa2-8bd1-73b34611fb32@gmail.com> (raw)
In-Reply-To: <8634n362gv.fsf@gnu.org>

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

On 8/17/2024 12:19 AM, Eli Zaretskii wrote:
> Jim, could you please look into this?  Is visual-wrap-prefix-mode at
> all supposed to be used in Org buffers?

Yes, I think 'visual-wrap-prefix-mode' should support Org buffers. It's 
probably one of the more useful text-based modes where 
'visual-wrap-prefix-mode' would be convenient.

It looks like this was just a small corner case in the visual-wrap code 
for aligning prefix lines that didn't account for Org-Mode's custom 
'adaptive-fill-function'. I've fixed this by being more careful to only 
apply the 'min-width' display property to a single logical line.

Mark, does the attached patch fix things for you? It looks like it works 
in my tests, but maybe you have some more complicated test cases you'd 
like to try to verify this.

[-- Attachment #2: 0001-Be-more-careful-about-aligning-prefix-lines-in-visua.patch --]
[-- Type: text/plain, Size: 1638 bytes --]

From fe116a69a79653041817c7de9306bbc5040c9652 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 17 Aug 2024 13:21:00 -0700
Subject: [PATCH] Be more careful about aligning prefix lines in
 'visual-wrap-prefix-mode'

* lisp/visual-wrap.el (visual-wrap--apply-to-line): Ensure we don't
apply the 'min-width' property across multiple lines (bug#72681).
---
 lisp/visual-wrap.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
index cac3bc767b8..eb5daa89222 100644
--- a/lisp/visual-wrap.el
+++ b/lisp/visual-wrap.el
@@ -121,9 +121,15 @@ visual-wrap--apply-to-line
                (next-line-prefix (visual-wrap--content-prefix
                                   first-line-prefix position)))
       (when (numberp next-line-prefix)
+        ;; Set a minimum width for the prefix so it lines up correctly
+        ;; with subsequent lines.  Make sure not to do this past the end
+        ;; of the line though!  (`fill-match-adaptive-prefix' could
+        ;; potentially return a number larger the length of the current
+        ;; line in the buffer.)
         (put-text-property
-         position (+ position (length first-line-prefix)) 'display
-         `(min-width ((,next-line-prefix . width)))))
+         position (min (+ position (length first-line-prefix))
+                       (line-end-position))
+         'display `(min-width ((,next-line-prefix . width)))))
       (setq next-line-prefix (visual-wrap--adjust-prefix next-line-prefix))
       (put-text-property
        position (line-end-position) 'wrap-prefix
-- 
2.25.1


  reply	other threads:[~2024-08-17 20:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-17  2:21 bug#72681: 31.0.50; visual-wrap-prefix-mode interacts badly with plain lists in org-mode Mark Hepburn
2024-08-17  7:19 ` Eli Zaretskii
2024-08-17 20:29   ` Jim Porter [this message]
2024-08-18  0:02     ` Mark Hepburn
2024-08-18  1:40       ` Jim Porter
2024-08-18  9:53         ` Mark Hepburn
2024-08-18 17:11           ` Jim Porter
     [not found]             ` <a552da1e-80b9-42f1-900c-2255c65a63d4@app.fastmail.com>
     [not found]               ` <CANh=_JH9GcCGhuLQUZeGZ89CnpYTuWmEGwKXRQ=zY-7X4WzUmg@mail.gmail.com>
     [not found]                 ` <31873240-cedb-4a6e-825c-2ad60caa8b11@app.fastmail.com>
     [not found]                   ` <3cbd38fd-82e5-46aa-bc51-a8cd3caf688d@app.fastmail.com>
2024-08-25  5:55                     ` Eli Zaretskii
2024-08-25 18:50                       ` Jim Porter
2024-08-25 20:58                         ` Mark Hepburn

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=418fb258-c318-9aa2-8bd1-73b34611fb32@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=72681@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mark@markhepburn.com \
    /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 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).