Re: [O] Is it possible to pass variable to variables of src block?

2017-12-11 Thread Xi Shen
Hi Michael,

Yes, I think this is a way to my previous question. But what I really want
to achieve is to loop through a list of server names and execute a script
on them.

Say I have 20 different database server. How can I do a loop with each
server?


Regards,
David


On Wed, Dec 6, 2017 at 5:34 PM Michael Welle <mwe012...@gmx.net> wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > Hi,
> >
> > http://orgmode.org/manual/var.html
> >
> > This wiki explains how to use variable inside a src block. But I wonder
> if
> > it is possible to specify variable to the variables in the src
> definition.
> >
> > E.g. for the sql src block, I want to execute a script on different
> server.
> > I want to define a variable for the ":dbhost" variable.
> did you think about something like this?
>
>
> (setq hmw/dbhost "db1")
>
> #+BEGIN_SRC sql :dbhost (symbol-value 'hmw/dbhost) :dbuser weather
> :database environment :engine postgresql
> select time, temperature from weather limit 20;
> #+END_SRC
>
> Regards
> hmw
>
>


[O] Is it possible to pass variable to variables of src block?

2017-12-04 Thread Xi Shen
Hi,

http://orgmode.org/manual/var.html

This wiki explains how to use variable inside a src block. But I wonder if
it is possible to specify variable to the variables in the src definition.

E.g. for the sql src block, I want to execute a script on different server.
I want to define a variable for the ":dbhost" variable.


Regards,
David


Re: [O] org-capture-expand-file: Invalid file location: nil

2017-11-04 Thread Xi Shen
Hi Nicolas,

Sorry, I missed this one.

