emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* OrgMobile problem: only three files in checksums.dat
@ 2012-03-18  3:50 Alexander Vorobiev
  2012-03-18 22:23 ` Alexander Vorobiev
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Vorobiev @ 2012-03-18  3:50 UTC (permalink / raw)
  To: emacs-orgmode

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

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

[-- Attachment #2: Type: text/html, Size: 710 bytes --]

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

* Re: OrgMobile problem: only three files in checksums.dat
  2012-03-18  3:50 OrgMobile problem: only three files in checksums.dat Alexander Vorobiev
@ 2012-03-18 22:23 ` Alexander Vorobiev
  2012-03-19  4:35   ` Jonathan Leech-Pepin
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Vorobiev @ 2012-03-18 22:23 UTC (permalink / raw)
  To: emacs-orgmode

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

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
>

[-- Attachment #2: Type: text/html, Size: 4479 bytes --]

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

* Re: OrgMobile problem: only three files in checksums.dat
  2012-03-18 22:23 ` Alexander Vorobiev
@ 2012-03-19  4:35   ` Jonathan Leech-Pepin
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Leech-Pepin @ 2012-03-19  4:35 UTC (permalink / raw)
  To: Alexander Vorobiev; +Cc: emacs-orgmode

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

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 <alexander.vorobiev@gmail.com>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
>>
>
>

[-- Attachment #2: Type: text/html, Size: 6316 bytes --]

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

end of thread, other threads:[~2012-03-19  4:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-18  3:50 OrgMobile problem: only three files in checksums.dat Alexander Vorobiev
2012-03-18 22:23 ` Alexander Vorobiev
2012-03-19  4:35   ` Jonathan Leech-Pepin

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