emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [QUESTION] A decision about matching ob-sql.el's :engine header argument match sql-mode product name
Date: Thu, 30 Jan 2020 18:29:53 +1100	[thread overview]
Message-ID: <878slppfke.fsf@gmail.com> (raw)
In-Reply-To: <87tv4d5us5.fsf@gmail.com>


My vote would be to modify ob-sql and change the hard coded values into
a custom variable. Then users can add/remove/modify engine names to suit
their requirements. The default should probably match the product names
supported by sql.el (you could even have multiple entries mapping to the
same product name for backwards compatibility i.e. 'postgres' =>
'postgres', 'postgresql' => 'postgres' etc.). It would also be trivial
to then add new 'products' in the future.

stardiviner <numbchild@gmail.com> writes:

> I'm writing a patch which try to set ~sql-product~ when editing sql src block.
>
> Here is the code:
>
> #+begin_src emacs-lisp
> (defun org-babel-edit-prep:sql (info)
>   "Set `sql-product' in Org edit buffer.
> Set `sql-product' in Org edit buffer according to the
> corresponding :engine source block header argument."
>   (let ((product (cdr (assq :engine (nth 2 info)))))
>     (sql-set-product product)))
> #+end_src
>
> But =ob-sql.el= source code hardcoded ~:engine~ names which some are not matched
> with ~sql-product-alist~ in =sql-mode=. For example =:engine postgresql=, but it's
> ~postgres~ in ~sql-product-alist~.
>
> For now, I have two solutions:
>
> 1. write an adapter function which translate ~:engine~ header argument value into
>    ~sql-product-alist~ product names. This is a safe way, which will not
>    incompatiable with old Org document.
>
> 2. modify source code hardcoded ~:engine~ names (also need to update Org
>    document), this has a minor advantage is *consistance*.
>
> WDYT?
>
> BTW, about writing an adapter function to translate names. I want to hear some
> suggestion about use which method. Writing an hash map or assoc list etc?
>
> Regards


--
Tim Cross

  reply	other threads:[~2020-01-30  7:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30  6:21 [QUESTION] A decision about matching ob-sql.el's :engine header argument match sql-mode product name stardiviner
2020-01-30  7:29 ` Tim Cross [this message]
2020-01-30 12:32   ` stardiviner
2020-01-31 10:53     ` Bastien
2020-02-04 16:29       ` [PATCH] ob-sql.el support auto set sql-product in editing sql-mode src block buffer stardiviner
2020-02-05 15:46         ` stardiviner
2020-02-12  7:11         ` stardiviner
2020-02-12  8:06           ` Bastien
2020-02-12  8:41             ` [SOLVED] " stardiviner

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=878slppfke.fsf@gmail.com \
    --to=theophilusx@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).