Function: org-toggle-tag

org-toggle-tag is a byte-compiled function defined in org.el.gz.

Signature

(org-toggle-tag TAG &optional ONOFF)

Documentation

Toggle the tag TAG for the current line.

If ONOFF is on or off, don't toggle but set to this state.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-toggle-tag (tag &optional onoff)
  "Toggle the tag TAG for the current line.
If ONOFF is `on' or `off', don't toggle but set to this state."
  (save-excursion
    (org-back-to-heading t)
    (let ((current
	   ;; Reverse the tags list so any new tag is appended to the
	   ;; current list of tags.
	   (nreverse (org-get-tags nil t)))
	  res)
      (pcase onoff
	(`off (setq current (delete tag current)))
	((or `on (guard (not (member tag current))))
	 (setq res t)
	 (cl-pushnew tag current :test #'equal))
	(_ (setq current (delete tag current))))
      (org-set-tags (nreverse current))
      res)))