emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.
@ 2017-04-12  3:16 Xi Shen
  2017-04-15  6:06 ` Xi Shen
  2017-04-16  7:25 ` Nicolas Goaziou
  0 siblings, 2 replies; 3+ messages in thread
From: Xi Shen @ 2017-04-12  3:16 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.
  2017-04-12  3:16 [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment Xi Shen
@ 2017-04-15  6:06 ` Xi Shen
  2017-04-16  7:25 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Xi Shen @ 2017-04-15  6:06 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

On Wed, Apr 12, 2017, 11:16 Xi Shen <davidshen84@gmail.com> wrote:

> 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 #2: Type: text/html, Size: 1111 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.
  2017-04-12  3:16 [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment Xi Shen
  2017-04-15  6:06 ` Xi Shen
@ 2017-04-16  7:25 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Goaziou @ 2017-04-16  7:25 UTC (permalink / raw)
  To: Xi Shen; +Cc: emacs-orgmode@gnu.org

Hello,

Xi Shen <davidshen84@gmail.com> writes:

> 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.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-16  7:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12  3:16 [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment Xi Shen
2017-04-15  6:06 ` Xi Shen
2017-04-16  7:25 ` Nicolas Goaziou

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).