summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2018-04-28 08:06:20 +0200
committerBastien <bzg@gnu.org>2018-04-28 08:06:20 +0200
commit26f54050b69816362a981cb2c83834a908534329 (patch)
treee6f8bba617928c0b826e2e0512c7c0c9d5331d2a
parent39b9a12bab3ec935191ff50906ce56e58879bbe1 (diff)
parentc7c8370dfbbbc2fd4e9238f6571981ef1bf1c154 (diff)
downloadorg-mode-26f54050b69816362a981cb2c83834a908534329.tar.gz
Merge branch 'master' of code.orgmode.org:bzg/org-mode
-rw-r--r--lisp/org-colview.el2
-rw-r--r--lisp/org-compat.el7
-rw-r--r--lisp/org.el2
-rw-r--r--testing/lisp/test-org-clock.el16
-rw-r--r--testing/lisp/test-org.el70
5 files changed, 87 insertions, 10 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 65d6c54..cf63148 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -448,7 +448,7 @@ for the duration of the command.")
"Overlay the newline before the current line with the table title."
(interactive)
(let ((title "")
- (linum-offset (line-number-display-width 'columns))
+ (linum-offset (org-line-number-display-width 'columns))
(i 0))
(dolist (column org-columns-current-fmt-compiled)
(pcase column
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index f6dd128..c43160a 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -62,6 +62,13 @@
(defvar org-table1-hline-regexp)
+;;; Emacs < 26.1 compatibility
+
+(if (fboundp 'line-number-display-width)
+ (defalias 'org-line-number-display-width 'line-number-display-width)
+ (defun org-line-number-display-width (&rest _) 0))
+
+
;;; Emacs < 25.1 compatibility
(when (< emacs-major-version 25)
diff --git a/lisp/org.el b/lisp/org.el
index 901b4b3..9f92649 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14182,7 +14182,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
(let ((current
;; Reverse the tags list so any new tag is appended to the
;; current list of tags.
- (nreverse (org-get-tags)))
+ (nreverse (org-get-tags nil t)))
res)
(pcase onoff
(`off (setq current (delete tag current)))
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index e446af4..c27d3f1 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -327,11 +327,11 @@ the buffer."
;; Test match filtering.
(should
(equal
- "| Headline | Time | |
-|------------+------+------|
+ "| Headline | Time | |
+|--------------+--------+------|
| *Total time* | *2:00* | |
-|------------+------+------|
-| H1 | | 2:00 |"
+|--------------+--------+------|
+| H1 | | 2:00 |"
(org-test-with-temp-text "** H1\n\n*** H2 :tag:\n\n*** H3\n<point>"
(insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
(goto-line 4)
@@ -343,11 +343,11 @@ the buffer."
;; Test tags column.
(should
(equal
- "| Tags | Headline | Time | |
-|------+------------+------+------|
+ "| Tags | Headline | Time | |
+|------+--------------+--------+------|
| | *Total time* | *1:00* | |
-|------+------------+------+------|
-| tag | H1 | | 1:00 |"
+|------+--------------+--------+------|
+| tag | H1 | | 1:00 |"
(org-test-with-temp-text "** H1 :tag:\n\n*** H2 \n<point>"
(insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
(goto-line 4)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index db4909b..6966a79 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -6280,6 +6280,76 @@ Paragraph<point>"
(let ((org-tags-column 1)) (org-set-tags-command t))
(buffer-string)))))
+(ert-deftest test-org/toggle-tag ()
+ "Test `org-toggle-tag' specifications."
+ ;; Insert missing tag.
+ (should
+ (equal "* H :tag:"
+ (org-test-with-temp-text "* H"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag"))
+ (buffer-string))))
+ (should
+ (equal "* H :tag1:tag2:"
+ (org-test-with-temp-text "* H :tag1:"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag2"))
+ (buffer-string))))
+ ;; Remove existing tag.
+ (should
+ (equal "* H"
+ (org-test-with-temp-text "* H :tag:"
+ (org-toggle-tag "tag")
+ (buffer-string))))
+ (should
+ (equal "* H :tag1:"
+ (org-test-with-temp-text "* H :tag1:tag2:"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag2"))
+ (buffer-string))))
+ (should
+ (equal "* H :tag2:"
+ (org-test-with-temp-text "* H :tag1:tag2:"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag1"))
+ (buffer-string))))
+ ;; With optional argument ONOFF set to `on', try to insert the tag,
+ ;; even if its already there.
+ (should
+ (equal "* H :tag:"
+ (org-test-with-temp-text "* H"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag" 'on))
+ (buffer-string))))
+ (should
+ (equal "* H :tag:"
+ (org-test-with-temp-text "* H :tag:"
+ (let ((org-tags-column 1)) (org-toggle-tag "tag" 'on))
+ (buffer-string))))
+ ;; With optional argument ONOFF set to `off', try to remove the tag,
+ ;; even if its not there.
+ (should
+ (equal "* H"
+ (org-test-with-temp-text "* H :tag:"
+ (org-toggle-tag "tag" 'off)
+ (buffer-string))))
+ (should
+ (equal "* H :tag:"
+ (org-test-with-temp-text "* H :tag:"
+ (let ((org-tags-column 1)) (org-toggle-tag "foo" 'off))
+ (buffer-string))))
+ ;; Special case: Handle properly tag inheritance. In particular, do
+ ;; not set inherited tags.
+ (should
+ (equal "* H1 :tag:\n** H2 :tag2:tag:"
+ (org-test-with-temp-text "* H1 :tag:\n** <point>H2 :tag2:"
+ (let ((org-use-tag-inheritance t)
+ (org-tags-column 1))
+ (org-toggle-tag "tag"))
+ (buffer-string))))
+ (should
+ (equal "* H1 :tag1:tag2:\n** H2 :foo:"
+ (org-test-with-temp-text "* H1 :tag1:tag2:\n** <point>H2"
+ (let ((org-use-tag-inheritance t)
+ (org-tags-column 1))
+ (org-toggle-tag "foo"))
+ (buffer-string)))))
+
;;; TODO keywords