From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: [QUESTION] A decision about matching ob-sql.el's :engine header argument match sql-mode product name Date: Thu, 30 Jan 2020 14:21:30 +0800 Message-ID: <87tv4d5us5.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51881) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ix3Cw-0001iS-4c for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 01:21:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ix3Cu-0004L3-VQ for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 01:21:41 -0500 Received: from [183.246.143.250] (port=8400 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ix3Ct-0004HH-Pt for emacs-orgmode@gnu.org; Thu, 30 Jan 2020 01:21:40 -0500 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: Org Mode , Nicolas Goaziou 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 -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3