Parcourir la source

Merge branch 'master' of code.orgmode.org:bzg/org-mode

Bastien il y a 8 ans
Parent
commit
26f54050b6
5 fichiers modifiés avec 87 ajouts et 10 suppressions
  1. 1 1
      lisp/org-colview.el
  2. 7 0
      lisp/org-compat.el
  3. 1 1
      lisp/org.el
  4. 8 8
      testing/lisp/test-org-clock.el
  5. 70 0
      testing/lisp/test-org.el

+ 1 - 1
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."
   "Overlay the newline before the current line with the table title."
   (interactive)
   (interactive)
   (let ((title "")
   (let ((title "")
-	(linum-offset (line-number-display-width 'columns))
+	(linum-offset (org-line-number-display-width 'columns))
 	(i 0))
 	(i 0))
     (dolist (column org-columns-current-fmt-compiled)
     (dolist (column org-columns-current-fmt-compiled)
       (pcase column
       (pcase column

+ 7 - 0
lisp/org-compat.el

@@ -61,6 +61,13 @@
 (defvar org-table-tab-recognizes-table.el)
 (defvar org-table-tab-recognizes-table.el)
 (defvar org-table1-hline-regexp)
 (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
 ;;; Emacs < 25.1 compatibility
 
 

+ 1 - 1
lisp/org.el

@@ -14182,7 +14182,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
     (let ((current
     (let ((current
 	   ;; Reverse the tags list so any new tag is appended to the
 	   ;; Reverse the tags list so any new tag is appended to the
 	   ;; current list of tags.
 	   ;; current list of tags.
-	   (nreverse (org-get-tags)))
+	   (nreverse (org-get-tags nil t)))
 	  res)
 	  res)
       (pcase onoff
       (pcase onoff
 	(`off (setq current (delete tag current)))
 	(`off (setq current (delete tag current)))

+ 8 - 8
testing/lisp/test-org-clock.el

@@ -327,11 +327,11 @@ the buffer."
   ;; Test match filtering.
   ;; Test match filtering.
   (should
   (should
    (equal
    (equal
-    "| Headline   | Time |      |
-|------------+------+------|
+    "| Headline     | Time   |      |
+|--------------+--------+------|
 | *Total time* | *2:00* |      |
 | *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>"
     (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"))
       (insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
       (goto-line 4)
       (goto-line 4)
@@ -343,11 +343,11 @@ the buffer."
   ;; Test tags column.
   ;; Test tags column.
   (should
   (should
    (equal
    (equal
-    "| Tags | Headline   | Time |      |
-|------+------------+------+------|
+    "| Tags | Headline     | Time   |      |
+|------+--------------+--------+------|
 |      | *Total time* | *1:00* |      |
 |      | *Total time* | *1:00* |      |
-|------+------------+------+------|
-| tag  | H1         |      | 1:00 |"
+|------+--------------+--------+------|
+| tag  | H1           |        | 1:00 |"
     (org-test-with-temp-text "** H1 :tag:\n\n*** H2 \n<point>"
     (org-test-with-temp-text "** H1 :tag:\n\n*** H2 \n<point>"
       (insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
       (insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
       (goto-line 4)
       (goto-line 4)

+ 70 - 0
testing/lisp/test-org.el

@@ -6280,6 +6280,76 @@ Paragraph<point>"
 	    (let ((org-tags-column 1)) (org-set-tags-command t))
 	    (let ((org-tags-column 1)) (org-set-tags-command t))
 	    (buffer-string)))))
 	    (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
 ;;; TODO keywords