(global-set-key (kbd "C-c c") 'org-capture)

OK, thanks for the tip. The problem lies in the "org-capture-templates"
settings. I think in the past, it accept a "nil" argument. Now it expects
an empty string. Replacing nil with empty string solves my problem.


Regards,
David


On Sun, Nov 5, 2017 at 5:23 AM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > When I do C-c c, I got an error:
>
> I don't see any "c" template in your `org-capture-templates'.
>
> > org-capture-expand-file: Invalid file location: nil
> >
> > But (org-capture-expand-file "") returns the expected value. And the file
> > does exist. But (org-capture-expand-file nil) raise an error.
>
> This seems expected according to the docstring.
>
> > So I guess the function was given an erroneous value.
> >
> > My relevant settings are:
> >
> > (org-capture-templates
> >(quote
> > (("t" "Task" entry
> >   (file+headline nil "Tasks")
> >   "* TODO %? %^g")
> >  ("q" "Quick note" entry
> >   (file+datetree nil)
> >   "* [%<%H:%M>] %?"
>
> Have you tried to specify an actual filename, or the empty string,
> instead of using nil? Both `file+headline' and `file+datetree' expect
> some file to operate on.
>
> Regards,
>
> --
> Nicolas Goaziou
>


[O] org-capture-expand-file: Invalid file location: nil

2017-11-04 Thread Xi Shen
Hi,

When I do C-c c, I got an error:

org-capture-expand-file: Invalid file location: nil

But (org-capture-expand-file "") returns the expected value. And the file
does exist. But (org-capture-expand-file nil) raise an error. So I guess
the function was given an erroneous value.

My relevant settings are:

(org-capture-templates
   (quote
(("t" "Task" entry
  (file+headline nil "Tasks")
  "* TODO %? %^g")
 ("q" "Quick note" entry
  (file+datetree nil)
  "* [%<%H:%M>] %?"

(setq org-default-notes-file (concat org-directory "/.notes"))

I did not change my configurations for a long time. Maybe some of them are
outdated?


Thanks,
David


[O] ob-sclang.el error on Windows 10 64 bit

2017-09-29 Thread Xi Shen
Hi,

I have seeing this error many times when I update org-plus-contrib package
on Emacs for Windows.

ob-sclang.el:63:1:Error: Cannot open load file: No such file or
directory, sclang-interp

So far, nothing breaks, because I do not use anything related to
ob-sclang.el.

The error is caused by (require 'sclang-interp) which is referring to a
package I do not have on my system.


Thanks,
David


Re: [O] [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.

2017-04-15 Thread Xi Shen
On Wed, Apr 12, 2017, 11:16 Xi Shen <davidshe...@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
>
>


[O] [PATCH] lisp/ob-sql.el: Fix filename conversion in minGW environment.

2017-04-11 Thread Xi Shen
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


ob-sql.el.patch
Description: Binary data


Re: [O] How to use org mode shell with ssh?

2016-09-23 Thread Xi Shen
I got it :)

After reading
http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/ob-shell.el#n57, I found
I can simply specify the shell name in the block.


On Fri, Sep 23, 2016 at 6:50 PM Fabrice Popineau <
fabrice.popin...@centralesupelec.fr> wrote:

> 2016-09-23 10:32 GMT+02:00 Xi Shen <davidshe...@gmail.com>:
>
>> Hi,
>>
>> On my Windows system, I have Cygwin setup, with Emacs as part of the
>> Cygwin installation.
>>
>
> Cygwin Emacs is not a native Emacs (AFAIK). The difference is in the way
> it groks pathnames
> and other stuff like the default shell.
>
> I also setup my Cygwin environment to use zsh. I started my Emacs from
>> this zsh environment. I think that's where org inherited this setting.
>>
>> I think when org execute my block, it some how assumed that it should use
>> the same shell at the remote end.
>>
>
> The portion of code I pointed out does not make sense to me and it may be
> responsible for your problem.
>
> Fabrice
>
-- 


Thanks,
David S.


Re: [O] How to use org mode shell with ssh?

2016-09-23 Thread Xi Shen
Hi,

On my Windows system, I have Cygwin setup, with Emacs as part of the Cygwin
installation. I also setup my Cygwin environment to use zsh. I started my
Emacs from this zsh environment. I think that's where org inherited this
setting.

I think when org execute my block, it some how assumed that it should use
the same shell at the remote end.

P.S. OpenWRT is the router OS. It is just a tiny Linux. Most people would
not install zsh on it :P


On Fri, Sep 23, 2016 at 4:35 AM Fabrice Popineau <
fabrice.popin...@supelec.fr> wrote:

> My $0.02
>
> As I'm using Emacs on Windows, with MSYS2+MingW64, I tried this.
> There is a problem with using bash from a _native_ MingW64 Emacs:
> bash is a MSYS2 app and Emacs is a MingW64 app.
>
> From emacs, I would have used the plink protocol, so that's what I did.
> And I got this message in the *Org-Babel Error Output* buffer
>
> /bin/sh: 1: C:/Local/Emacs/bin/cmdproxy.exe: not found
>
> So I looked at ob-eval.el and the org-babel-eval function.
> And there are at least 2 big problems.
> 1- when entering this function, the `command' parameter is
> "C:/Local/Emacs/bin/cmdproxy.exe"
> 2 - the `shell-file-name' variable has the same value
> So the following won't work for Windows :
> ;; Unfortunately, `executable-find' does not support file name
> ;; handlers.  Therefore, we could use it in the local case
> ;; only.
> (shell-file-name
> (cond ((and (not (file-remote-p default-directory))
> (executable-find shell-file-name))
> shell-file-name)
>   ((file-executable-p
> (concat (file-remote-p default-directory) shell-file-name))
> shell-file-name)
>   ("/bin/sh")))
>
> BTW I don't see the point concatenating shell-file-name with
> default-directory when the later is remote.
> Do we expect to find the shell in the remote directory ?
>
> Anyway, there is little chance this stuff will work under Windows with a
> native Emacs.
> If I find time, I may try to propose some fix.
>
> Fabrice
>
>
> 2016-09-22 16:52 GMT+02:00 Nick Dokos :
>
>> Colin Baxter  writes:
>>
>>
>> >> #+BEGIN_SRC shell :dir /scp:openwrt:/mnt/sda1
>> >> ls -al
>> >> #+END_SRC
>> >>
>> >> The error, I think, is from the remote end.
>> >>
>> >> /bin/sh: /bin/zsh: not found
>> >>
>> >> Clearly, I am using zsh on my Windows, but my remote OpenWRT system
>> only has ash installed. Is
>> >> there's way to specify the shell to use on the remote end?
>> >>
>> >
>> > I can't help you here. I've never used openwrt. All I can suggest is to
>> > search openwrt documentation or try with cgywin.
>> >
>>
>> IIUC, openwrt is the name of the remote node - nothing to do with OpenWrt
>> (except of course, that
>> the remote node may be a router which has been flashed with OpenWrt, but
>> that should make no
>> difference to ssh/tramp).
>>
>> --
>> Nick
>>
>>
>>
>
>
> --
> Fabrice Popineau
> -
> SUPELEC
> Département Informatique
> 3, rue Joliot Curie
> 91192 Gif/Yvette Cedex
> Tel direct : +33 (0) 169851950
> Standard : +33 (0) 169851212
> --
>
> --


Thanks,
David S.


Re: [O] How to use org mode shell with ssh?

2016-09-22 Thread Xi Shen
Instead of using ssh, I tried with scp. This time I got a different error.

#+BEGIN_SRC shell :dir /scp:openwrt:/mnt/sda1
ls -al
#+END_SRC

The error, I think, is from the remote end.

/bin/sh: /bin/zsh: not found

Clearly, I am using zsh on my Windows, but my remote OpenWRT system only
has ash installed. Is there's way to specify the shell to use on the remote
end?


On Thu, Sep 22, 2016 at 8:15 PM Xi Shen <davidshe...@gmail.com> wrote:

> Hi,
>
> I just tried with:
>
> #+BEGIN_SRC shell :dir /ssh:openwrt:/mnt/sda1
> ls -al
> #+END_SRC
>
> But still got the same error. I wonder on which end threw me this error.
> Maybe it is because I am using Emacs on Windows, and some thing is missing?
> Or maybe it is because the remote system is OpenWRT which has limited
> function?
>
>
> On Thu, Sep 22, 2016 at 4:57 PM Colin Baxter <m43...@yandex.com> wrote:
>
>> On Wed, Sep 21 2016, William Denton wrote:
>>
>> > On 22 September 2016, Xi Shen wrote:
>> >
>> >> #+BEGIN_SRC sh :dir /sshx:openwrt:/mnt/sda1
>> >> ls -al
>> >> #+END_SRC
>> >
>> > Just use ssh, not sshx, and it should work.
>> >
>> > Bill
>>
>> In babel it is now (shell . t). The form (sh . t) is depreciated as from
>> org-mode version 8.2.10 at least.
>>
>> Best wishes.
>>
> --
>
>
> Thanks,
> David S.
>
-- 


Thanks,
David S.


Re: [O] How to use org mode shell with ssh?

2016-09-22 Thread Xi Shen
Hi,

I just tried with:

#+BEGIN_SRC shell :dir /ssh:openwrt:/mnt/sda1
ls -al
#+END_SRC

But still got the same error. I wonder on which end threw me this error.
Maybe it is because I am using Emacs on Windows, and some thing is missing?
Or maybe it is because the remote system is OpenWRT which has limited
function?


On Thu, Sep 22, 2016 at 4:57 PM Colin Baxter <m43...@yandex.com> wrote:

> On Wed, Sep 21 2016, William Denton wrote:
>
> > On 22 September 2016, Xi Shen wrote:
> >
> >> #+BEGIN_SRC sh :dir /sshx:openwrt:/mnt/sda1
> >> ls -al
> >> #+END_SRC
> >
> > Just use ssh, not sshx, and it should work.
> >
> > Bill
>
> In babel it is now (shell . t). The form (sh . t) is depreciated as from
> org-mode version 8.2.10 at least.
>
> Best wishes.
>
-- 


Thanks,
David S.


[O] How to use org mode shell with ssh?

2016-09-21 Thread Xi Shen
Hi,

I tried this block

#+BEGIN_SRC sh :dir /sshx:openwrt:/mnt/sda1
ls -al
#+END_SRC

But I got

byte-code: Method `sshx' should specify both encoding and decoding command
or an scp program

But I could not find a way to define the encoding/decoding command...
-- 


Thanks,
David S.


[O] Can I quote/ref value in the output table?

2016-07-12 Thread Xi Shen
Hi,

Say I have a sql babel block which outputs a table. Is there any way
that I can reference the values in the output table in another babel
block?



Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-07-04 Thread Xi Shen
Hello Nicolas,

I saw my patch in the master for a while, but I still cannot get the
change from `org-plus-contrib' package...I have to manually patch it
on my local which is not very convenient. When could I expect my patch
release in the `org-plus-contrib' package?


Thanks,
David

On Mon, Jun 20, 2016 at 8:34 PM Xi Shen <davidshe...@gmail.com> wrote:
>
> Thanks Nicolas! I will consider to sign FSF the next time :)
>
>
> On Fri, Jun 17, 2016 at 6:29 AM Nicolas Goaziou <m...@nicolasgoaziou.fr> 
> wrote:
>>
>> Hello,
>>
>> Xi Shen <davidshe...@gmail.com> writes:
>>
>> > Please take a look at the updated patch. Changes:
>> >
>> > - add ORG-NEWS entry
>> > - add function declaration
>> > - add input file template for `mssql' engine to remove the "affected rows"
>> > tail
>>
>> Applied. Thank you.
>>
>> Please consider signing FSF papers if you want to contribute more to
>> Org.
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou
>
> --
>
>
> Thanks,
> David S.



[O] dbus-error with org-notify

2016-06-28 Thread Xi Shen
Hi,

I am using Emacs within a Cygwin environment on Windows 7 64bit. I have
install the dbus Windows service with "messagebus-config", and started the
service from Windows service console.

After I called (org-notify-start), I got below Message before my task
deadline:

Warning: notification for "check org-notify" behind schedule!
Error: (dbus-error "No connection to bus" :session) [2 times]
Warning: notification for "check org-notify" behind schedule!
Error: (dbus-error "No connection to bus" :session)
...

In eLisp, if I call (dbus-init-bus :session), I got "dbus-init-bus: D-Bus
error: "No connection to bus", :session"; if I call (dbus-init-bus
:system), I got ((:signal :system "org.freedesktop.DBus.Local"
"Disconnected") (nil "/org/freedesktop/DBus/Local"
dbus-handle-bus-disconnect)).

Does it means I have a system dbus, but no session dbus? Which dbus should
Emacs/org-notify use?


Thanks,
David


Re: [O] Does org-nofity uses dbus?

2016-06-23 Thread Xi Shen
I also think it is a good idea to add some functions in Emacs for Win32
platform, and let other's used those functions from elisp. Thanks~

On Thu, Jun 23, 2016 at 1:02 AM Fabrice Popineau <fabrice.popin...@gmail.com>
wrote:

> 2016-06-22 14:16 GMT+02:00 Xi Shen <davidshe...@gmail.com>:
>
>> Well~that's good news. But I think dbus requires X11 to work. But in
>> Cygwin environment, people usually do not configure a full X11 environment.
>>
>
> No, dbus doesn't require X11 to work. Neither does emacs require  Cygwin
> to work.
> Actually, Emacs compiles as a native Windows application (using MinGW32 or
> MinGW64) and it is also the case of dbus.
>
>
>> Besides, for org-notify, could dbus help it playing a notification sound
>> on Windows? Or popup a notification message?
>>
>>
> I guess it will work the same way it does elsewhere.
>
>
>
>> So what I am thinking is to get some Windows native behavior for
>> org-notify on Windows/Cygwin environment.
>>
>>
> I too think that a native, session only module that will provide the same
> interface as dbus could be interesting
> for Windows users. However, that shouldn't prevent those who want to use
> dbus to use it.
>
> AFAIU, using dbus, you could have a distant running emacs (ssh) session
> and get notifications on your local desktop,
> provided the right setup.
>
> Well, browsing the source code, I see that Eli Zaretskii has already
> implemented native win32 tray notifications.
> They are a small subset of the dbus notifications.
> However, he made them exclusive with dbus. I don't see the reason yet.
>
> Fabrice
>
-- 


Thanks,
David S.


Re: [O] Does org-nofity uses dbus?

2016-06-22 Thread Xi Shen
Well~that's good news. But I think dbus requires X11 to work. But in Cygwin
environment, people usually do not configure a full X11 environment.

Besides, for org-notify, could dbus help it playing a notification sound on
Windows? Or popup a notification message?

So what I am thinking is to get some Windows native behavior for org-notify
on Windows/Cygwin environment.


On Tue, Jun 21, 2016 at 10:25 PM Fabrice Popineau <
fabrice.popin...@centralesupelec.fr> wrote:

>
> Le 21 juin 2016 16:14, "Xi Shen" <davidshe...@gmail.com> a écrit :
> >
> > Yeah...getting dbus to work on Windows will be hard.
>
> Actually, not so much. Dbus does work on windows. It doesn't work right
> now on emacs. I'm looking into it.
>
> Fabrice
>
-- 


Thanks,
David S.


Re: [O] Does org-nofity uses dbus?

2016-06-21 Thread Xi Shen
Yeah...getting dbus to work on Windows will be hard. Maybe we should
consider using some other ways to display a notification on Windows.

E.g. On Windows/Cygwin environment, org-notify should use a command line
tool to show a notification in the Windows notification area.

But I wonder how to deploy this command line tool with Emacs system...any
suggestions/ideas?


Thanks,
David


On Tue, Jun 21, 2016 at 4:45 PM Fabrice Popineau <
fabrice.popin...@supelec.fr> wrote:

> 2016-06-21 8:31 GMT+02:00 Xi Shen <davidshe...@gmail.com>:
>
>> Hi,
>>
>> I got below error after I called (org-notify-start). It seems the
>> dbus-error happens very close to the task notification. I wonder if
>> org-notify uses dbus.
>>
>> Error: (dbus-error "No connection to bus" :session)
>> Warning: notification for "Go to dental in 30 mins." behind schedule!
>> Error: (dbus-error "No connection to bus" :session) [2 times]
>> Warning: notification for "Go to dental in 30 mins." behind schedule!
>> Error: (dbus-error "No connection to bus" :session) [2 times]
>>
>> I am using Emacs on Windows, and there's no dbus on Windows...
>>
>>
> It seems so, yes: org-notify calls notifications-notify from the emacs
> notifications.el library.
> Clearly, notifications.el relies on dbus.
>
> However, if you are using Mingw64, there is a dbus package which should
> provide
> what is needed. Unfortunately, I tried it and can't tell yet how to
> configure it or if it
> even works.
>
>
> Fabrice
>
> --


Thanks,
David S.


[O] Does org-nofity uses dbus?

2016-06-21 Thread Xi Shen
Hi,

I got below error after I called (org-notify-start). It seems the
dbus-error happens very close to the task notification. I wonder if
org-notify uses dbus.

Error: (dbus-error "No connection to bus" :session)
Warning: notification for "Go to dental in 30 mins." behind schedule!
Error: (dbus-error "No connection to bus" :session) [2 times]
Warning: notification for "Go to dental in 30 mins." behind schedule!
Error: (dbus-error "No connection to bus" :session) [2 times]

I am using Emacs on Windows, and there's no dbus on Windows...


Thanks,
David

-- 


Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-20 Thread Xi Shen
Thanks Nicolas! I will consider to sign FSF the next time :)


On Fri, Jun 17, 2016 at 6:29 AM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > Please take a look at the updated patch. Changes:
> >
> > - add ORG-NEWS entry
> > - add function declaration
> > - add input file template for `mssql' engine to remove the "affected
> rows"
> > tail
>
> Applied. Thank you.
>
> Please consider signing FSF papers if you want to contribute more to
> Org.
>
> Regards,
>
> --
> Nicolas Goaziou
>
-- 


Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-16 Thread Xi Shen
Hi Nicolas,

Please take a look at the updated patch. Changes:

- add ORG-NEWS entry
- add function declaration
- add input file template for `mssql' engine to remove the "affected rows"
tail


On Thu, Jun 16, 2016 at 12:49 AM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > I suppose I should put the news entry to ./etc/ORG-NEWS file, but into
> > which version? I created below entry, please take look and let me know
> > where do you want me to put it.
>
> I'd say
>
>   Version 9.0 > New features > Babel
>
> or
>
>   Version 9.0 > Miscellaneous
>
> > *** Improved support to Microsoft SQL Server in =ob-sql.el=
> > =ob-sql.el= library removes support to the ~msosql~ engine which uses
> > the deprecated =osql= command line tool, and replaces it with ~mssql~
> > engine which uses the =sqlcmd= command line tool.  Use with properties
> > like this:
> >
> > #+BEGIN_EXAMPLE
> >  :engine mssql
> >  :dbhost 
> >  :dbuser 
> >  :dbpassword 
> >  :database 
> > #+END_EXAMPLE
> >
> > If you want to use the *trusted connection* feature, omit *both* the
> > =dbuser= and =dbpassword= properties and add =cmdline -E= to the
> > properties.
> >
> > If your Emacs is running in a Cygwin environment, the =ob-sql.el=
> > library can pass the converted path to the =sqlcmd= tool.
>
> It looks good.
>
> > I checked the code and it does not quote the arguments for me. It is a
> safe
> > manner in Windows to always quote the path. So I will keep it.
>
> Fair enough.
>
> > I have a question. Currently the table generated by mssql engine has the
> > "affected rows" append to the end, like this.
> >
> >   |  memberid | username | xx   | flags |
> >   |---+--+--+---|
> >   | 1 | GPL  | Indo | NULL  |
> >   | 2 | GPL  | Indo | NULL  |
> >   |   |  |  |   |
> >   | (2 rows affected) |  |  |   |
> >
> > I personally prefer to remove it. Do you or the org community has a
> > preference about this? Maybe I should keep the behavior align with other
> > engines?
>
> I lean towards removing it, too. I doesn't give useful feedback. We can
> always insert it back later if it introduces unwanted side-effects.
>
>
> Thank you.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>
-- 


Thanks,
David S.


0001-ob-sql.el-Support-sqlcmd-in-Cygwin-environment.patch
Description: Binary data


[O] Does org-notify work on Windows?

2016-06-15 Thread Xi Shen
Hi,

I am using Emacs in a Cygwin environment on Windows 7. I installed the
latest org from http://orgmode.org/elpa/.

I added (org-notify-start) in my .emacs file, and added some tasks. I can
see the tasks in my org-agenda, but I never got any notification.

I want to know if it is expected to work on Windows. What would be the
expected behavior if a notification breaks? Would I see a message, or a pop
up windows?

-- 


Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-14 Thread Xi Shen
Hi Nicolas,

I suppose I should put the news entry to ./etc/ORG-NEWS file, but into
which version? I created below entry, please take look and let me know
where do you want me to put it.

*** Improved support to Microsoft SQL Server in =ob-sql.el=
=ob-sql.el= library removes support to the ~msosql~ engine which uses
the deprecated =osql= command line tool, and replaces it with ~mssql~
engine which uses the =sqlcmd= command line tool.  Use with properties
like this:

#+BEGIN_EXAMPLE
 :engine mssql
 :dbhost 
 :dbuser 
 :dbpassword 
 :database 
#+END_EXAMPLE

If you want to use the *trusted connection* feature, omit *both* the
=dbuser= and =dbpassword= properties and add =cmdline -E= to the
properties.

If your Emacs is running in a Cygwin environment, the =ob-sql.el=
library can pass the converted path to the =sqlcmd= tool.

I checked the code and it does not quote the arguments for me. It is a safe
manner in Windows to always quote the path. So I will keep it.

I have a question. Currently the table generated by mssql engine has the
"affected rows" append to the end, like this.

  |  memberid | username | xx   | flags |
  |---+--+--+---|
  | 1 | GPL  | Indo | NULL  |
  | 2 | GPL  | Indo | NULL  |
  |   |  |  |   |
  | (2 rows affected) |  |  |   |

I personally prefer to remove it. Do you or the org community has a
preference about this? Maybe I should keep the behavior align with other
engines?


On Tue, Jun 14, 2016 at 9:02 PM Xi Shen <davidshe...@gmail.com> wrote:

> Hi Nicholas,
>
> Sure, I will add the news and declaration.
>
> The "format" is required to quote the filename, so the spaces won't
> surprise sqlcmd. Maybe the arguments will be quoted when passing to the
> command?
>
> On Tue, Jun 14, 2016, 19:52 Nicolas Goaziou <m...@nicolasgoaziou.fr>
> wrote:
>
>> Hello,
>>
>> Xi Shen <davidshe...@gmail.com> writes:
>>
>> > I think I uploaded the wrong patch. Sorry~ Please check this one.
>>
>> It looks good. Thank you. I have one minor comment about it, see below.
>>
>> Also, could you provide an entry for ORG-NEWS since this is a user
>> visible change?
>>
>> > +(defun org-babel-sql-convert-standard-filename (file)
>> > +  "Convert the file name to OS standard.
>> > +In Cygwin environment, is uses Cygwin specific function to
>> > +convert the file name and double quote it. Otherwise, uses Emacs
>> > +standard conversion function."
>> > +  (if (fboundp 'cygwin-convert-file-name-to-windows)
>> > +  (format "\"%s\"" (cygwin-convert-file-name-to-windows file))
>> > +(convert-standard-filename file)))
>>
>> `cygwin-convert-file-name-to-windows' is going to generate a compilation
>> warning. You need to declare it with `declare-function' at the top of
>> the file.
>>
>> I'm also surprised that the function above doesn't return a string
>> already. Are you sure the `format' part is needed?
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou
>>
> --
>
>
> Thanks,
> David S.
>
-- 


Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-14 Thread Xi Shen
Hi Nicholas,

Sure, I will add the news and declaration.

The "format" is required to quote the filename, so the spaces won't
surprise sqlcmd. Maybe the arguments will be quoted when passing to the
command?

On Tue, Jun 14, 2016, 19:52 Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > I think I uploaded the wrong patch. Sorry~ Please check this one.
>
> It looks good. Thank you. I have one minor comment about it, see below.
>
> Also, could you provide an entry for ORG-NEWS since this is a user
> visible change?
>
> > +(defun org-babel-sql-convert-standard-filename (file)
> > +  "Convert the file name to OS standard.
> > +In Cygwin environment, is uses Cygwin specific function to
> > +convert the file name and double quote it. Otherwise, uses Emacs
> > +standard conversion function."
> > +  (if (fboundp 'cygwin-convert-file-name-to-windows)
> > +  (format "\"%s\"" (cygwin-convert-file-name-to-windows file))
> > +(convert-standard-filename file)))
>
> `cygwin-convert-file-name-to-windows' is going to generate a compilation
> warning. You need to declare it with `declare-function' at the top of
> the file.
>
> I'm also surprised that the function above doesn't return a string
> already. Are you sure the `format' part is needed?
>
> Regards,
>
> --
> Nicolas Goaziou
>
-- 


Thanks,
David S.


[O] Bug? when add the first item using capture

2016-06-13 Thread Xi Shen
Hi,

This is my first time using org-capture. I am not sure if it is a bug, or I
made a mistake in the configuration.

Here's my settings for capture templates:

(setq org-capture-templates
  '(("t" "Task" entry (file+headline nil "Tasks")
"* TODO %? %^g")
("q" "Quick note" entry (file+headline nil "Quick Notes")
"* On %t %^g \n  %i%?")))

After I add the *first* "Quick note", and open my "notes.org", I saw
this...the "Quick Notes" section looks like merged with the next section.

[image: pasted1]

But if I close the file and open it again, everything looks fine.
-- 

Thanks,
David S.


Re: [O] Code in contrib directory is not published with ELPA?

2016-06-13 Thread Xi Shen
err~sorry!

http://orgmode.org/elpa.html

On Mon, Jun 13, 2016 at 5:19 PM Xi Shen <davidshe...@gmail.com> wrote:

> Hi,
>
> I am using Emacs on Windows within Cygwin environment. I found installing
> org from the ELPA will not include code in the `contrib' directory. Is it
> correct? What is the right way to get code in the `contrib' directory to
> work on my local?
>
> --
>
> Thanks,
> David S.
>
-- 

Thanks,
David S.


[O] Code in contrib directory is not published with ELPA?

2016-06-13 Thread Xi Shen
Hi,

I am using Emacs on Windows within Cygwin environment. I found installing
org from the ELPA will not include code in the `contrib' directory. Is it
correct? What is the right way to get code in the `contrib' directory to
work on my local?

-- 

Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-13 Thread Xi Shen
Hi Nicolas,

I think I uploaded the wrong patch. Sorry~ Please check this one.


On Mon, Jun 13, 2016 at 1:36 PM Xi Shen <davidshe...@gmail.com> wrote:

> Hi Nicolas,
>
> Please see my updated patch.
>
>
> On Sun, Jun 12, 2016 at 6:37 PM Xi Shen <davidshe...@gmail.com> wrote:
>
>> Hi Nicolas,
>>
>> So I will:
>>
>> - add "org-babel-sql-convert-filename", so another name...I am thinking
>> - remove `msosql` support. I am been playing with the options for a
>> while, and I could not find a way the make osql output the same format as
>> sqlcmd
>>
>>
>> Thanks,
>> David
>>
>>
>> On Sun, Jun 12, 2016 at 10:12 AM Xi Shen <davidshe...@gmail.com> wrote:
>>
>>> Yes, I think it is better to let upstream function to resolve the path
>>> for org-mode.
>>>
>>> But I have never contacted Emacs developers before. Should I go through
>>> the bug-gnu-em...@gnu.org mail list? Or there's a more effective
>>> channel?
>>>
>>>
>>> On Sat, Jun 11, 2016 at 4:41 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> Xi Shen <davidshe...@gmail.com> writes:
>>>>
>>>> > According to
>>>> >
>>>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html
>>>> ,
>>>> > the `convert-standard-filename` works for *nix and MS-DOS, but not
>>>> Cygwin
>>>> > environment. And I tested, it does not work. For the prefix, please
>>>> advice
>>>> > me a better one. Maybe we should path this function first? How can I
>>>> > patch/update a Emacs native function?
>>>>
>>>> Since there is no module in Emacs, you need to prefix functions and
>>>> variables according to the package, or, even better, the library they
>>>> belong to.
>>>>
>>>> Hence, functions and variables in "ob-sql.el" are prefixed with
>>>> "org-babel-sql-".
>>>>
>>>> Do you mind discussing it upstream on emacs-devel ML first? I don't
>>>> think this kind of function belongs to Org. If upstream has no
>>>> equivalent and doesn't want to add one, we might consider adding it to
>>>> the library.
>>>>
>>>> WDYT?
>>>>
>>>> >> > The `osql` command line tool was last updated in 2004,
>>>> >> >
>>>> https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx,
>>>> >> > and could not output the query result in a way that morden
>>>> >> > `org-table.el` expects.  The `sqlcmd` is the preferred command line
>>>> >> > tool to connect the Microsoft SQL Server and it also has a Linux
>>>> >> > version,
>>>> >> > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx.
>>>> >>
>>>> >> Would it make sense to remove the msosql support then?
>>>> >>
>>>> > Yes, but I am also thinking about backward compatibility. Do you want
>>>> > me to create a patch to remove `msosql` support?
>>>>
>>>> AFAIU, according to your comment, "osql" output is barely usable. If you
>>>> think it is still usable and even used by some users, then I do not mind
>>>> keeping it. I just wanted to be sure we're not keeping something that is
>>>> not reasonable to keep.
>>>>
>>>> >> #'identity
>>>> >>
>>>> >>
>>>> >>> OK, but what's the difference? Care to give me a short lesson?
>>>> >>>Thanks!
>>>>
>>>> Not much difference, hence the "nitpick" tag.
>>>>
>>>> 'identity is a generic symbol, #'identity clearly indicates we (the
>>>> user, the compiler) are interested in the symbol function cell.
>>>>
>>>> In this case, it is obvious, but it is not always the case in other
>>>> parts of the code base, and more consistency in the right direction
>>>> doesn't hurt.
>>>>
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> Nicolas Goaziou
>>>>
>>>>
>>>
>>> Thanks,
>>> David
>>>
>>> --
>>>
>>> Thanks,
>>> David S.
>>>
>> --
>>
>> Thanks,
>> David S.
>>
> --
>
> Thanks,
> David S.
>
-- 

Thanks,
David S.


0001-ob-sql.el-Support-sqlcmd-in-Cygwin-environment.patch
Description: Binary data


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-12 Thread Xi Shen
Hi Nicolas,

Please see my updated patch.


On Sun, Jun 12, 2016 at 6:37 PM Xi Shen <davidshe...@gmail.com> wrote:

> Hi Nicolas,
>
> So I will:
>
> - add "org-babel-sql-convert-filename", so another name...I am thinking
> - remove `msosql` support. I am been playing with the options for a while,
> and I could not find a way the make osql output the same format as sqlcmd
>
>
> Thanks,
> David
>
>
> On Sun, Jun 12, 2016 at 10:12 AM Xi Shen <davidshe...@gmail.com> wrote:
>
>> Yes, I think it is better to let upstream function to resolve the path
>> for org-mode.
>>
>> But I have never contacted Emacs developers before. Should I go through
>> the bug-gnu-em...@gnu.org mail list? Or there's a more effective channel?
>>
>>
>> On Sat, Jun 11, 2016 at 4:41 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
>> wrote:
>>
>>> Hello,
>>>
>>> Xi Shen <davidshe...@gmail.com> writes:
>>>
>>> > According to
>>> >
>>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html
>>> ,
>>> > the `convert-standard-filename` works for *nix and MS-DOS, but not
>>> Cygwin
>>> > environment. And I tested, it does not work. For the prefix, please
>>> advice
>>> > me a better one. Maybe we should path this function first? How can I
>>> > patch/update a Emacs native function?
>>>
>>> Since there is no module in Emacs, you need to prefix functions and
>>> variables according to the package, or, even better, the library they
>>> belong to.
>>>
>>> Hence, functions and variables in "ob-sql.el" are prefixed with
>>> "org-babel-sql-".
>>>
>>> Do you mind discussing it upstream on emacs-devel ML first? I don't
>>> think this kind of function belongs to Org. If upstream has no
>>> equivalent and doesn't want to add one, we might consider adding it to
>>> the library.
>>>
>>> WDYT?
>>>
>>> >> > The `osql` command line tool was last updated in 2004,
>>> >> > https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx
>>> ,
>>> >> > and could not output the query result in a way that morden
>>> >> > `org-table.el` expects.  The `sqlcmd` is the preferred command line
>>> >> > tool to connect the Microsoft SQL Server and it also has a Linux
>>> >> > version,
>>> >> > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx.
>>> >>
>>> >> Would it make sense to remove the msosql support then?
>>> >>
>>> > Yes, but I am also thinking about backward compatibility. Do you want
>>> > me to create a patch to remove `msosql` support?
>>>
>>> AFAIU, according to your comment, "osql" output is barely usable. If you
>>> think it is still usable and even used by some users, then I do not mind
>>> keeping it. I just wanted to be sure we're not keeping something that is
>>> not reasonable to keep.
>>>
>>> >> #'identity
>>> >>
>>> >>
>>> >>> OK, but what's the difference? Care to give me a short lesson?
>>> >>>Thanks!
>>>
>>> Not much difference, hence the "nitpick" tag.
>>>
>>> 'identity is a generic symbol, #'identity clearly indicates we (the
>>> user, the compiler) are interested in the symbol function cell.
>>>
>>> In this case, it is obvious, but it is not always the case in other
>>> parts of the code base, and more consistency in the right direction
>>> doesn't hurt.
>>>
>>>
>>> Regards,
>>>
>>> --
>>> Nicolas Goaziou
>>>
>>>
>>
>> Thanks,
>> David
>>
>> --
>>
>> Thanks,
>> David S.
>>
> --
>
> Thanks,
> David S.
>
-- 

Thanks,
David S.


0001-ob-sql.el-Support-sqlcmd-in-Cygwin-environment.patch
Description: Binary data


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-12 Thread Xi Shen
Hi Nicolas,

So I will:

- add "org-babel-sql-convert-filename", so another name...I am thinking
- remove `msosql` support. I am been playing with the options for a while,
and I could not find a way the make osql output the same format as sqlcmd


Thanks,
David


On Sun, Jun 12, 2016 at 10:12 AM Xi Shen <davidshe...@gmail.com> wrote:

> Yes, I think it is better to let upstream function to resolve the path for
> org-mode.
>
> But I have never contacted Emacs developers before. Should I go through
> the bug-gnu-em...@gnu.org mail list? Or there's a more effective channel?
>
>
> On Sat, Jun 11, 2016 at 4:41 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
> wrote:
>
>> Hello,
>>
>> Xi Shen <davidshe...@gmail.com> writes:
>>
>> > According to
>> >
>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html
>> ,
>> > the `convert-standard-filename` works for *nix and MS-DOS, but not
>> Cygwin
>> > environment. And I tested, it does not work. For the prefix, please
>> advice
>> > me a better one. Maybe we should path this function first? How can I
>> > patch/update a Emacs native function?
>>
>> Since there is no module in Emacs, you need to prefix functions and
>> variables according to the package, or, even better, the library they
>> belong to.
>>
>> Hence, functions and variables in "ob-sql.el" are prefixed with
>> "org-babel-sql-".
>>
>> Do you mind discussing it upstream on emacs-devel ML first? I don't
>> think this kind of function belongs to Org. If upstream has no
>> equivalent and doesn't want to add one, we might consider adding it to
>> the library.
>>
>> WDYT?
>>
>> >> > The `osql` command line tool was last updated in 2004,
>> >> > https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx,
>> >> > and could not output the query result in a way that morden
>> >> > `org-table.el` expects.  The `sqlcmd` is the preferred command line
>> >> > tool to connect the Microsoft SQL Server and it also has a Linux
>> >> > version,
>> >> > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx.
>> >>
>> >> Would it make sense to remove the msosql support then?
>> >>
>> > Yes, but I am also thinking about backward compatibility. Do you want
>> > me to create a patch to remove `msosql` support?
>>
>> AFAIU, according to your comment, "osql" output is barely usable. If you
>> think it is still usable and even used by some users, then I do not mind
>> keeping it. I just wanted to be sure we're not keeping something that is
>> not reasonable to keep.
>>
>> >> #'identity
>> >>
>> >>
>> >>> OK, but what's the difference? Care to give me a short lesson?
>> >>>Thanks!
>>
>> Not much difference, hence the "nitpick" tag.
>>
>> 'identity is a generic symbol, #'identity clearly indicates we (the
>> user, the compiler) are interested in the symbol function cell.
>>
>> In this case, it is obvious, but it is not always the case in other
>> parts of the code base, and more consistency in the right direction
>> doesn't hurt.
>>
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou
>>
>>
>
> Thanks,
> David
>
> --
>
> Thanks,
> David S.
>
-- 

Thanks,
David S.


[O] Fwd: Request to support Cygwin in convert-standard-filename function

2016-06-12 Thread Xi Shen
Hi Nicolas,

So according to Emacs upstream developer Eli' reply, the current
`convert-standard-filename` function's result is as expected. Since the
Cygwin environment is defined as a "Posix" environment. In my patch, I was
trying to call a Windows command inside a Posix environment, and
intentionally pass a file path in Windows format. This is a very special
case, and should be taken care of individually.

So I think I will update my patch to add a `org-babel-sql-convert-filename`
function.


Thanks,
David


-- Forwarded message -
From: Eli Zaretskii <e...@gnu.org>
Date: Sun, Jun 12, 2016 at 3:10 PM
Subject: Re: Request to support Cygwin in convert-standard-filename function
To: Xi Shen <davidshe...@gmail.com>
Cc: <emacs-de...@gnu.org>


> From: Xi Shen <davidshe...@gmail.com>
> Date: Sun, 12 Jun 2016 02:51:14 +
>
> I encounter a problem with `convert-standard-filename`,
>
https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html.
I call this function
> within a Cygwin environment, and this function could not return me a
MS-DOS/Windows format path. I think it
> treats Cygwin environment as a normal *nix environment.
>
> In Cygwin environment, the Emacs has a function called
`cygwin-convert-file-name-to-windows` which
> converts a expanded path to a Windows path, e.g.:
>
> /cygdrive/c/Windows => c:\Windows
>
> According to the description of the `convert-standard-filename`, it is
expected to be used only in places where
> the callee wants to convert a *nix path to the underline OS path. I think
it is appropriate we invoke the
> `cygwin-convert-file-name-to-windows` function inside the
`convert-standard-filename` function if it is called
> within a Cygwin environment.

Yes, Cygwin is a Posix environment, and convert-standard-filename is
documented to be a no-op in such an environment.

For the conversion you need, you can call
cygwin-convert-file-name-to-windows directly.
-- 

Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-11 Thread Xi Shen
Yes, I think it is better to let upstream function to resolve the path for
org-mode.

But I have never contacted Emacs developers before. Should I go through the
bug-gnu-em...@gnu.org mail list? Or there's a more effective channel?


On Sat, Jun 11, 2016 at 4:41 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > According to
> >
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html
> ,
> > the `convert-standard-filename` works for *nix and MS-DOS, but not Cygwin
> > environment. And I tested, it does not work. For the prefix, please
> advice
> > me a better one. Maybe we should path this function first? How can I
> > patch/update a Emacs native function?
>
> Since there is no module in Emacs, you need to prefix functions and
> variables according to the package, or, even better, the library they
> belong to.
>
> Hence, functions and variables in "ob-sql.el" are prefixed with
> "org-babel-sql-".
>
> Do you mind discussing it upstream on emacs-devel ML first? I don't
> think this kind of function belongs to Org. If upstream has no
> equivalent and doesn't want to add one, we might consider adding it to
> the library.
>
> WDYT?
>
> >> > The `osql` command line tool was last updated in 2004,
> >> > https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx,
> >> > and could not output the query result in a way that morden
> >> > `org-table.el` expects.  The `sqlcmd` is the preferred command line
> >> > tool to connect the Microsoft SQL Server and it also has a Linux
> >> > version,
> >> > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx.
> >>
> >> Would it make sense to remove the msosql support then?
> >>
> > Yes, but I am also thinking about backward compatibility. Do you want
> > me to create a patch to remove `msosql` support?
>
> AFAIU, according to your comment, "osql" output is barely usable. If you
> think it is still usable and even used by some users, then I do not mind
> keeping it. I just wanted to be sure we're not keeping something that is
> not reasonable to keep.
>
> >> #'identity
> >>
> >>
> >>> OK, but what's the difference? Care to give me a short lesson?
> >>>Thanks!
>
> Not much difference, hence the "nitpick" tag.
>
> 'identity is a generic symbol, #'identity clearly indicates we (the
> user, the compiler) are interested in the symbol function cell.
>
> In this case, it is obvious, but it is not always the case in other
> parts of the code base, and more consistency in the right direction
> doesn't hurt.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>
>

Thanks,
David

-- 

Thanks,
David S.


Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-10 Thread Xi Shen
Hello Nicolas,

Please see my replies inline.

On Sat, Jun 11, 2016 at 6:06 AM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Xi Shen <davidshe...@gmail.com> writes:
>
> > I would like to apply this path to add sqlcmd support, and allow org-mode
> > to execute and capture sqlcmd output in cygwin environment.
>
> Thank you for the patch.
>
> > I added a "platform-convert-file-name" function to convert a *nix path to
> > Windows path. Should I put this function in ob-sql.el, or somewhere
> > else?
>
> I'm surprised it doesn't exist. Wouldn't `convert-standard-filename' do
> the job?
>
> In any case, it doesn't have a proper prefix.
>
>
>> According to
https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-File-Names.html,
the `convert-standard-filename` works for *nix and MS-DOS, but not Cygwin
environment. And I tested, it does not work. For the prefix, please advice
me a better one. Maybe we should path this function first? How can I
patch/update a Emacs native function?


> > Subject: [PATCH] ob-sql.el: Support sqlcmd and cygwin environment
> >
> > * lisp/ob-sql.el (org-babel-sql-dbstring-mssql): Format Microsoft
> >   sqlcmd command line args.
> >
> > * lisp/ob-sql.el (platform-convert-file-name): Convert a *nix path to
> >   Windows long path in Cygwin environment, or do nothing.
> >
> > * lisp/ob-sql.el (org-babel-execute:sql): Add `mssql` command support.
> >   For both `msosql` and `mssql` the `input` and `output` path will be
> >   mapped by `platform-convert-file-name`
>
> You can write it like
>
>  * lisp/ob-sql.el (org-babel-sql-dbstring-mssql): Format Microsoft
>sqlcmd command line args.
>  (platform-convert-file-name): Convert a *nix path to Windows long path
>  in Cygwin environment, or do nothing.
>  (org-babel-execute:sql): Add `mssql' command support. For both `msosql'
>  and `mssql` the `input` and `output' path will be mapped by
>  `platform-convert-file-name'
>
> >> Sure, I will update the ChangeLog entry.


> > The `osql` command line tool was last updated in 2004,
> > https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx,
> > and could not output the query result in a way that morden
> > `org-table.el` expects.  The `sqlcmd` is the preferred command line
> > tool to connect the Microsoft SQL Server and it also has a Linux
> > version,
> > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx.
>
> Would it make sense to remove the msosql support then?
>
> >> Yes, but I am also thinking about backward compatibility. Do you want
me to create a patch to remove `msosql` support?


> > +(defun org-babel-sql-dbstring-mssql (host user password database)
> > +  "Make Microsoft sqlcmd commmand line args for database
> > +connection."
>
> The first sentence has to fit on a single line.
>
> > Will do, thanks~


> > +  (mapconcat 'identity
>
> Nit-pick:
>
> #'identity
>
>
>> OK, but what's the difference? Care to give me a short lesson? Thanks!


> > +  "In Cygwin environment convert the file path into Windows long
> > +path and quote it."
> > +  (if (fboundp 'cygwin-convert-file-name-to-windows)
> > +  (format "\"%s\"" (cygwin-convert-file-name-to-windows file))
> > +file))
>
> See above.
>
> Regards,
>
> --
> Nicolas Goaziou
>


Thanks,
David

-- 

Thanks,
David S.


[O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment

2016-06-08 Thread Xi Shen
Hi,

I would like to apply this path to add sqlcmd support, and allow org-mode
to execute and capture sqlcmd output in cygwin environment.

I added a "platform-convert-file-name" function to convert a *nix path to
Windows path. Should I put this function in ob-sql.el, or somewhere else?


Thanks,
David

-- 

Thanks,
David S.


0001-ob-sql.el-Support-sqlcmd-and-cygwin-environment.patch
Description: Binary data


[O] Where should I add a new utility function?

2016-06-08 Thread Xi Shen
Hi,

I would like to add a utility function which will be used by the
org-babel-execute:sql function. The function would look like this:

+(defun platform-convert-file-name (file)
+  (if (fboundp 'cygwin-convert-file-name-to-windows)
+  (format "\"%s\"" (cygwin-convert-file-name-to-windows file))
+(t file)))
+

As its name suggests, this function if very platform specific. Should I put
this definition in the ob-sql.el file, the ob-core.el file or somewhere
else?


Thanks,
David

-- 

Thanks,
David S.


Re: [O] How to setup a development for org-mode?

2016-06-08 Thread Xi Shen
I found the minimal-org trick works for me.


On Wed, Jun 8, 2016 at 3:04 PM Robert Klein <rokl...@roklein.de> wrote:

> Hi,
>
> On Wed, 08 Jun 2016 06:55:08 +
> Xi Shen <davidshe...@gmail.com> wrote:
>
> > Tried that at first, but got:
> >
> > Symbol's function definition is void: org-babel--get-vars
> >
> > Maybe it is because I am in cygwin environment, so Emacs eval buffers
> > differently?
>
> You are using org-mode 8.3.4 from then maint branch (or earlier) which
> hasn't org-babel--get-vars.  The version of ob-sql.el you are editing
> is from the master branch.
>
> Best regards
> Robert
>
>
> >
> >
> > Thanks,
> > David
> >
> >
> > On Wed, Jun 8, 2016 at 2:42 PM Rasmus <ras...@gmx.us> wrote:
> >
> > > Xi Shen <davidshe...@gmail.com> writes:
> > >
> > > > Hi,
> > > >
> > > > I want to make some change to the ob-sql.el file. But I don't
> > > > want to
> > > "make
> > > > install" every time I change something. I tried to use
> > > > “load-file" to reload the file I changed, but I got symbol not
> > > > found error.
> > >
> > > Open the file you've edited and do,
> > >
> > > M-x eval-buffer RET
> > >
> > > Hope it helps,
> > > Rasmus
> > >
> > >
> > > --
> > > Hvor meget poesi tror De kommer ud af et glas isvand?
> > >
> > >
> > > --
> >
> > Thanks,
> > David S.
>
> --

Thanks,
David S.


[O] Proposal to use sqlcmd for connecting to SQL Server

2016-06-08 Thread Xi Shen
Hi,

I tried the use the msosql engine in org-mode, but it cannot format the
result into a table. I think MS has made some change that the output of the
command is not compatible with org-mode. More specifically, the output add
"1> 2> 3> 4>  " to the begging and break the table formatting. I saw this
result on Windows 7 with osql 10.50.1600.1.

However, I found that the output of "sqlcmd" can be formatted into a table
in org-mode correctly without any trick.

osql and sqlcmd take similar command arguments, with sqlcmd has more
options. I think it is safe to simply replace the "osql" command into
"sqlcmd" command in the ob-sql.el file.

The only major difference between these two tools are: osql uses ODBC to
connect to the server; while sqlcmd uses the fancy native client to connect
to the server.

I would like to hear ideas/suggestions about this.


Thanks,
David

-- 

Thanks,
David S.


Re: [O] How to setup a development for org-mode?

2016-06-08 Thread Xi Shen
Tried that at first, but got:

Symbol's function definition is void: org-babel--get-vars

Maybe it is because I am in cygwin environment, so Emacs eval buffers
differently?


Thanks,
David


On Wed, Jun 8, 2016 at 2:42 PM Rasmus <ras...@gmx.us> wrote:

> Xi Shen <davidshe...@gmail.com> writes:
>
> > Hi,
> >
> > I want to make some change to the ob-sql.el file. But I don't want to
> "make
> > install" every time I change something. I tried to use “load-file" to
> > reload the file I changed, but I got symbol not found error.
>
> Open the file you've edited and do,
>
> M-x eval-buffer RET
>
> Hope it helps,
> Rasmus
>
>
> --
> Hvor meget poesi tror De kommer ud af et glas isvand?
>
>
> --

Thanks,
David S.


[O] How to setup a development for org-mode?

2016-06-07 Thread Xi Shen
Hi,

I want to make some change to the ob-sql.el file. But I don't want to "make
install" every time I change something. I tried to use “load-file" to
reload the file I changed, but I got symbol not found error.

Any suggestions?


Thanks,
David

-- 

Thanks,
David S.


[O] How to contribute?

2016-06-07 Thread Xi Shen
Hi,

I would like to make some code change to org-mode. I followed the
instruction on http://orgmode.org/worg/org-contribute.html#patches, but I
got stuck at the first step.

I send my RSA public key, to the system, but I never got a response.

What is the preferred public key specification?


Thanks,
David

-- 

Thanks,
David S.


[O] Could org-babel-process-file-name support cygwin environment?

2016-06-06 Thread Xi Shen
Hi,

I have been using the latest version of the Emacs in cygwin
environment for a long time. Recently, I want to use the sql source
environment in the org-mode.

But I got some error from the "osql" tool on Windows environment. I
did some investigation, and I believe it is because this tool cannot
handle the input and output path Emacs handled to it in Unix form.

I checked the code,
https://github.com/jwiegley/org-mode/blob/fdd9b18598239dd0e8b18383ac930110d51ed22e/lisp/ob-sql.el#L115,
it will directly pass the path generated from
"org-babel-process-file-name" to osql, but
"org-babel-process-file-name" did not take cygwin environment into
account neither.

I think it would be very helpful if the "org-babel-process-file-name"
check the cygwin environment, and map the path using the "cygpath"
tool beforehand.


Thanks,
David