From 739853d128d7583103ae1d8f31e1be9f9669be04 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 22 Jun 2015 10:01:51 +0200 Subject: [PATCH] Tiny speed-up for `org-entry-properties' * lisp/org.el (org-entry-properties): Tiny speed-up. * testing/lisp/test-org.el (test-org/entry-properties): Add test. --- lisp/org.el | 17 ++++++++++++----- testing/lisp/test-org.el | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 7b720f842..8eaaa3ee2 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -15642,7 +15642,8 @@ strings." (when specific (throw 'exit props))) (when (or (not specific) (string= specific "PRIORITY")) (when (looking-at org-priority-regexp) - (push (cons "PRIORITY" (org-match-string-no-properties 2)) props)) + (push (cons "PRIORITY" (org-match-string-no-properties 2)) + props)) (when specific (throw 'exit props))) (when (or (not specific) (string= specific "FILE")) (push (cons "FILE" (buffer-file-name (buffer-base-buffer))) @@ -15689,10 +15690,16 @@ strings." (member specific '("TIMESTAMP" "TIMESTAMP_IA"))) (let ((find-ts (lambda (end ts) - (let ((regexp (if (or (string= specific "TIMESTAMP") - (assoc "TIMESTAMP_IA" ts)) - org-ts-regexp - org-ts-regexp-both))) + (let ((regexp (cond + ((string= specific "TIMESTAMP") + org-ts-regexp) + ((string= specific "TIMESTAMP_IA") + org-ts-regexp-inactive) + ((assoc "TIMESTAMP_IA" ts) + org-ts-regexp) + ((assoc "TIMESTAMP" ts) + org-ts-regexp-inactive) + (t org-ts-regexp-both)))) (catch 'next (while (re-search-forward regexp end t) (backward-char) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 04e0843dc..11004f0c8 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -3164,6 +3164,23 @@ Text. "\n" "** H2\n:PROPERTIES:\n:CATEGORY: cat2\n:END:") (cdr (assoc "CATEGORY" (org-entry-properties nil "CATEGORY")))))) + ;; Get "TIMESTAMP" and "TIMESTAMP_IA" properties. + (should + (equal "<2012-03-29 thu.>" + (org-test-with-temp-text "* Entry\n<2012-03-29 thu.>" + (cdr (assoc "TIMESTAMP" (org-entry-properties)))))) + (should + (equal "[2012-03-29 thu.]" + (org-test-with-temp-text "* Entry\n[2012-03-29 thu.]" + (cdr (assoc "TIMESTAMP_IA" (org-entry-properties)))))) + (should + (equal "<2012-03-29 thu.>" + (org-test-with-temp-text "* Entry\n[2014-03-04 tue.]<2012-03-29 thu.>" + (cdr (assoc "TIMESTAMP" (org-entry-properties nil "TIMESTAMP")))))) + (should + (equal "[2014-03-04 tue.]" + (org-test-with-temp-text "* Entry\n<2012-03-29 thu.>[2014-03-04 tue.]" + (cdr (assoc "TIMESTAMP_IA" (org-entry-properties nil "TIMESTAMP_IA")))))) ;; Get standard properties. (should (equal "1" -- 2.11.4.GIT