From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: [PATCH] org-global-tags-completion-table does not include tags from buffers Date: Mon, 19 Mar 2018 10:02:01 -0500 Message-ID: <878tao2jo6.fsf@fastmail.fm> References: <87zi35geo2.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exwIb-0001UF-7p for emacs-orgmode@gnu.org; Mon, 19 Mar 2018 11:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exwIV-0007ub-Jo for emacs-orgmode@gnu.org; Mon, 19 Mar 2018 11:02:09 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:39355) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1exwIV-0007tp-BR for emacs-orgmode@gnu.org; Mon, 19 Mar 2018 11:02:03 -0400 Received: from archpad (wcnat-96-24.wheaton.edu [209.147.96.24]) by mail.messagingengine.com (Postfix) with ESMTPA id 3A62624251 for ; Mon, 19 Mar 2018 11:02:02 -0400 (EDT) In-Reply-To: <87zi35geo2.fsf@fastmail.fm> (Matt Lundin's message of "Sun, 18 Mar 2018 18:14:05 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode --=-=-= Content-Type: text/plain Attached is a patch that fixes the issue. Best, Matt Matt Lundin 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Include-buffer-tags-in-global-tags-completion.patch >From fc09bce2c9efe72a340132a499510658cd03bec2 Mon Sep 17 00:00:00 2001 From: Matt Lundin 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 --=-=-=--