From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Malakhovski Subject: [PATCH 2/4] org: move org-duration-string-to-minutes to a better place Date: Sun, 25 Oct 2015 12:48:11 +0000 Message-ID: <1445777293-13909-3-git-send-email-oxij@oxij.org> References: <1445777293-13909-1-git-send-email-oxij@oxij.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqKjF-0006io-Hl for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 08:48:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqKjC-0004eq-Dc for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 08:48:53 -0400 Received: from tricoro.koumakan.jp ([195.154.188.176]:14255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqKjC-0004eg-8T for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 08:48:50 -0400 In-Reply-To: <1445777293-13909-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 088913c..453ed37 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18329,6 +18329,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? @@ -18387,26 +18407,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.5.3