summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-18 23:57:51 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-19 11:52:07 +0200
commitedc159c2f2b02b2dcb9b9ac11dc4588b53d653ee (patch)
tree95337ace74c026d29dfc29933ef21ea6d1a9f466
parent2a293843ade5fd276ebdb7fcce030b4f6b1e925f (diff)
downloadorg-mode-edc159c2f2b02b2dcb9b9ac11dc4588b53d653ee.tar.gz
Remove `org-get-tags-string'
* lisp/org.el (org-get-tags-string): Move to "org-compat". (org-make-tag-string): New function (org-set-tags-to): (org-set-tags): (org-set-current-tags-overlay): (org-entry-properties): (org-agenda-prepare-buffers): * lisp/org-mouse.el (org-mouse-set-tags): * lisp/ox-ascii.el (org-ascii--build-title): * lisp/ox-beamer.el (org-beamer-select-environment): * lisp/ox-latex.el (org-latex-format-inlinetask-default-function): * lisp/ox-md.el (org-md-headline): (org-md--build-toc): * lisp/ox-texinfo.el (org-texinfo-format-headline-default-function): (org-texinfo-format-inlinetask-default-function): * contrib/lisp/ox-groff.el (org-groff-headline): (org-groff-inlinetask): Use new function. * lisp/org-compat.el (org-get-tags-string): New function.
-rw-r--r--contrib/lisp/ox-groff.el6
-rw-r--r--lisp/org-compat.el5
-rw-r--r--lisp/org-mouse.el2
-rw-r--r--lisp/org.el38
-rw-r--r--lisp/ox-ascii.el3
-rw-r--r--lisp/ox-beamer.el7
-rw-r--r--lisp/ox-latex.el5
-rw-r--r--lisp/ox-md.el9
-rw-r--r--lisp/ox-texinfo.el8
9 files changed, 40 insertions, 43 deletions
diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el
index 05200b9..14bc2ce 100644
--- a/contrib/lisp/ox-groff.el
+++ b/contrib/lisp/ox-groff.el
@@ -977,8 +977,7 @@ holding contextual information."
(when priority (format " [\\#%c] " priority))
text
(when tags
- (format " \\fC:%s:\\fP "
- (mapconcat 'identity tags ":"))))))
+ (format " \\fC%s\\fP " (org-make-tag-string tags))))))
(full-text-no-tag
(if (functionp org-groff-format-headline-function)
;; User-defined formatting function.
@@ -1120,8 +1119,7 @@ holding contextual information."
(when todo (format "\\fB%s\\fP " todo))
(when priority (format " [\\#%c] " priority))
title
- (when tags (format " \\fC:%s:\\fP "
- (mapconcat 'identity tags ":"))))))
+ (when tags (format " \\fC%s\\fP " (org-make-tag-string tags))))))
(format (concat "\n.DS I\n"
"%s\n"
".sp"
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 7e0e975..2a617d3 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -395,6 +395,11 @@ use of this function is for the stuck project list."
(declare (obsolete "use `org-get-tags' instead." "Org 9.2"))
(org-get-tags pos 'local))
+(defun org-get-tags-string ()
+ "Get the TAGS string in the current headline."
+ (declare (obsolete "use `org-make-tag-string' instead." "Org 9.2"))
+ (org-make-tag-string (org-get-tags nil t)))
+
;;;; Obsolete link types
(eval-after-load 'org
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index b17a7b5..426e218 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -448,7 +448,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
;; set new tags if any
(when tags
(end-of-line)
- (insert " :" (mapconcat 'identity tags ":") ":")
+ (insert " " (org-make-tag-string tags))
(org-set-tags nil t))))
(defun org-mouse-insert-checkbox ()
diff --git a/lisp/org.el b/lisp/org.el
index a53c7b1..f091488 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14211,10 +14211,9 @@ If DATA is nil or the empty string, all tags are removed."
(let ((data
(pcase (if (stringp data) (org-trim data) data)
((or `nil "") nil)
- ((pred listp) (format ":%s:" (mapconcat #'identity data ":")))
+ ((pred listp) (org-make-tag-string data))
((pred stringp)
- (format ":%s:"
- (mapconcat #'identity (org-split-string data ":+") ":")))
+ (org-make-tag-string (org-split-string data ":+")))
(_ (error "Invalid tag specification: %S" data)))))
(org-with-wide-buffer
(org-back-to-heading t)
@@ -14263,7 +14262,7 @@ When JUST-ALIGN is non-nil, only align tags."
(org-set-tags nil t)
(end-of-line))
(message "All tags realigned to column %d" org-tags-column))
- (let* ((current (org-get-tags-string))
+ (let* ((current (org-make-tag-string (org-get-tags nil t)))
(tags
(if just-align current
;; Get a new set of tags from the user.
@@ -14436,7 +14435,7 @@ Also insert END."
(defun org-set-current-tags-overlay (current prefix)
"Add an overlay to CURRENT tag with PREFIX."
- (let ((s (concat ":" (mapconcat 'identity current ":") ":")))
+ (let ((s (org-make-tag-string current)))
(put-text-property 0 (length s) 'face '(secondary-selection org-tag) s)
(org-overlay-display org-tags-overlay (concat prefix s))))
@@ -14642,15 +14641,11 @@ Returns the new tags string, or nil to not change the current settings."
(mapconcat 'identity current ":")
nil))))
-(defun org-get-tags-string ()
- "Get the TAGS string in the current headline."
- (unless (org-at-heading-p t)
- (user-error "Not on a heading"))
- (save-excursion
- (beginning-of-line 1)
- (if (looking-at ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
- (match-string-no-properties 1)
- "")))
+(defun org-make-tag-string (tags)
+ "Return string associated to TAGS.
+TAGS is a list of strings."
+ (if (null tags) ""
+ (format ":%s:" (mapconcat #'identity tags ":"))))
(defun org--get-local-tags ()
"Return list of tags for the current headline.
@@ -15031,14 +15026,15 @@ strings."
props)
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "TAGS"))
- (let ((value (org-string-nw-p (org-get-tags-string))))
- (when value (push (cons "TAGS" value) props)))
+ (let ((tags (org-get-tags nil t)))
+ (when tags
+ (push (cons "TAGS" (org-make-tag-string tags))
+ props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ALLTAGS"))
- (let ((value (org-get-tags)))
- (when value
- (push (cons "ALLTAGS"
- (format ":%s:" (mapconcat #'identity value ":")))
+ (let ((tags (org-get-tags)))
+ (when tags
+ (push (cons "ALLTAGS" (org-make-tag-string tags))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "BLOCKED"))
@@ -17915,7 +17911,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
(pall '(:org-archived t :org-comment t))
(inhibit-read-only t)
(org-inhibit-startup org-agenda-inhibit-startup)
- (rea (concat ":" org-archive-tag ":"))
+ (rea (org-make-tag-string (list org-archive-tag)))
re pos)
(setq org-tag-alist-for-agenda nil
org-tag-groups-alist-for-agenda nil)
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 7184f30..ee83898 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -671,8 +671,7 @@ possible. It doesn't apply to `inlinetask' elements."
(plist-get info :with-tags)
(let ((tag-list (org-export-get-tags element info)))
(and tag-list
- (format ":%s:"
- (mapconcat 'identity tag-list ":"))))))
+ (org-make-tag-string tag-list)))))
(priority
(and (plist-get info :with-priority)
(let ((char (org-element-property :priority element)))
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 38c3530..01cf0c9 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -1076,11 +1076,11 @@ aid, but the tag does not have any semantic meaning."
(org-use-fast-tag-selection t)
(org-fast-tag-selection-single-key t))
(org-set-tags)
- (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
+ (let ((tags (org-get-tags nil t)))
(cond
;; For a column, automatically ask for its width.
((eq org-last-tag-selection-key ?|)
- (if (string-match ":BMCOL:" tags)
+ (if (member "BMCOL" tags)
(org-set-property "BEAMER_col" (read-string "Column width: "))
(org-delete-property "BEAMER_col")))
;; For an "againframe" section, automatically ask for reference
@@ -1096,7 +1096,8 @@ aid, but the tag does not have any semantic meaning."
(read-string "Frame reference (*Title, #custom-id, id:...): "))
(org-set-property "BEAMER_act"
(read-string "Overlay specification: "))))
- ((string-match (concat ":B_\\(" (mapconcat 'car envs "\\|") "\\):") tags)
+ ((let ((tags-re (concat "B_" (regexp-opt (mapcar #'car envs) t))))
+ (cl-some (lambda (tag) (string-match tags-re tag)) tags))
(org-entry-put nil "BEAMER_env" (match-string 1 tags)))
(t (org-entry-delete nil "BEAMER_env"))))))
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 2e89ec7..c67f217 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2132,8 +2132,9 @@ See `org-latex-format-inlinetask-function' for details."
(when priority (format "\\framebox{\\#%c} " priority))
title
(when tags
- (format "\\hfill{}\\textsc{:%s:}"
- (mapconcat #'org-latex--protect-text tags ":"))))))
+ (format "\\hfill{}\\textsc{%s}"
+ (org-make-tag-string
+ (mapcar #'org-latex--protect-text tags)))))))
(concat "\\begin{center}\n"
"\\fbox{\n"
"\\begin{minipage}[c]{.6\\textwidth}\n"
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index e2a000b..960407a 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -211,8 +211,7 @@ a communication channel."
(tags (and (plist-get info :with-tags)
(let ((tag-list (org-export-get-tags headline info)))
(and tag-list
- (format " :%s:"
- (mapconcat 'identity tag-list ":"))))))
+ (concat " " (org-make-tag-string tag-list))))))
(priority
(and (plist-get info :with-priority)
(let ((char (org-element-property :priority headline)))
@@ -589,10 +588,8 @@ contents according to the current headline."
(org-export-get-reference headline info))))
(tags (and (plist-get info :with-tags)
(not (eq 'not-in-toc (plist-get info :with-tags)))
- (let ((tags (org-export-get-tags headline info)))
- (and tags
- (format ":%s:"
- (mapconcat #'identity tags ":")))))))
+ (org-make-tag-string
+ (org-export-get-tags headline info)))))
(concat indentation bullet title tags)))
(org-export-collect-headlines info n (and local keyword)) "\n")
"\n"))
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 0ed6801..e93a6c7 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -914,10 +914,10 @@ holding contextual information."
(todo _todo-type priority text tags)
"Default format function for a headline.
See `org-texinfo-format-headline-function' for details."
- (concat (when todo (format "@strong{%s} " todo))
- (when priority (format "@emph{#%s} " priority))
+ (concat (and todo (format "@strong{%s} " todo))
+ (and priority (format "@emph{#%s} " priority))
text
- (when tags (format " :%s:" (mapconcat 'identity tags ":")))))
+ (and tags (concat " " (org-make-tag-string tags)))))
;;;; Inline Src Block
@@ -955,7 +955,7 @@ See `org-texinfo-format-inlinetask-function' for details."
(concat (when todo (format "@strong{%s} " todo))
(when priority (format "#%c " priority))
title
- (when tags (format ":%s:" (mapconcat #'identity tags ":"))))))
+ (when tags (org-make-tag-string tags)))))
(format "@center %s\n\n%s\n" full-title contents)))
;;;; Italic