From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Vorobiev Subject: Re: OrgMobile problem: only three files in checksums.dat Date: Sun, 18 Mar 2012 17:23:36 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f3bb0cfc35fcd04bb8be58c Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9OWA-00073r-U2 for emacs-orgmode@gnu.org; Sun, 18 Mar 2012 18:24:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9OW6-0002bw-UI for emacs-orgmode@gnu.org; Sun, 18 Mar 2012 18:24:02 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:34162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9OW6-0002bk-Hh for emacs-orgmode@gnu.org; Sun, 18 Mar 2012 18:23:58 -0400 Received: by werj55 with SMTP id j55so6944234wer.0 for ; Sun, 18 Mar 2012 15:23:56 -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: emacs-orgmode --e89a8f3bb0cfc35fcd04bb8be58c Content-Type: text/plain; charset=ISO-8859-1 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 > --e89a8f3bb0cfc35fcd04bb8be58c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 "[^\"]" argument))
=
(<= ; (match-end 0) (length argument)))
=A0 = =A0(while (string-match "[\"]" argument start)
=A0 =A0 =A0(= setq end (match-beginning 0)
=A0= =A0result (concat result (substring argument start end)
=A0 "\\&q= uot; (substring argument end (1+ end)))
=A0= =A0start (1+ end))))
(concat "\"" result (substring argumen= t 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.vorobiev@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

--e89a8f3bb0cfc35fcd04bb8be58c--