From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Cross 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 Message-ID: <878slppfke.fsf@gmail.com> References: <87tv4d5us5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42401) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ix4H4-0003OD-8r for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 02:30:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ix4H2-0004sA-7T for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 02:30:01 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ix4H1-0004q9-VU for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 02:30:00 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9so998100plo.11 for ; Wed, 29 Jan 2020 23:29:59 -0800 (PST) Received: from tim-desktop (203-173-25-224.dyn.iinet.net.au. [203.173.25.224]) by smtp.gmail.com with ESMTPSA id 136sm4941190pgg.74.2020.01.29.23.29.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 23:29:57 -0800 (PST) In-reply-to: <87tv4d5us5.fsf@gmail.com> 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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 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