emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: spectria@mail.com
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Bug: Unintended column added to table [9.4.6 (9.4.6-gab9f2a @ /home/user/.emacs.d/elpa/org-9.4.6/)]
Date: Sat, 02 Oct 2021 14:54:37 +0800	[thread overview]
Message-ID: <87v92fyl02.fsf@localhost> (raw)
In-Reply-To: <87lf4mhqfi.fsf@localhost>

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

Ihor Radchenko <yantar92@gmail.com> writes:

> spectria@mail.com writes:
>
>> In a preexisting org table, hitting <tab> can add a new, unintended column
>>
>> Bug: After the 2nd iteration, org adds a unintended new column. Further iteration adds more columns.
>
> Confirmed
>
> The problem appears somewhere inside org-table-justify-field-maybe

And here is the fix.

I am not familiar with org-table codebase, so feedback would be
appreciated.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-table.el-Do-not-create-new-field-when-at-EOL-aft.patch --]
[-- Type: text/x-diff, Size: 1221 bytes --]

From 36485b234d607be16cc06912dc85b9984a0142af Mon Sep 17 00:00:00 2001
Message-Id: <36485b234d607be16cc06912dc85b9984a0142af.1633157571.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 2 Oct 2021 14:44:30 +0800
Subject: [PATCH] org-table.el: Do not create new field when at EOL after table
 line

* lisp/org-table.el (org-table-justify-field-maybe): Do not treat "|$"
as unclosed table field.

Fixes https://orgmode.org/list/trinity-2561db57-1561-470b-982f-0d91ddf4f145-1629900012884@3c-app-mailcom-lxa06
---
 lisp/org-table.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 89c57fb06..e34872fb4 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -4436,7 +4436,7 @@ (defun org-table-justify-field-maybe (&optional new)
 	  (col (org-table-current-column)))
       (when (> col 0)
 	(skip-chars-backward "^|")
-	(if (not (looking-at " *\\([^|\n]*?\\) *\\(|\\|$\\)"))
+	(if (not (looking-at " *\\(?:\\([^|\n]*?\\) *\\(|\\)\\|\\([^|\n]+?\\) *\\($\\)\\)"))
 	    (setq org-table-may-need-update t)
 	  (let* ((align (nth (1- col) org-table-last-alignment))
 		 (width (nth (1- col) org-table-last-column-widths))
-- 
2.32.0


      parent reply	other threads:[~2021-10-02  6:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 14:00 spectria
2021-08-27 15:12 ` Ihor Radchenko
2021-08-31 10:12   ` Timothy
2021-10-02  6:54   ` Ihor Radchenko [this message]

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87v92fyl02.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=spectria@mail.com \
    --subject='Re: [PATCH] Bug: Unintended column added to table [9.4.6 (9.4.6-gab9f2a @ /home/user/.emacs.d/elpa/org-9.4.6/)]' \
    /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

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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 NNTP newsgroup(s).