emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (rel


From: Charles Sebold
Subject: [O] Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (release_7.5.147.g9ddc)]
Date: Thu, 07 Apr 2011 09:06:35 -0500

Second attempt to send this patch.

I primarily use Org-mode on Windows, and my org files mostly have DOS
line endings.  A while back a patch from me was accepted to convert the
checksum file to Unix EOLs (and Richard updated the iOS app to be
agnostic about it, I think, at the same time), which saved a lot of
syncing because the checksum file never looked right to MobileOrg.

However, the files themselves are irritating because they appear to have
double line feeds when they are viewed on the iOS device, and edits from
MobileOrg never sync because stray ^Ms creep in.

This patch makes all files pushed to MobileOrg into Unix files as far as
line endings go.

It's not a very elegant solution and my feelings won't be hurt if a
better way is proposed.

Emacs  : GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-04-05 on CT-SEBOLDCR-T4C
Package: Org-mode version 7.5 (release_7.5.147.g9ddc)
Changes in master
        Modified lisp/org-mobile.el
diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
index 83462f0..fa1d4f4 100644
--- a/lisp/org-mobile.el
+++ b/lisp/org-mobile.el
@@ -472,6 +472,12 @@ agenda view showing the flagged items."
                                   target-file)
       (org-mobile-cleanup-encryption-tempfile))))
 
+(defun org-mobile-copy-file (file newname)
+  "Copy file, converting to Unix line endings."
+  (with-temp-file newname
+    (set-buffer-file-coding-system 'undecided-unix nil)
+    (insert-file-contents file)))
+
 (defun org-mobile-copy-agenda-files ()
   "Copy all agenda files to the stage or WebDAV directory."
   (let ((files-alist org-mobile-files-alist)
@@ -485,7 +491,7 @@ agenda view showing the flagged items."
          (make-directory target-dir 'parents))
        (if org-mobile-use-encryption
            (org-mobile-encrypt-and-move file target-path)
-         (copy-file file target-path 'ok-if-exists))
+         (org-mobile-copy-file file target-path))
        (setq check (shell-command-to-string
                     (concat org-mobile-checksum-binary " "
                             (shell-quote-argument (expand-file-name file)))))
@@ -710,12 +716,15 @@ encryption program does not understand them."
 
 (defun org-mobile-encrypt-file (infile outfile)
   "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."
-  (shell-command
-   (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s"
-          (shell-quote-argument (concat "pass:"
-                                        (org-mobile-encryption-password)))
-          (shell-quote-argument (expand-file-name infile))
-          (shell-quote-argument (expand-file-name outfile)))))
+  (let ((tempfile (make-temp-file "orgmobile")))
+    (org-mobile-copy-file infile tempfile)
+    (shell-command
+     (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s"
+            (shell-quote-argument (concat "pass:"
+                                          (org-mobile-encryption-password)))
+            (shell-quote-argument (expand-file-name tempfile))
+            (shell-quote-argument (expand-file-name outfile))))
+    (delete-file tempfile)))
 
 (defun org-mobile-decrypt-file (infile outfile)
   "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]