emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Bug] org-global-tags-completion-table does not include tags from buffers
@ 2018-03-18 23:14 Matt Lundin
  2018-03-19 15:02 ` [PATCH] " Matt Lundin
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Lundin @ 2018-03-18 23:14 UTC (permalink / raw)
  To: Org Mode

If org-tags-alist is customized by the user, the value returned by
org-global-tags-completion-table does not include any tags from agenda
buffers and files.

This behavior contradicts the docstring of
org-global-tags-completion-table, which claims to return the list of all
tags in all agenda buffer/files.

I believe this bug was introduced with commit
4743d43dd8e448b6c440b1e4988bcd353de60cc7 in April 2016. Before that
commit, Org mode appended tags in org-tags-alist to tags gathered from
the buffer. After the commit, Org mode no longer gathers buffer tags if
org-tags-alist is defined.

Line 13731 is the key line:

        (or org-current-tag-alist (org-get-buffer-tags)))

AFAICT, org-current-tag-alist only includes tags defined in
org-tag-alist and org-tag-persistent-alist. So if these are defined, the
function will never gather the buffer tags.

As an aside, this bug makes filtering the agenda by filetags or tags in
org buffers impossible due to commit
404ac42ee51f0ac0d9cfb8fbefaefbbe96c61017, which requires a match for tag
completion when hitting "/ [TAB]" in the agenda. Since
org-global-tags-completion-table does not actually return the tags in
buffers, it is impossible to filter by them.

I can reproduce this with emacs -Q (emacs 25.3 and Org mode from git).

Best,
Matt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] org-global-tags-completion-table does not include tags from buffers
  2018-03-18 23:14 [Bug] org-global-tags-completion-table does not include tags from buffers Matt Lundin
@ 2018-03-19 15:02 ` Matt Lundin
  2018-03-21  1:01   ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Lundin @ 2018-03-19 15:02 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]

Attached is a patch that fixes the issue.

Best,
Matt

Matt Lundin <mdl@imapmail.org> writes:

> If org-tags-alist is customized by the user, the value returned by
> org-global-tags-completion-table does not include any tags from agenda
> buffers and files.
>
> This behavior contradicts the docstring of
> org-global-tags-completion-table, which claims to return the list of all
> tags in all agenda buffer/files.
>
> I believe this bug was introduced with commit
> 4743d43dd8e448b6c440b1e4988bcd353de60cc7 in April 2016. Before that
> commit, Org mode appended tags in org-tags-alist to tags gathered from
> the buffer. After the commit, Org mode no longer gathers buffer tags if
> org-tags-alist is defined.
>
> Line 13731 is the key line:
>
>         (or org-current-tag-alist (org-get-buffer-tags)))
>
> AFAICT, org-current-tag-alist only includes tags defined in
> org-tag-alist and org-tag-persistent-alist. So if these are defined, the
> function will never gather the buffer tags.
>
> As an aside, this bug makes filtering the agenda by filetags or tags in
> org buffers impossible due to commit
> 404ac42ee51f0ac0d9cfb8fbefaefbbe96c61017, which requires a match for tag
> completion when hitting "/ [TAB]" in the agenda. Since
> org-global-tags-completion-table does not actually return the tags in
> buffers, it is impossible to filter by them.
>
> I can reproduce this with emacs -Q (emacs 25.3 and Org mode from git).
>
> Best,
> Matt


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Include-buffer-tags-in-global-tags-completion.patch --]
[-- Type: text/x-patch, Size: 1183 bytes --]

From fc09bce2c9efe72a340132a499510658cd03bec2 Mon Sep 17 00:00:00 2001
From: Matt Lundin <mdl@imapmail.org>
Date: Mon, 19 Mar 2018 09:53:15 -0500
Subject: [PATCH] Include buffer tags in global tags completion 

* lisp/org.el: (org-global-tags-completion-table): Return all tags,
  including tags in the buffer. This fixes a bug that caused buffer
  tags to be excluded if user configured tags either via org-tag-alist
  or the #+TAGS keyword.
---
 lisp/org.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 73ab32aa0..44b57a60d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13724,10 +13724,11 @@ instead of the agenda files."
 		  (mapcar
 		   (lambda (file)
 		     (set-buffer (find-file-noselect file))
-		     (mapcar (lambda (x)
-			       (and (stringp (car-safe x))
-				    (list (car-safe x))))
-			     (or org-current-tag-alist (org-get-buffer-tags))))
+		     (append (org-get-buffer-tags)
+			     (mapcar (lambda (x)
+				       (and (stringp (car-safe x))
+					    (list (car-safe x))))
+				     org-current-tag-alist)))
 		   (if (car-safe files) files
 		     (org-agenda-files))))))))
 
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] org-global-tags-completion-table does not include tags from buffers
  2018-03-19 15:02 ` [PATCH] " Matt Lundin
@ 2018-03-21  1:01   ` Bastien
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2018-03-21  1:01 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Org Mode

Hi Matt,

Matt Lundin <mdl@imapmail.org> writes:

> Attached is a patch that fixes the issue.

Thanks a lot, applied -- together with some other fixes related to
group tags.  Can you check and report any problems?

-- 
 Bastien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-21  1:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-18 23:14 [Bug] org-global-tags-completion-table does not include tags from buffers Matt Lundin
2018-03-19 15:02 ` [PATCH] " Matt Lundin
2018-03-21  1:01   ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).