0

I noticed an annoying behaviour when copying multiple rows (a list) from a web page into an org-mode table, following a process inspired by Is it possible to copy /paste multiple lines of text into cells of org-mode table?.

The annoying result is that the table sides don't align properly, due to a TAB character being introduced during the process. Maybe I've discovered a bug or an undesired feature.

Note: It seems that using copy-rectangle-as-kill rather than kill-rectangle in the process prevents the TAB from appearing.

Reproducing the behaviour

Update: Reproduced in Emacs 26.3, but not fully in 27.1. If you have Docker installed you can test yourself using: docker run -it silex/emacs:26.3 emacs. For version 27.1, do docker run -it silex/emacs:27.1 emacs and note that when yanking, a TAB character is actually created/inserted after the A. However, when you then press C-c C-c the TAB is replaced with a suitable number of spaces.

Create an empty table and these lines of text (the number of characters matter):

|   |
|   |

A
12345678

Cut/kill the lines as a rectangle in exactly the following way:

  • Start rectangle-mark-mode (C-x SPC) with the cursor to the left of A
  • Use kill-rectangle (C-x r k) with the cursor to the right of 8

Yank rectangle into the table:

  • Place cursor on first row
  • Do yank-rectangle (C-x r y)

It should now look like this:

| A   |
| 12345678  |

There should be a TAB character after the A in the first row. With cursor in table, align borders using C-c C-c, giving:

| A  |
|  12345678 |

Oops, still unaligned.

Discussion

I suspect the misalignment is due to the TAB character. But to see the effect, you have to have the right number of characters on the second row. Repeating steps above on the following two lines of text produces an aligned table without a TAB character:

A
1234567

| A        |
| 1234567  |

Further, using copy-rectangle-as-kill (C-x r M-w) on the original two lines of text also did not result in a TAB character.

7
  • 1
    I can't replicate the "Oops, still unaligned." in Emacs 27.1 with its standard org version. It aligns it correctly. GNU Emacs 27.1, Org mode version 9.3.
    – phils
    Jan 9, 2021 at 0:13
  • Same here. I started Emacs 27.1 with emacs -Q and didn't get the "Oops, still unaligned." part. @chr could you please start Emacs by executing emacs -Q and tell us whether you still get the error?
    – doltes
    Jan 9, 2021 at 0:49
  • Hmm, this is weird. I am unable to replicate in a new Emacs. However, I can still replicate the behaviour in my old running instance of Emacs (version 26.3), that was started on 4th of January. The laptop has been up for 20 days. And I did mess a bit with the Emacs configuration relatively recently, e.g. pulling in new versions of 'org' and 'org-plus-contrib'. So I may well have done something to e.g. cause an invalid configuration. My apologies for not testing in a fresh Emacs before posting!
    – chr
    Jan 9, 2021 at 10:41
  • Ok, get's weirder... Turns out my original Emacs was started with 'emacs -q'. I don't remember why at all. However, if I start with emacs -q I can replicate the behaviour. I can also replicate the behaviour on another computer (also version 26.3). I also could replicate on a third computer. Could you please give it a try with '-q'? Note: Don't do my mistake an try and replicate with only '1234567', it needs eight characters on the second row.
    – chr
    Jan 9, 2021 at 10:49
  • Not sure what's going on. Just now I could reproduce it on version 26.3 using emacs -Q but not emacs. Using emacs -Q, the yank command inserts a TAB. Using emacs does not insert a TAB.
    – chr
    Jan 10, 2021 at 10:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.