From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Sebold Subject: Patch for ob-sql.el SQL output Date: Tue, 21 Dec 2010 09:02:45 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=34244 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PV3jo-0002Ri-PK for emacs-orgmode@gnu.org; Tue, 21 Dec 2010 10:02:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PV3jk-0002qN-GJ for emacs-orgmode@gnu.org; Tue, 21 Dec 2010 10:02:49 -0500 Received: from mail-fx0-f48.google.com ([209.85.161.48]:57897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PV3jk-0002qA-Bi for emacs-orgmode@gnu.org; Tue, 21 Dec 2010 10:02:48 -0500 Received: by fxm2 with SMTP id 2so4004167fxm.35 for ; Tue, 21 Dec 2010 07:02:46 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode I use org-mode and babel under Windows with osql, and the line separating the header from the rest of the rows in the output was bothering me. I don't know that this is a really good fix, but maybe it's a start for one? I've filled out paperwork with FSF for copyright assignment. It looks for the first output line of all dashes and replaces it later with the 'hline when the table is lisp-ified. I didn't test this with mysql or postgresql. diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 5bb123d..13e9bd3 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -65,6 +65,7 @@ This function is called by `org-babel-execute-src-block'.= " =A0=A0 =A0 =A0 =A0 =A0(in-file (org-babel-temp-file "sql-in-")) =A0=A0 =A0 =A0 =A0 =A0(out-file (or (cdr (assoc :out-file params)) =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(org-babel-temp-file "sql= -out-"))) + =A0 =A0 =A0 =A0 (header-delim "") =A0=A0 =A0 =A0 =A0 =A0(command (case (intern engine) =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ('msosql (format "osql %s -s \"\= t\" -i %s -o %s" =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0(or cmdline "") @@ -84,9 +85,19 @@ This function is called by `org-babel-execute-src-block'= ." =A0=A0 =A0 (message command) =A0=A0 =A0 (shell-command command) =A0=A0 =A0 (with-temp-buffer + =A0 =A0 =A0; need to figure out what the delimiter is for the header row + =A0 =A0 =A0(with-temp-buffer + =A0 =A0 =A0 =A0(insert-file-contents out-file) + =A0 =A0 =A0 =A0(goto-char (point-min)) + =A0 =A0 =A0 =A0(when (re-search-forward "^\\(-+\\)$" nil t) + =A0 =A0 =A0 =A0 =A0(setq header-delim (match-string-no-properties 1)))) =A0=A0 =A0 =A0 (org-table-import out-file '(16)) =A0=A0 =A0 =A0 (org-babel-reassemble-table - =A0 =A0 =A0 (org-table-to-lisp) + =A0 =A0 =A0 (mapcar (lambda (x) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (string=3D (car x) header-delim) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'hline + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 x)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-table-to-lisp)) =A0=A0 =A0 =A0 =A0(org-babel-pick-name (cdr (assoc :colname-names params)) =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(cdr (assoc :coln= ames params))) =A0=A0 =A0 =A0 =A0(org-babel-pick-name (cdr (assoc :rowname-names params)) -- Charles Sebold Ego delendus sum