From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rolf Sander Subject: Re: Fwd: comment lines inside org tables Date: Fri, 30 Sep 2016 16:52:43 +0200 Message-ID: References: <74597925-06d8-c5a3-198c-cfaa1acedd57@mpic.de> <87fuol1swa.fsf@nicolasgoaziou.fr> <55425935-58dc-b2d3-5b96-ec44ccbdd939@mpic.de> <87bmz910up.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzBE-0001tZ-ON for emacs-orgmode@gnu.org; Fri, 30 Sep 2016 10:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpzBA-00089g-G3 for emacs-orgmode@gnu.org; Fri, 30 Sep 2016 10:52:51 -0400 Received: from mail.mpic.de ([192.67.218.51]:48380 helo=fw.mpic.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzBA-00087g-9C for emacs-orgmode@gnu.org; Fri, 30 Sep 2016 10:52:48 -0400 Received: from mail02.mpic.de ([10.20.0.121]:54772 helo=mail.mpic.de) by fw.mpic.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1bpzB6-00019B-0g for emacs-orgmode@gnu.org; Fri, 30 Sep 2016 16:52:44 +0200 In-Reply-To: <87bmz910up.fsf@nicolasgoaziou.fr> 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" To: emacs-orgmode@gnu.org Hello Nicolas, > Then I don't understand what you really want. You want to comment a > row, but it's not clear wrt to what action. I want to add a comment line into the file that does not disturb the table. Like a "|---+---+---|" hline. I don't want any action. All programming languages have the option to add comments to the source code. The comment does not trigger any action, and the result of executing the code is the same, whether with or without comment lines. It would be nice if org-tbl would allow comment lines as well. > Anyway, in the general case, there is no way to comment a row. Okay, so my question turns into a feature request now... I have started to modify defun org-table-align. With the modification, org-tbl now ignores all lines starting with "|-/". For me it works fine. However, please let me know if you see any side-effects. You can download the full defun here: http://www.rolf-sander.net/tmp/org-table-align-new.el And here is a diff to the original code: ******************************************************* diff -U 1 org-table-align-old.el org-table-align-new.el @@ -63,4 +63,12 @@ ;; At the same time, we remove trailing space. + (setq lines0 (mapcar (lambda (l) + (cond ((string-match "^ *|-" l) + nil) + ((string-match "[ \t]+$" l) + (substring l 0 (match-beginning 0))) + (t l)) + ) + lines)) (setq lines (mapcar (lambda (l) - (if (string-match "^ *|-" l) + (if (string-match "^ *|-\\($\\|[^/]\\)" l) nil @@ -74,3 +82,3 @@ (org-split-string l " *| *")) - (delq nil (copy-sequence lines)))) + (delq nil (copy-sequence lines0)))) ;; How many fields in the longest line? @@ -164,5 +172,9 @@ (lambda (l) - (if l (apply 'format rfmt - (append (pop fields) emptystrings)) - hfmt)) + (cond ((eq l nil) + hfmt) + ((string-match "^ *|-/" l) + (concat l "\n")) + (t + (apply 'format rfmt + (append (pop fields) emptystrings))))) lines "")) ******************************************************* Best regards Rolf -- ----------------------------------------------------------------------- Rolf Sander phone: [+49] 6131/305-4610 Max-Planck Institute of Chemistry email: rolf.sander@mpic.de PO Box 3060, 55020 Mainz, Germany homepage: www.rolf-sander.net ----------------------------------------------------------------------- www.atmospheric-chemistry-and-physics.net www.geoscientific-model-development.net -----------------------------------------------------------------------