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.
This commit is contained in:
Nicolas Goaziou 2018-04-18 23:57:51 +02:00
parent 2a293843ad
commit edc159c2f2
9 changed files with 40 additions and 43 deletions

View File

@ -977,8 +977,7 @@ holding contextual information."
(when priority (format " [\\#%c] " priority)) (when priority (format " [\\#%c] " priority))
text text
(when tags (when tags
(format " \\fC:%s:\\fP " (format " \\fC%s\\fP " (org-make-tag-string tags))))))
(mapconcat 'identity tags ":"))))))
(full-text-no-tag (full-text-no-tag
(if (functionp org-groff-format-headline-function) (if (functionp org-groff-format-headline-function)
;; User-defined formatting function. ;; User-defined formatting function.
@ -1120,8 +1119,7 @@ holding contextual information."
(when todo (format "\\fB%s\\fP " todo)) (when todo (format "\\fB%s\\fP " todo))
(when priority (format " [\\#%c] " priority)) (when priority (format " [\\#%c] " priority))
title title
(when tags (format " \\fC:%s:\\fP " (when tags (format " \\fC%s\\fP " (org-make-tag-string tags))))))
(mapconcat 'identity tags ":"))))))
(format (concat "\n.DS I\n" (format (concat "\n.DS I\n"
"%s\n" "%s\n"
".sp" ".sp"

View File

@ -395,6 +395,11 @@ use of this function is for the stuck project list."
(declare (obsolete "use `org-get-tags' instead." "Org 9.2")) (declare (obsolete "use `org-get-tags' instead." "Org 9.2"))
(org-get-tags pos 'local)) (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 ;;;; Obsolete link types
(eval-after-load 'org (eval-after-load 'org

View File

@ -448,7 +448,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
;; set new tags if any ;; set new tags if any
(when tags (when tags
(end-of-line) (end-of-line)
(insert " :" (mapconcat 'identity tags ":") ":") (insert " " (org-make-tag-string tags))
(org-set-tags nil t)))) (org-set-tags nil t))))
(defun org-mouse-insert-checkbox () (defun org-mouse-insert-checkbox ()

View File

@ -14211,10 +14211,9 @@ If DATA is nil or the empty string, all tags are removed."
(let ((data (let ((data
(pcase (if (stringp data) (org-trim data) data) (pcase (if (stringp data) (org-trim data) data)
((or `nil "") nil) ((or `nil "") nil)
((pred listp) (format ":%s:" (mapconcat #'identity data ":"))) ((pred listp) (org-make-tag-string data))
((pred stringp) ((pred stringp)
(format ":%s:" (org-make-tag-string (org-split-string data ":+")))
(mapconcat #'identity (org-split-string data ":+") ":")))
(_ (error "Invalid tag specification: %S" data))))) (_ (error "Invalid tag specification: %S" data)))))
(org-with-wide-buffer (org-with-wide-buffer
(org-back-to-heading t) (org-back-to-heading t)
@ -14263,7 +14262,7 @@ When JUST-ALIGN is non-nil, only align tags."
(org-set-tags nil t) (org-set-tags nil t)
(end-of-line)) (end-of-line))
(message "All tags realigned to column %d" org-tags-column)) (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 (tags
(if just-align current (if just-align current
;; Get a new set of tags from the user. ;; Get a new set of tags from the user.
@ -14436,7 +14435,7 @@ Also insert END."
(defun org-set-current-tags-overlay (current prefix) (defun org-set-current-tags-overlay (current prefix)
"Add an overlay to CURRENT tag with 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) (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s)
(org-overlay-display org-tags-overlay (concat prefix 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 ":") (mapconcat 'identity current ":")
nil)))) nil))))
(defun org-get-tags-string () (defun org-make-tag-string (tags)
"Get the TAGS string in the current headline." "Return string associated to TAGS.
(unless (org-at-heading-p t) TAGS is a list of strings."
(user-error "Not on a heading")) (if (null tags) ""
(save-excursion (format ":%s:" (mapconcat #'identity tags ":"))))
(beginning-of-line 1)
(if (looking-at ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
(match-string-no-properties 1)
"")))
(defun org--get-local-tags () (defun org--get-local-tags ()
"Return list of tags for the current headline. "Return list of tags for the current headline.
@ -15031,14 +15026,15 @@ strings."
props) props)
(when specific (throw 'exit props))) (when specific (throw 'exit props)))
(when (or (not specific) (string= specific "TAGS")) (when (or (not specific) (string= specific "TAGS"))
(let ((value (org-string-nw-p (org-get-tags-string)))) (let ((tags (org-get-tags nil t)))
(when value (push (cons "TAGS" value) props))) (when tags
(push (cons "TAGS" (org-make-tag-string tags))
props)))
(when specific (throw 'exit props))) (when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ALLTAGS")) (when (or (not specific) (string= specific "ALLTAGS"))
(let ((value (org-get-tags))) (let ((tags (org-get-tags)))
(when value (when tags
(push (cons "ALLTAGS" (push (cons "ALLTAGS" (org-make-tag-string tags))
(format ":%s:" (mapconcat #'identity value ":")))
props))) props)))
(when specific (throw 'exit props))) (when specific (throw 'exit props)))
(when (or (not specific) (string= specific "BLOCKED")) (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)) (pall '(:org-archived t :org-comment t))
(inhibit-read-only t) (inhibit-read-only t)
(org-inhibit-startup org-agenda-inhibit-startup) (org-inhibit-startup org-agenda-inhibit-startup)
(rea (concat ":" org-archive-tag ":")) (rea (org-make-tag-string (list org-archive-tag)))
re pos) re pos)
(setq org-tag-alist-for-agenda nil (setq org-tag-alist-for-agenda nil
org-tag-groups-alist-for-agenda nil) org-tag-groups-alist-for-agenda nil)

View File

@ -671,8 +671,7 @@ possible. It doesn't apply to `inlinetask' elements."
(plist-get info :with-tags) (plist-get info :with-tags)
(let ((tag-list (org-export-get-tags element info))) (let ((tag-list (org-export-get-tags element info)))
(and tag-list (and tag-list
(format ":%s:" (org-make-tag-string tag-list)))))
(mapconcat 'identity tag-list ":"))))))
(priority (priority
(and (plist-get info :with-priority) (and (plist-get info :with-priority)
(let ((char (org-element-property :priority element))) (let ((char (org-element-property :priority element)))

View File

@ -1076,11 +1076,11 @@ aid, but the tag does not have any semantic meaning."
(org-use-fast-tag-selection t) (org-use-fast-tag-selection t)
(org-fast-tag-selection-single-key t)) (org-fast-tag-selection-single-key t))
(org-set-tags) (org-set-tags)
(let ((tags (or (ignore-errors (org-get-tags-string)) ""))) (let ((tags (org-get-tags nil t)))
(cond (cond
;; For a column, automatically ask for its width. ;; For a column, automatically ask for its width.
((eq org-last-tag-selection-key ?|) ((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-set-property "BEAMER_col" (read-string "Column width: "))
(org-delete-property "BEAMER_col"))) (org-delete-property "BEAMER_col")))
;; For an "againframe" section, automatically ask for reference ;; 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:...): ")) (read-string "Frame reference (*Title, #custom-id, id:...): "))
(org-set-property "BEAMER_act" (org-set-property "BEAMER_act"
(read-string "Overlay specification: ")))) (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))) (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
(t (org-entry-delete nil "BEAMER_env")))))) (t (org-entry-delete nil "BEAMER_env"))))))

View File

@ -2132,8 +2132,9 @@ See `org-latex-format-inlinetask-function' for details."
(when priority (format "\\framebox{\\#%c} " priority)) (when priority (format "\\framebox{\\#%c} " priority))
title title
(when tags (when tags
(format "\\hfill{}\\textsc{:%s:}" (format "\\hfill{}\\textsc{%s}"
(mapconcat #'org-latex--protect-text tags ":")))))) (org-make-tag-string
(mapcar #'org-latex--protect-text tags)))))))
(concat "\\begin{center}\n" (concat "\\begin{center}\n"
"\\fbox{\n" "\\fbox{\n"
"\\begin{minipage}[c]{.6\\textwidth}\n" "\\begin{minipage}[c]{.6\\textwidth}\n"

View File

@ -211,8 +211,7 @@ a communication channel."
(tags (and (plist-get info :with-tags) (tags (and (plist-get info :with-tags)
(let ((tag-list (org-export-get-tags headline info))) (let ((tag-list (org-export-get-tags headline info)))
(and tag-list (and tag-list
(format " :%s:" (concat " " (org-make-tag-string tag-list))))))
(mapconcat 'identity tag-list ":"))))))
(priority (priority
(and (plist-get info :with-priority) (and (plist-get info :with-priority)
(let ((char (org-element-property :priority headline))) (let ((char (org-element-property :priority headline)))
@ -589,10 +588,8 @@ contents according to the current headline."
(org-export-get-reference headline info)))) (org-export-get-reference headline info))))
(tags (and (plist-get info :with-tags) (tags (and (plist-get info :with-tags)
(not (eq 'not-in-toc (plist-get info :with-tags))) (not (eq 'not-in-toc (plist-get info :with-tags)))
(let ((tags (org-export-get-tags headline info))) (org-make-tag-string
(and tags (org-export-get-tags headline info)))))
(format ":%s:"
(mapconcat #'identity tags ":")))))))
(concat indentation bullet title tags))) (concat indentation bullet title tags)))
(org-export-collect-headlines info n (and local keyword)) "\n") (org-export-collect-headlines info n (and local keyword)) "\n")
"\n")) "\n"))

View File

@ -914,10 +914,10 @@ holding contextual information."
(todo _todo-type priority text tags) (todo _todo-type priority text tags)
"Default format function for a headline. "Default format function for a headline.
See `org-texinfo-format-headline-function' for details." See `org-texinfo-format-headline-function' for details."
(concat (when todo (format "@strong{%s} " todo)) (concat (and todo (format "@strong{%s} " todo))
(when priority (format "@emph{#%s} " priority)) (and priority (format "@emph{#%s} " priority))
text text
(when tags (format " :%s:" (mapconcat 'identity tags ":"))))) (and tags (concat " " (org-make-tag-string tags)))))
;;;; Inline Src Block ;;;; Inline Src Block
@ -955,7 +955,7 @@ See `org-texinfo-format-inlinetask-function' for details."
(concat (when todo (format "@strong{%s} " todo)) (concat (when todo (format "@strong{%s} " todo))
(when priority (format "#%c " priority)) (when priority (format "#%c " priority))
title 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))) (format "@center %s\n\n%s\n" full-title contents)))
;;;; Italic ;;;; Italic