emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Stefan-W. Hahn" <stefan.hahn@s-hahn.de>
To: emacs-orgmode@gnu.org
Subject: [RFC] Preserving text-properties when moving columns in org-table
Date: Tue, 6 Dec 2016 21:05:57 +0100	[thread overview]
Message-ID: <20161206200557.GA6980@seven> (raw)

Hello,

I'm using text-properties to mark special entries on org-tables.

When moving columns around in such a propertized table, the text-properties
got lost because moving around is realized with "replace-match", which does
not save the text-properties.

If replacing "replace-match" with "transpose-regions" the text-properties
of the text will be preserved.

The only thing I'm not sure about is if leaving markers, parameter
"leave-markers" of transpose-regions should be set.

#+BEGIN_SRC
modified   lisp/org-table.el
@@ -1494,7 +1494,9 @@ org-table-move-column
        (unless (org-at-table-hline-p)
 	 (org-table-goto-column col1 t)
 	 (when (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|")
-	   (replace-match "|\\2|\\1|")))
+           (transpose-regions
+            (match-beginning 1) (match-end 1)
+            (match-beginning 2) (match-end 2))))
        (forward-line)))
     (set-marker end nil)
     (org-table-goto-column colpos)
#+END_SRC

Moving rows with org-table-move-row preserves the text-properties and is
therefore ok.

With kind regards,
Stefan

-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

                 reply	other threads:[~2016-12-06 20:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20161206200557.GA6980@seven \
    --to=stefan.hahn@s-hahn.de \
    --cc=emacs-orgmode@gnu.org \
    /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/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 read-only IMAP folder(s) and NNTP newsgroup(s).