emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles.Sebold@lcms.org (Sebold, Charles)
To: emacs-orgmode@gnu.org
Cc: tdavey@gmail.com
Subject: Re: Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (release_7.5.147.g9ddc)]
Date: Wed, 04 May 2011 09:29:38 -0500	[thread overview]
Message-ID: <yuck4e6pmi5.fsf@lcms.org> (raw)
In-Reply-To: <yucwri7rab4.fsf@gmail.com> (charles sebold's message of "Tue, 03 May 2011 11:57:51 -0500")

On 3 May 2011, charles sebold wrote:

> I'm bumping this.  I think the patch attached to the last post could
> be better, but failing a response for now, I've decided that rather
> than drag my changes along, I'm just advising the necessary functions.
>
> So, to get this to work for Emacs on Windows + MobileOrg, the
> following is in my .emacs file.  Hopefully this will be helpful for
> somebody:

What I attached didn't work; I ended up flet-ing copy-file just a little
too much.

I've had to fall back to essentially redefining
org-mobile-copy-agenda-files.  Here's what I've got in my .emacs now,
but it's subject to break if org-mobile-copy-agenda-files ever changes.

I would like somebody to consider forcing all the output files
(pre-encryption obviously, if encryption is enabled) to unix line
endings in some more correct way than I have done.

#+BEGIN_SRC emacs-lisp
; bug fix for org-mobile
(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)))

(eval-and-compile
  (require 'cl)) ; for flet

(defadvice org-mobile-copy-agenda-files (around
                                         crs-org-mobile-copy-agenda-files)
  "Copy agenda files to mobile device with Unix EOLs."
  (let ((files-alist org-mobile-files-alist)
	file buf entry link-name target-path target-dir check)
    (while (setq entry (pop files-alist))
      (setq file (car entry) link-name (cdr entry))
      (when (file-exists-p file)
	(setq target-path (expand-file-name link-name org-mobile-directory)
	      target-dir (file-name-directory target-path))
	(unless (file-directory-p target-dir)
	  (make-directory target-dir 'parents))
	(if org-mobile-use-encryption
	    (org-mobile-encrypt-and-move file target-path)
	  (org-mobile-copy-file file target-path 'ok-if-exists))
	(setq check (shell-command-to-string
		     (concat org-mobile-checksum-binary " "
			     (shell-quote-argument (expand-file-name file)))))
	(when (string-match "[a-fA-F0-9]\\{30,40\\}" check)
	  (push (cons link-name (match-string 0 check))
		org-mobile-checksum-files))))

    (setq file (expand-file-name org-mobile-capture-file
				 org-mobile-directory))
    (save-excursion
      (setq buf (find-file file))
      (when (and (= (point-min) (point-max))) 
	(insert "\n")
	(save-buffer)
	(when org-mobile-use-encryption
	  (write-file org-mobile-encryption-tempfile)
	  (org-mobile-encrypt-and-move org-mobile-encryption-tempfile file)))
      (push (cons org-mobile-capture-file (md5 (buffer-string)))
	    org-mobile-checksum-files))
    (org-mobile-cleanup-encryption-tempfile)
    (kill-buffer buf)))

(defadvice org-mobile-encrypt-file (around crs-org-mobile-encrypt-file)
  "Encrypt INFILE to OUTFILE with Unix EOLs."
  (let ((tempfile (make-temp-file "orgmobile")))
    (org-mobile-copy-file infile tempfile)
    (ad-set-arg 0 tempfile)
    ad-do-it
    (delete-file tempfile)))

(ad-activate 'org-mobile-copy-agenda-files)
(ad-activate 'org-mobile-encrypt-file)
#+END_SRC
-- 
Charles Sebold                                          4th of May, 2011
              GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
     No Gnus v0.18 | Org-mode version 7.5 (release_7.5.249.gbf7ce)

      reply	other threads:[~2011-05-04 14:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07 14:06 Bug: EOL needs to be converted to Unix for MobileOrg files [7.5 (release_7.5.147.g9ddc)] Charles Sebold
2011-05-03 16:57 ` charles.sebold
2011-05-04 14:29   ` Sebold, Charles [this message]

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=yuck4e6pmi5.fsf@lcms.org \
    --to=charles.sebold@lcms.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=tdavey@gmail.com \
    /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).