From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] Code for simple set-operations on two tables. Asking for some input. Date: Sun, 15 Jan 2012 09:10:13 -0700 Message-ID: <87lip90wwq.fsf@gmx.com> References: <87sjk5ka7s.fsf@gmx.com> <4F114A8E.8070200@online.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmSey-0006aW-U1 for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 11:10:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmSex-00036k-KT for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 11:10:20 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:52113 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RmSex-00036g-FE for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 11:10:19 -0500 In-Reply-To: <4F114A8E.8070200@online.de> (Marc-Oliver Ihm's message of "Sat, 14 Jan 2012 10:27:42 +0100") 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: Marc-Oliver Ihm Cc: emacs-orgmode@gnu.org Hi Marc-Oliver, I would recommend two small coding style points for writing lisp code (especially for inclusion into the library of babel). 1. You *never* want to leave trailing ")"'s on a line by themselves, but rather you should always stack these, indentation is used to visually identify nesting in lisp. e.g., this (defun lob-table-operations-filter (what table filter) "Internal function for table-operations in orgmodes library of babel" (let (keys result) (setq keys (mapcar 'car filter)) (dolist (line table) (if (equal (not (not (member (car line) keys))) (equal what 'keep)) (setq result (cons line result)) ) ) (nreverse result) ) ) should be (defun lob-table-operations-filter (what table filter) "Internal function for table-operations in orgmodes library of babel" (let (keys result) (setq keys (mapcar 'car filter)) (dolist (line table) (when (equal (not (not (member (car line) keys))) (equal what 'keep)) (setq result (cons line result)))) (nreverse result))) Using `paredit-mode' makes this behavior very easy to maintain. This point is true for any lisp coding (not just in the library of babel). 2. When writing code for the library of babel, please try to keep all lines <= 79 characters long. I like to use [1] to identify overlong lines by adding the following to my .emacs (require 'column-marker) (add-hook 'emacs-lisp-mode-hook (lambda () (column-marker-3 80))) Also, two non-style suggestions; 1. If you set "results" to "silent" as a subtree property in your "Internals" subtree you won't have to remove empty results. 2. In one function you save many functions into local variables and then call them using funcall, it may be simpler to use flet to define local functions which can then be called directly. I'm very pleased to hear that you're enjoying babel, and look forward to your contribution to the library of babel. Cheers, Marc-Oliver Ihm writes: > Hello, > > please find attached an early draft of lob-table-operations.org. > > It already has a reasonable documentation and working examples, so it > should be easy to play with. > > Some features are still missing (e.g. handling of column names and hlines) > and the coding needs some improvement (using the cl-package ?). > So it is probably not yet fit for official inclusion into the library of babel. > > with kind regards, > Marc-Oliver Ihm > > As a side note: I am very pleased and fascinated, how easily babel and > org have made the task of keeping together > all aspects of development; from user documentation to implementation > and (of course !) organisation. > > This has made my coding even more fun ! > > Footnotes: [1] http://www.emacswiki.org/emacs/ColumnMarker -- Eric Schulte http://cs.unm.edu/~eschulte/