From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Leech-Pepin Subject: Re: OrgMobile problem: only three files in checksums.dat Date: Mon, 19 Mar 2012 00:35:44 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b339b8d6eab9f04bb9117a1 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9UJy-0002ja-K5 for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 00:35:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9UJw-0002E1-0g for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 00:35:50 -0400 Received: from mail-pz0-f51.google.com ([209.85.210.51]:47527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9UJv-0002Dl-JF for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 00:35:47 -0400 Received: by dady9 with SMTP id y9so11159108dad.38 for ; Sun, 18 Mar 2012 21:35:44 -0700 (PDT) In-Reply-To: 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.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Alexander Vorobiev Cc: emacs-orgmode --047d7b339b8d6eab9f04bb9117a1 Content-Type: text/plain; charset=ISO-8859-1 I haven't had this issue with Org-Mobile specifically because I'm not using it, however I found the same error when using el-get. In my case at least the issue popped up because I was using zsh/bash via cygwin for =shell-file-name= where =shell-quote-argument= expected it to be cmdproxy.exe on Windows. I'm guessing you've got something similar since it's using forward-slashes for sha1sum. It also fits because the only way the final regexp gets applied is when the system is not ms-dos or windows-nt along with a known Windows shell, which means cmd.exe, command.com, cmdproxy and a couple others, cygwin shells are not on that list. The simplest solution would actually be to wrap your Org-mobile call in (let ((shell-file-name (or (and (eq system-type 'windows-nt) (executable-find "cmdproxy.exe")) shell-file-name))) {{{insert call here}}} ) Hope this helps, Jonathan On 18 March 2012 18:23, Alexander Vorobiev wrote: > I figured out what is wrong. I am on Windows 7 (with cygwin) where > shell-quote-argument (defined in emacs' subr.el) seems to be broken, > specifically it insists on escaping colons (as one of non-POSIX filename > characters), so, for instance path to one of my files c:/Users/alex/org/ > gtd.org becomes c\\:/Users/alex/org/gtd.org. > The result of that is org-mobile-copy-agenda-files which > calls shell-quote-argument while generating command line to produce > checksums, ends up with something like > > c:/cygwin/bin/sha1sum c\\:/Users/alex/org/gtd.org > > which inevitably fails. I am surprised nobody else with Windows machines > noticed that, could there be anything I am doing wrong? > > The quick fix would be to redefine the shell-quote-argument to account for > colons (added colon in the regex on the last line, see below). After that > all my org files get added to checksum.dat and become visible on my Android > phone. > > I temporarily put this definition to my cygwin-specific initialization > file but I feel that there should be more elegant solutions: > > (defun shell-quote-argument (argument) > "Quote ARGUMENT for passing as argument to an inferior shell." > (if (or (eq system-type 'ms-dos) > (and (eq system-type 'windows-nt) (w32-shell-dos-semantics))) > ;; Quote using double quotes, but escape any existing quotes in > ;; the argument with backslashes. > (let ((result "") > (start 0) > end) > (if (or (null (string-match "[^\"]" argument)) > (< (match-end 0) (length argument))) > (while (string-match "[\"]" argument start) > (setq end (match-beginning 0) > result (concat result (substring argument start end) > "\\" (substring argument end (1+ end))) > start (1+ end)))) > (concat "\"" result (substring argument start) "\"")) > (if (equal argument "") > "''" > ;; Quote everything except POSIX filename characters. > ;; This should be safe enough even for really weird shells. > (replace-regexp-in-string "\n" "'\n'" > (replace-regexp-in-string "[^-0-9a-zA-Z_./\n:]" "\\\\\\&" > argument))))) > > Regards, > Alex > > On Sat, Mar 17, 2012 at 10:50 PM, Alexander Vorobiev < > alexander.vorobiev@gmail.com> wrote: > >> Hi, >> >> I have many files in the org-mobile-files list. On org-mobile-push all of >> them are copied to my MobileOrg directory, syncronized via Dropbox to my >> phone, etc. But the file checksums.dat always has only three lines - for >> files index.org, mobileorg.org, and agendas.org. >> The org-mobile-checksum-files variable also has the checksums for those >> files only. Consequently, MobileOrg for Android only shows one line "Agenda >> Views" and does not show any of my org files despite having all of them in >> the same Dropbox directory. >> >> Thanks >> Alex >> > > --047d7b339b8d6eab9f04bb9117a1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I haven't had this issue with Org-Mobile specifically because I= 9;m not using it, however I found the same error when using el-get.

In my case at least the issue popped up because I was= using zsh/bash via cygwin for =3Dshell-file-name=3D where =3Dshell-quote-a= rgument=3D expected it to be cmdproxy.exe on Windows. =A0I'm guessing y= ou've got something similar since it's using forward-slashes for sh= a1sum. =A0It also fits because the only way the final regexp gets applied i= s when the system is not ms-dos or windows-nt along with a known Windows sh= ell, which means cmd.exe, command.com, c= mdproxy and a couple others, cygwin shells are not on that list.

The simplest solution would actually be to wrap your Or= g-mobile call in


(let ((shell-file-name (or (and (eq system= -type 'windows-nt)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 (executable-find "cmdproxy.exe"))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 shell-file-name)))
=A0 =A0 =A0{{{insert call here}}} )

Hope this helps,
Jonathan

=
On 18 March 2012 18:23, Alexander Vorobiev <alexander.= vorobiev@gmail.com> wrote:
I figured out what is wrong. I am on Windows 7 (with cygwin) where shell-qu= ote-argument (defined in emacs' subr.el) seems to be broken, specifical= ly it insists on escaping colons (as one of non-POSIX filename characters),= so, for instance path to one of my files c:/Users/alex/org/gtd.org becomes c\\:/Users/alex/org/gtd.org.=A0
The result of that is org-mobile-copy-agenda-files which calls=A0shell-quot= e-argument=A0while generating command line to produce checksums, ends up wi= th something like

c:/cygwin/bin/sha1sum c\\:/Users= /alex/org/gtd.org

which inevitably fails. I am surprised nobody else with= Windows machines noticed that, could there be anything I am doing wrong?

The quick fix would be to redefine the=A0shell-quot= e-argument=A0to account for colons (added colon in the regex on the last li= ne, see below). After that all my org files get added to checksum.dat and b= ecome visible on my Android phone.

I temporarily put this definition to my cygwin-specific= initialization file but I feel that there should be more elegant solutions= :

(defun shell-quote-argument (argument)
=A0 "Quote ARGUMENT for passing as argument to an inferior shell.= "
=A0 (if (or (eq system-type 'ms-dos)
=A0 =A0= =A0 =A0 =A0 (and (eq system-type 'windows-nt) (w32-shell-dos-semantics= )))
=A0 =A0 =A0 ;; Quote using double quotes, but escape any existing quotes in=
=A0 =A0 =A0 ;; the argument with backslashes.
=A0 =A0 = =A0 (let ((result "")
=A0 =A0(start 0)
=A0 =A0end)
(if (or (null (string-match &quo= t;[^\"]" argument))
(< (match-end 0) (length argument)))
=A0 =A0(while (string-ma= tch "[\"]" argument start)
=A0 =A0 =A0(setq end (match-beginning 0)
=A0 =A0result (concat r= esult (substring argument start end)
=A0 "\\" (substring argument end (1+ end)))<= /div>
=A0 =A0start (1+ end)))= )
(concat "\&qu= ot;" result (substring argument start) "\""))
=A0 =A0 (if (equal argument "")
=A0 =A0 =A0 =A0 &q= uot;''"
=A0 =A0 =A0 ;; Quote everything except POSIX= filename characters.
=A0 =A0 =A0 ;; This should be safe enough e= ven for really weird shells.
=A0 =A0 =A0 (replace-regexp-in-string "\n" "'\n'= ;"
=A0 =A0 =A0 =A0(replace-regexp-in-string "[^-0-9a-zA= -Z_./\n:]" "\\\\\\&" argument)))))

<= div>Regards,
Alex

On Sat= , Mar 17, 2012 at 10:50 PM, Alexander Vorobiev <alexander.vorob= iev@gmail.com> wrote:
Hi,

I have many files in the org-mobile-files list. On o= rg-mobile-push all of them are copied to my MobileOrg directory, syncronize= d via Dropbox to my phone, etc. But the file checksums.dat always has only = three lines - for files inde= x.org, mobileorg.org= , and agendas.org.= The=A0org-mobile-checksum-files variable also has the checksums for those = files only. Consequently, MobileOrg for Android only shows one line "A= genda Views" and does not show any of my org files despite having all = of them in the same Dropbox directory.

Thanks
Alex


--047d7b339b8d6eab9f04bb9117a1--