From: Florian Adamsky <fa-orgmode@haktar.org>
To: emacs-orgmode@gnu.org
Subject: Remove empty rows in a org-table
Date: Sun, 27 Oct 2013 10:59:15 +0100 [thread overview]
Message-ID: <87y55fjaq4.fsf@voyager.lan> (raw)
Dear org-mode hackers,
in a org-mode file I copy various information to a org-table. Sometimes
there are empty rows in that org-table which I don't like. Therefore I
wrote a little function that removes empty rows from a org-mode table.
Maybe this is of any for org-mode or for other people. I would like to
hear of any improvements or better ways to do this. Maybe this already
exists in org-mode somewhere? :-)
#+BEGIN_SRC emacs-lisp
(defun fa/org-table-remove-empty-rows ()
"Removes empty rows in a org-mode table."
(interactive)
(save-excursion
(unless (org-table-p)
(error
"You are not in an org-table."))
(goto-char (org-table-begin))
(let ((tbl-list (org-table-to-lisp)))
(while
(let ((row-list (car tbl-list)))
(cond ((and
(listp row-list)
(equal row-list (make-list (length row-list)
(string))))
(kill-line)
(kill-line))
(t (next-line)))
(setq tbl-list (cdr tbl-list)))))))
#+END_SRC
This functions does the following:
|------+------+-----| |------+------+-----|
| test | foo | bar | | test | foo | bar |
|------+------+-----| |------+------+-----|
| 1 | 2 | 3 | | 1 | 2 | 3 |
| | | | | 4 | | 6 |
| 4 | | 6 | --> | | test | bla |
| | | | |------+------+-----|
| | test | bla | | | 2 | 4 |
|------+------+-----| |------+------+-----|
| | | |
| | 2 | 4 |
|------+------+-----|
--
Florian Adamsky
http://florian.adamsky.it/
reply other threads:[~2013-10-27 9:59 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=87y55fjaq4.fsf@voyager.lan \
--to=fa-orgmode@haktar.org \
--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).