From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Adamsky Subject: Remove empty rows in a org-table Date: Sun, 27 Oct 2013 10:59:15 +0100 Message-ID: <87y55fjaq4.fsf@voyager.lan> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VaN80-000751-4N for emacs-orgmode@gnu.org; Sun, 27 Oct 2013 05:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VaN7u-0005ZD-48 for emacs-orgmode@gnu.org; Sun, 27 Oct 2013 05:59:24 -0400 Received: from haktar.org ([46.38.251.222]:35342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VaN7t-0005Z5-Uk for emacs-orgmode@gnu.org; Sun, 27 Oct 2013 05:59:18 -0400 Received: from localhost (p579264D4.dip0.t-ipconnect.de [87.146.100.212]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cit) by haktar.org (Postfix) with ESMTPSA id 155E71A0727 for ; Sun, 27 Oct 2013 10:59:16 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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/