emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Xi Shen <davidshen84@gmail.com>
To: "emacs-orgmode@gnu.org" <Emacs-orgmode@gnu.org>
Subject: [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.
Date: Wed, 12 Apr 2017 03:16:29 +0000	[thread overview]
Message-ID: <CANO68EMbqp7Fes507gCnba1HZxV7FSe07HiuGmnJv0yWhZ=MYA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

Hi,

Regarding a patch I made early. Ref. title: [PATCH] ob-sql.el: Support
sqlcmd and cygwin environment.

I found it does not for Emacs for Windows. More generally, it does not work
in minGW or MSYS environments. I think it is because minGW is not a POSIX
environment, and applications in minGW can actually talk to Windows system
and handle Windows file path directly.

Because there's no official way to identify if Emacs is in minGW
environment, I must roll out cygwin environment first, then I test if it is
in "windows-nt" environment.

Please review the patch, and let me know if you have any comments/question.


Thanks,
David

[-- Attachment #1.2: Type: text/html, Size: 817 bytes --]

[-- Attachment #2: ob-sql.el.patch --]
[-- Type: application/octet-stream, Size: 1646 bytes --]

From 48d3193799fc0a6fab07c9e011d5acb63615bfe3 Mon Sep 17 00:00:00 2001
From: Xi Shen <davidshen84@gmail.com>
Date: Wed, 12 Apr 2017 10:23:45 +0800
Subject: [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.

(org-babel-sql-convert-standard-filename): If it is not in Cygwin
environment, and `system-nt' is "windows-nt", Emacs must be in minGW
or MSYS environment, can can handle Windows filename correctly.
---
 lisp/ob-sql.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index ec0427f..04f40d9 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -149,14 +149,14 @@ SQL Server on Windows and Linux platform."
 	      " "))
 
 (defun org-babel-sql-convert-standard-filename (file)
-  "Convert the file name to OS standard.
+  "Convert `FILE' to OS standard file path.
 If in Cygwin environment, uses Cygwin specific function to
-convert the file name. Otherwise, uses Emacs' standard conversion
-function."
-  (format "\"%s\""
-	  (if (fboundp 'cygwin-convert-file-name-to-windows)
-	      (cygwin-convert-file-name-to-windows file)
-	    (convert-standard-filename file))))
+convert the file name; if in `windows-nt' environment, do not
+convertthe `FILE' parameter.  Otherwise, uses Emacs' standard
+conversion function."
+  (cond ((fboundp 'cygwin-convert-file-name-to-windows) (format "\"%s\"" (cygwin-convert-file-name-to-windows file)))
+	((string= "windows-nt" system-type) file)
+	(t (format "\"%s\"" (convert-standard-filename file)))))
 
 (defun org-babel-execute:sql (body params)
   "Execute a block of Sql code with Babel.
-- 
2.10.0.windows.1


             reply	other threads:[~2017-04-12  3:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12  3:16 Xi Shen [this message]
2017-04-15  6:06 ` [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment Xi Shen
2017-04-16  7:25 ` Nicolas Goaziou

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='CANO68EMbqp7Fes507gCnba1HZxV7FSe07HiuGmnJv0yWhZ=MYA@mail.gmail.com' \
    --to=davidshen84@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).