emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tamas Papp <tkpapp@gmail.com>
To: emacs-orgmode@gnu.org
Subject: changing cells in an org-mode table with Emacs lisp
Date: Sat, 27 Dec 2014 17:37:22 +0100	[thread overview]
Message-ID: <87vbkxgibh.fsf@tamas.ihs.ac.at> (raw)

Hi,

I would like to manipulate cells in an org-mode table using Emacs lisp
code. Suppose I have a function (FORMAT-CELL CELL ROW COL) that takes a
cell (string), row and column numbers, and returns a new string if I
want to replace content in a cell, and NIL otherwise.

I need help with writing code that makes Emacs walk the table (all
cells), and then the new row when I insert a row (eg after capture).

For example, if my formatting function is

  (defun format-cell (cell row col)
    ;; toy example, actual code would be more complicated
    (when (<= (length cell) col)
      (concat "*" cell "*")))

then the table

| a   | a   |
| aa  | aa  |
| aaa | aaa |

would be replaced by

| *a* | *a*  |
| aa  | *aa* |
| aaa | aaa  |

I need the replacement in place, I don't want to make a new table. I
would like to re-align the table when done.

Any help with this would be appreciated, in particular, the names of the
functions that would help me get started, I could not figure this out.

Best,

Tamas

             reply	other threads:[~2014-12-27 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-27 16:37 Tamas Papp [this message]
2014-12-28 18:38 ` changing cells in an org-mode table with Emacs lisp Michael Brand

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=87vbkxgibh.fsf@tamas.ihs.ac.at \
    --to=tkpapp@gmail.com \
    --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).