unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Arthur Elsenaar <arthur@artelse.com>, 73882@debbugs.gnu.org
Subject: bug#73882: 31.0.50; global-visual-wrap-prefix-mode misaligns org tables
Date: Sat, 19 Oct 2024 16:14:48 -0700	[thread overview]
Message-ID: <b13ad319-dc5e-53ad-2378-d09f0e8f7ff2@gmail.com> (raw)
In-Reply-To: <57IhhRXkW76A6AfCCuAzPXZD5wAah3fV2P0gNIB6312oMAQMbi3iFL4Msyx5RaQqZmEEmaOJm8iWP3w5a0i7apxmpc8RScCpp7PXX7M5ik4=@artelse.com>

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

On 10/19/2024 2:52 AM, Arthur Elsenaar wrote:
> | head  | 1 | 2 | 3 | 4 |
> |-------+---+---+---+---|
> | apple |   |   |   |   |
> | orange |   |   |   |   |
> | pear  |   |   |   |   |
> | banana |   |   |   |   |
> 
> Table cells are misaligned.
> When one hits <tab> within a cell, the cells align. However when
> global-visual-wrap-prefix-mode is enabled, the cells get
> misaligned. It appears a character in the first column gets attributes
> added that makes the character span more than one space.

Thanks for noticing. This patch should do the trick, I think.

[-- Attachment #2: 0001-Fix-min-width-calculation-in-visual-wrap-prefix-mode.patch --]
[-- Type: text/plain, Size: 1515 bytes --]

From 727abc3fbb8d43de78a9acf47aa4fb3a97bbb21a Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 19 Oct 2024 16:12:43 -0700
Subject: [PATCH] Fix 'min-width' calculation in 'visual-wrap-prefix-mode'

* lisp/visual-wrap.el (visual-wrap--content-prefix): Remove 'min-width'
before computing the pixel width to avoid miscalculation (bug#73882).
---
 lisp/visual-wrap.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
index 76276c0f474..fa128d287a4 100644
--- a/lisp/visual-wrap.el
+++ b/lisp/visual-wrap.el
@@ -165,9 +165,12 @@ visual-wrap--content-prefix
     ;; first-line prefix.
     (let ((avg-space (propertize (buffer-substring position (1+ position))
                                  'display '(space :width 1))))
-        (max (string-width prefix)
-             (ceiling (string-pixel-width prefix (current-buffer))
-                      (string-pixel-width avg-space (current-buffer))))))))
+      ;; Remove any `min-width' display specs since we'll replace with
+      ;; our own later in `visual-wrap--apply-to-line' (bug#73882).
+      (add-display-text-property 0 (length prefix) 'min-width nil prefix)
+      (max (string-width prefix)
+           (ceiling (string-pixel-width prefix (current-buffer))
+                    (string-pixel-width avg-space (current-buffer))))))))
 
 (defun visual-wrap-fill-context-prefix (beg end)
   "Compute visual wrap prefix from text between BEG and END.
-- 
2.25.1


  reply	other threads:[~2024-10-19 23:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19  9:52 bug#73882: 31.0.50; global-visual-wrap-prefix-mode misaligns org tables Arthur Elsenaar
2024-10-19 23:14 ` Jim Porter [this message]
2024-10-20  4:31   ` Jim Porter

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=b13ad319-dc5e-53ad-2378-d09f0e8f7ff2@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=73882@debbugs.gnu.org \
    --cc=arthur@artelse.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).