diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-08-07 11:32:39 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-08-07 11:32:39 +0200 |
commit | 15f112259b69701e693b0eb5cb8fa4879fb646e8 (patch) | |
tree | 904395124a4ad680f330983081e8065fe3d79e07 | |
parent | e28714c3f2dc2691a2dae44da13b7522290799b1 (diff) | |
download | org-mode-15f112259b69701e693b0eb5cb8fa4879fb646e8.tar.gz |
Fix spurious colons next to TODO keywords
* lisp/org.el (org-toggle-tag): Fix spurious colons next to TODO
keywords.
Reported-by: Colin Baxter <m43cap@yandex.com>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-08/msg00075.html>
-rw-r--r-- | lisp/org.el | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/lisp/org.el b/lisp/org.el index ecbf544..9da1da2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14739,30 +14739,24 @@ ignore inherited ones." (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." - (let (res current) - (save-excursion - (org-back-to-heading t) - (if (re-search-forward "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t]*$" - (point-at-eol) t) - (progn - (setq current (match-string 1)) - (replace-match "")) - (setq current "")) - (setq current (nreverse (org-split-string current ":"))) - (cond - ((eq onoff 'on) - (setq res t) - (or (member tag current) (push tag current))) - ((eq onoff 'off) - (or (not (member tag current)) (setq current (delete tag current)))) - (t (if (member tag current) - (setq current (delete tag current)) - (setq res t) - (push tag current)))) - (end-of-line 1) + (save-excursion + (org-back-to-heading t) + (let ((current + (when (re-search-forward "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t]*$" + (point-at-eol) t) + (replace-match "") + (nreverse (org-split-string (match-string 1) ":")))) + 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)))) + (end-of-line) (if current (progn - (insert " :" (mapconcat 'identity (nreverse current) ":") ":") + (insert " :" (mapconcat #'identity (nreverse current) ":") ":") (org-set-tags nil t)) (delete-horizontal-space)) (run-hooks 'org-after-tags-change-hook)) |