From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Malakhovski Subject: [PATCH 1/4] org: move `org-duration-string-to-minutes' to a better place Date: Sun, 27 Dec 2015 15:13:46 +0000 Message-ID: <1451229229-18973-2-git-send-email-oxij@oxij.org> References: <1451229229-18973-1-git-send-email-oxij@oxij.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDD1M-0004wy-1p for emacs-orgmode@gnu.org; Sun, 27 Dec 2015 10:14:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDD1L-0004GI-3b for emacs-orgmode@gnu.org; Sun, 27 Dec 2015 10:14:07 -0500 Received: from fujibayashi-1-pt.tunnel.tserv10.par1.ipv6.he.net ([2001:470:1f12:446::2]:26925 helo=tricoro.koumakan.jp) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDD1K-0004GE-Ty for emacs-orgmode@gnu.org; Sun, 27 Dec 2015 10:14:07 -0500 In-Reply-To: <1451229229-18973-1-git-send-email-oxij@oxij.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Jan Malakhovski --- lisp/org.el | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 74d1c4c..f6c513e 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18303,6 +18303,26 @@ If no number is found, the return value is 0." (string-to-number (match-string 1 s))) (t 0))) +(defun org-duration-string-to-minutes (s &optional output-to-string) + "Convert a duration string S to minutes. + +A bare number is interpreted as minutes, modifiers can be set by +customizing `org-effort-durations' (which see). + +Entries containing a colon are interpreted as H:MM by +`org-hh:mm-string-to-minutes'." + (let ((result 0) + (re (concat "\\([0-9.]+\\) *\\(" + (regexp-opt (mapcar 'car org-effort-durations)) + "\\)"))) + (while (string-match re s) + (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) + (string-to-number (match-string 1 s)))) + (setq s (replace-match "" nil t s))) + (setq result (floor result)) + (incf result (org-hh:mm-string-to-minutes s)) + (if output-to-string (number-to-string result) result))) + (defcustom org-image-actual-width t "Should we use the actual width of images when inlining them? @@ -18361,26 +18381,6 @@ The value is a list, with zero or more of the symbols `effort', `appt', :package-version '(Org . "8.3") :group 'org-agenda) -(defun org-duration-string-to-minutes (s &optional output-to-string) - "Convert a duration string S to minutes. - -A bare number is interpreted as minutes, modifiers can be set by -customizing `org-effort-durations' (which see). - -Entries containing a colon are interpreted as H:MM by -`org-hh:mm-string-to-minutes'." - (let ((result 0) - (re (concat "\\([0-9.]+\\) *\\(" - (regexp-opt (mapcar 'car org-effort-durations)) - "\\)"))) - (while (string-match re s) - (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) - (string-to-number (match-string 1 s)))) - (setq s (replace-match "" nil t s))) - (setq result (floor result)) - (incf result (org-hh:mm-string-to-minutes s)) - (if output-to-string (number-to-string result) result))) - ;;;; Files (defun org-save-all-org-buffers () -- 2.6.4