From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Malakhovski Subject: [PATCH 4/9] org: move `org-duration-string-to-minutes' to a better place Date: Tue, 3 Nov 2015 20:15:42 +0000 Message-ID: <1446581747-1960-5-git-send-email-oxij@oxij.org> References: <1446581747-1960-1-git-send-email-oxij@oxij.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zti0B-0002Na-5y for emacs-orgmode@gnu.org; Tue, 03 Nov 2015 15:16:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zti0A-0004OI-6d for emacs-orgmode@gnu.org; Tue, 03 Nov 2015 15:16:19 -0500 Received: from fujibayashi-1-pt.tunnel.tserv10.par1.ipv6.he.net ([2001:470:1f12:446::2]:29107 helo=tricoro.koumakan.jp) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zti0A-0004O2-18 for emacs-orgmode@gnu.org; Tue, 03 Nov 2015 15:16:18 -0500 In-Reply-To: <1446581747-1960-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 6218a3a..a0fe644 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18328,6 +18328,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? @@ -18386,26 +18406,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.2