emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Sebold <Charles.Sebold@lcms.org>
To: emacs-orgmode@gnu.org
Subject: Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (release_7.5.125.g70fe)]
Date: Fri, 01 Apr 2011 14:44:49 -0500	[thread overview]
Message-ID: <yucvcyxg3im.fsf@lcms.org> (raw)

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

This has been a problem for me for some time, but I only just now had
the chance to find the problem.

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.

Diff is here, followed by the bug report data dump (edited to remove
things that don't need to be public, and I wonder if it would be a good
idea to modify the bug report to automatically leave out encryption
passwords and the like?).

------------------------------------------------------------------------
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'."
------------------------------------------------------------------------

Emacs  : GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-03-29 on CT-SEBOLDCR-T4C
Package: Org-mode version 7.5 (release_7.5.125.g70fe)

current state:
==============
(setq
 org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
 org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
 org-agenda-custom-commands '(("z" tags "memorize&daily|odd|thursday|memday31")
                              ("A" "Full Agenda" ((agenda "")))
                              ("7" "Full Weekly Agenda"
                               ((agenda "" ((org-agenda-span (quote week))))))
                              ("h" . "HOME + tag/TODO searches")
                              ("ha" "Full Agenda + Next Actions"
                               ((agenda) (todo "INBOX") (todo "NEXTACTION") (todo "TODO")))
                              ("hn" "Next Actions"
                               ((todo "INBOX") (todo "NEXTACTION") (todo "TODO")))
                              ("ht" "Non-LCMS Tasks" ((tags-todo "-lcms")))
                              ("hp" "All Projects"
                               ((todo "PROJECT") (todo "PROJWAITING") (todo "PROJVERIFY")))
                              ("R" "TeamMania tasks" ((tags-todo "+work+teammania")))
                              ("w" . "LCMS + tag/TODO searches")
                              ("wo" "LCMS Servicewise Open Tickets"
                               ((tags "+servicewise+ticket-status=\"Closed\"")))
                              ("wt" "LCMS tasks" ((tags-todo "+work+lcms")))
                              ("wn" "LCMS Next Actions"
                               ((agenda) (todo "INBOX") (todo "NEXTACTION")
                                (tags "+servicewise+ticket-status=\"Closed\"") (todo "TODO"))
                               ((org-agenda-files (quote ("~/org/lcms")))))
                              ("wp" "LCMS Unfinished Projects"
                               ((todo "PROJECT") (todo "PROJWAITING") (todo "PROJVERIFY"))
                               ((org-agenda-files (quote ("~/org/lcms")))))
                              ("ws" "SQL tasks" ((tags-todo "+work+sql")))
                              ("g" agenda "non-LCMS Agenda"
                               ((org-agenda-files (quote ("~/org/gtd.org")))))
                              ("wd" agenda "LCMS Daily Agenda"
                               ((org-agenda-files (quote ("~/org/lcms")))))
                              )
 org-agenda-files '("~/org" "~/org/fiction" "~/org/reference" "~/org/personal" "~/org/gaming"
                    "~/org/lcms")
 org-src-fontify-natively t
 org-babel-load-languages '((R) (clojure . t) (C) (ditaa . t) (dot) (emacs-lisp . t) (gnuplot)
                            (haskell) (latex) (ocaml) (org . t) (perl) (python) (ruby)
                            (screen) (sh) (sql . t) (sqlite))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-babel-tangle-lang-exts '(("clojure" . "clj") ("emacs-lisp" . "el"))
 org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
 org-deadline-warning-days 5
 org-export-latex-format-toc-function 'org-export-latex-format-toc-default
 org-agenda-skip-scheduled-if-done t
 org-stuck-projects '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") ("info") "")
 org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe
                      org-babel-hide-result-toggle-maybe)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-reveal-start-hook '(org-decrypt-entry)
 org-export-first-hook '(org-beamer-initialize-open-trackers)
 org-todo-keywords '((sequence "INBOX(i)" "TICKLER(t!)" "|" "FILE(f@)" "CANCELED(k@)")
                     (sequence "TODO" "NEXTACTION(n)" "WAITING" "VERIFY" "|" "DONE"
                      "REASSIGNED")
                     (sequence "DAILY(d)" "|" "DONEDLY" "UNSCHEDDLY(D)")
                     (sequence "WEEKLY(e)" "|" "DONEWKLY" "UNSCHEDWKLY(E)")
                     (sequence "MONTHLY(m)" "|" "DONEMNTHLY" "UNSCHEDMNTHLY(M)")
                     (sequence "QUARTERLY(q)" "|" "DONEQUARTERLY" "UNSCHEDQUTRLY")
                     (sequence "REQUEST(r!)" "REQWAITING(w@/!)" "REQVERIFY(v)" "|"
                      "REQCLOSED(c!)" "REQREASSIGNED(a@)")
                     (sequence "PROJECT(P!)" "PROJWAITING(W@/!)" "PROJVERIFY(V)" "|"
                      "PROJCLOSED(C!)" "PROJREASSIGNED(A@)")
                     )
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-default-notes-file "~/org//process.org"
 org-directory "~/org/"
 org-babel-pre-tangle-hook '(save-buffer)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
                  org-cycle-show-empty-lines org-optimize-window-after-visibility-change)
 org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers)
 org-agenda-span 'day
 org-mode-hook '(#[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook org-babel-show-result-all append local]
                   5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-use-fast-todo-selection 'prefix
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-log-into-drawer t
 org-agenda-mode-hook '(hl-line-mode)
 org-export-interblocks '((lob org-babel-exp-lob-one-liners)
                          (src org-babel-exp-inline-src-blocks))
 org-agenda-skip-deadline-if-done t
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp nil
 org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code)
 org-mobile-use-encryption t
 org-agenda-use-time-grid nil
 org-mobile-checksum-binary "sha1sum"
 org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc
                               org-beamer-auto-fragile-frames
                               org-beamer-place-default-actions-for-lists)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-export-blocks '((src org-babel-exp-src-block nil)
                     (comment org-export-blocks-format-comment t)
                     (ditaa org-export-blocks-format-ditaa nil)
                     (dot org-export-blocks-format-dot nil))
 )

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-mode patch --]
[-- Type: text/x-patch, Size: 2121 bytes --]

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	other threads:[~2011-04-01 19:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-01 19:44 Charles Sebold [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-01 20:12 Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (release_7.5.125.g70fe)] Charles Sebold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yucvcyxg3im.fsf@lcms.org \
    --to=charles.sebold@lcms.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).