From 0bd47871e863686198d9c0e4a09a7fbe299fa056 Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 3 Sep 2012 11:15:27 +0300 Subject: [PATCH] * mu4e: don't require org directly --- mu4e/mu4e-actions.el | 2 +- mu4e/mu4e-utils.el | 36 ++++++++++++++++++++++++++++++++---- mu4e/org-mu4e.el | 4 ++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/mu4e/mu4e-actions.el b/mu4e/mu4e-actions.el index 0bc35e70..6d0338d3 100644 --- a/mu4e/mu4e-actions.el +++ b/mu4e/mu4e-actions.el @@ -138,7 +138,7 @@ with `mu4e-compose-attach-captured-message'." current message (in headers or view). You need to set `mu4e-org-contacts-file' to the full path to the file where you store your org-contacts." - (unless (require 'org-capture nil 'nomu4e-error) + (unless (require 'org-capture nil 'noerror) (mu4e-error "org-capture is not available.")) (unless mu4e-org-contacts-file (mu4e-error "`mu4e-org-contacts-file' is not defined.")) diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 966eb47d..5aeb9d82 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -32,8 +32,7 @@ (require 'mu4e-vars) (require 'mu4e-about) (require 'doc-view) -(require 'org) ;; for org-parse-time-string - + (defcustom mu4e-html2text-command nil "Shell command that converts HTML from stdin into plain text on stdout. If this is not defined, the emacs `html2text' tool will be @@ -50,6 +49,35 @@ e-mail message (if there is any." :group 'mu4e-view) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; the following is taken from org.el; we copy it here since we don't want to +;; depend on org-mode directly (it causes byte-compilation errors) TODO: a +;; cleaner solution.... +(defconst mu4e~ts-regexp0 + "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\( +[^]+0-9>\r\n -]+\\)?\\( +\\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)" + "Regular expression matching time strings for analysis. +This one does not require the space after the date, so it can be +used on a string that terminates immediately after the date.") + +(defun mu4e-parse-time-string (s &optional nodefault) + "Parse the standard Org-mode time string. +This should be a lot faster than the normal `parse-time-string'. +If time is not given, defaults to 0:00. However, with optional NODEFAULT, +hour and minute fields will be nil if not given." + (if (string-match mu4e~ts-regexp0 s) + (list 0 + (if (or (match-beginning 8) (not nodefault)) + (string-to-number (or (match-string 8 s) "0"))) + (if (or (match-beginning 7) (not nodefault)) + (string-to-number (or (match-string 7 s) "0"))) + (string-to-number (match-string 4 s)) + (string-to-number (match-string 3 s)) + (string-to-number (match-string 2 s)) + nil nil nil) + (mu4e-error "Not a standard mu4e time string: %s" s))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + (defun mu4e-create-maildir-maybe (dir) "Offer to create DIR if it does not exist yet. Return t if the dir already existed, or has been created, nil otherwise." @@ -645,7 +673,7 @@ FUNC (if non-nil) afterwards." (when mu4e-compose-complete-only-after (float-time (apply 'encode-time - (org-parse-time-string mu4e-compose-complete-only-after)))))))) + (mu4e-parse-time-string mu4e-compose-complete-only-after)))))))) (defun mu4e~stop () "Stop the mu4e session." @@ -884,7 +912,7 @@ displaying it). Do _not_ bury the current buffer, though." after PROMPT. Formats are all that are accepted by `parse-time-string'." (let ((timestr (read-string (mu4e-format "%s" prompt)))) - (apply 'encode-time (org-parse-time-string timestr)))) + (apply 'encode-time (mu4e-parse-time-string timestr)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconst mu4e~main-about-buffer-name "*mu4e-about*" diff --git a/mu4e/org-mu4e.el b/mu4e/org-mu4e.el index 89d62555..1794e74c 100644 --- a/mu4e/org-mu4e.el +++ b/mu4e/org-mu4e.el @@ -27,6 +27,10 @@ ;;; Code: +;; the 'noerror is just to make sure bytecompilations does not break... +;; FIXME: find a better solution +(require 'org nil 'noerror) + (eval-when-compile (require 'cl)) (eval-when-compile (require 'mu4e)) ;; hack: we don't want to require org (as that doesn't always work in