emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Marc-Oliver Ihm <marc-oliver.ihm@online.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] Code for simple set-operations on two tables. Asking for some input.
Date: Sun, 15 Jan 2012 09:10:13 -0700	[thread overview]
Message-ID: <87lip90wwq.fsf@gmx.com> (raw)
In-Reply-To: <4F114A8E.8070200@online.de> (Marc-Oliver Ihm's message of "Sat, 14 Jan 2012 10:27:42 +0100")

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 <marc-oliver.ihm@online.de> 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/

      reply	other threads:[~2012-01-15 16:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-26 11:00 [babel] Code for simple set-operations on two tables. Asking for some input Marc-Oliver Ihm
2011-12-27 20:53 ` Eric Schulte
2011-12-28  8:56   ` Marc-Oliver Ihm
2012-01-14  9:27   ` Marc-Oliver Ihm
2012-01-15 16:10     ` Eric Schulte [this message]

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=87lip90wwq.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=marc-oliver.ihm@online.de \
    /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).