From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wKuROaV7+18PCgAA0tVLHw (envelope-from ) for ; Sun, 10 Jan 2021 22:11:49 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 6AFjNaV7+19YLwAA1q6Kng (envelope-from ) for ; Sun, 10 Jan 2021 22:11:49 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0004D9402D6 for ; Sun, 10 Jan 2021 22:11:48 +0000 (UTC) Received: from localhost ([::1]:49682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyiw7-0007p7-Vd for larch@yhetil.org; Sun, 10 Jan 2021 17:11:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyivH-0007ox-7b for emacs-orgmode@gnu.org; Sun, 10 Jan 2021 17:10:55 -0500 Received: from out1.migadu.com ([91.121.223.63]:24282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyivE-00049N-JN for emacs-orgmode@gnu.org; Sun, 10 Jan 2021 17:10:54 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1610316649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lzpLz+36A4ZrIUu5ydLtkZ2OiE/AI2s+KsoIB2rXnjA=; b=oLa96VlgvSloJ42U6Pk0aR4t4ZhNRi8/3uA+pWiHWXV4xb3sDMJ40ePXNKxtM6aX/QgLi9 1L/6ynak536kHB5XJWrrQbuAkHVTaH8olJb0VD9U1dMEYRq62wUY1q7U9TeasHLjmM9wVt Ko9Jvwsf3wbll4PrlLjH3nzQx3IL8p+ZZklgEaNxcjvH6m7qpGWBLz51c7fqSGXsIqODKx TjxSVy2SME7h4399UASc0ziG4MHaZE7/lcjoH2KDB++JaULRUl/wrXkP9En+hEogjcFooF j926/FkZHT9bkW+55RxBOR3y73jpcNvq0fFsdA7MsP6v6W8g7HMGQVCk1xbzmg== From: Kyle Meyer To: stardiviner Subject: Re: [PATCH] I updated patch by deleteing duplicate tags In-Reply-To: References: Message-ID: <87sg78phnc.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Auth-User: kyle@kyleam.com Date: Sun, 10 Jan 2021 22:10:49 GMT Received-SPF: pass client-ip=91.121.223.63; envelope-from=kyle@kyleam.com; helo=out1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.55 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=kyleam.com header.s=key1 header.b=oLa96Vlg; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 0004D9402D6 X-Spam-Score: -2.55 X-Migadu-Scanner: scn1.migadu.com X-TUID: vBhKo8gzfAS+ Thanks for the patch. stardiviner writes: > On Wed, Dec 2, 2020 at 5:30 PM stardiviner wrote: > >> The default [C-c C-q] completing tags only retrieve tags from current >> buffer locally. >> >> By this patch, will merge both buffer-local tags and user defined global >> `org-tags-alist`. It does a bit more than that. It uses org-global-tags-completion-table, which considers tags in all agenda files by default and takes into account org-tag-alist (as well as org-tag-persistent-alist) via the use of the org-current-tag-alist variable. >> This is more reasonable. I'd guess that depends on the user. I personally wouldn't like to see tags from all of my agenda files, and I'm fine not seeing org-tag{-persistent}-alist ones that aren't in the current buffer given that they have fast selection keys. > Subject: [PATCH] org.el: Complete tags from both global and buffer local > > * lisp/org.el: (org-fast-tag-selection): merge buffer local tags with > global alist of tags. Convention/consistency nits: spurious ":" after ".el" and s/merge/Merge/. > --- > lisp/org.el | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 0e12e4b15..287b8c407 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -12256,10 +12256,13 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table) > (condition-case nil > (setq tg (completing-read > "Tag: " > - (or buffer-tags > - (with-current-buffer buf > - (setq buffer-tags > - (org-get-buffer-tags)))))) > + (delq nil > + (delete-dups > + (append (or buffer-tags > + (with-current-buffer buf > + (setq buffer-tags > + (org-get-buffer-tags)))) > + (org-global-tags-completion-table)))))) This change in behavior should come with a NEWS entry and a documentation update. What the manual currently says is now stale: - {{{kbd(TAB)}}} :: #+kindex: TAB Enter a tag in the minibuffer, even if the tag is not in the predefined list. You can complete on all tags present in the buffer. You can also add several tags: just separate them with a comma. As I mentioned above, though, I'm not sure always adding agenda tags is desirable. However, I think it'd probably be safe to look at org-complete-tags-always-offer-all-agenda-tags as an indication of whether the user wants this behavior. org-set-tags-command already considers that option when it generates the table that it passes to org-fast-tag-selection. So perhaps we could just consider the table when calling completing-read for the tab key (something along the lines of the patch at the end of the email). Conceptually that's been discussed/tried before, but it was then backed out of: * https://orgmode.org/list/F753E612-2D5D-4BA7-AF0C-D49C7A8DDA24@pobox.com/T/#u * 647396464 (org.el: Include tags from `org-tag-alist' when completing with the TAB key, 2012-03-27) * d4ddcbb8b (Revert "org.el: Include tags from `org-tag-alist' when completing with the TAB key.", 2012-04-10) * acc7a0b2b (org.el: Include `org-tag-alist' in the list for tag completions, 2012-03-27) At a quick glance, I think the patch below avoids the problems that led to 647396464 being reverted, but that'd need to be checked more carefully. diff --git a/lisp/org.el b/lisp/org.el index 5b0ae389c..9383719e3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12139,7 +12139,7 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table) fulltable)))) (buf (current-buffer)) (expert (eq org-fast-tag-selection-single-key 'expert)) - (buffer-tags nil) + (tab-tags nil) (fwidth (+ maxlen 3 1 3)) (ncol (/ (- (window-width) 4) fwidth)) (i-face 'org-done) @@ -12274,16 +12274,22 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table) (setq current nil) (when exit-after-next (setq exit-after-next 'now))) ((= c ?\t) + (unless tab-tags + (setq tab-tags + (delq nil + (mapcar (lambda (x) + (let ((item (car-safe x))) + (and (stringp item) + (list item)))) + (org--tag-add-to-alist + (with-current-buffer buf + (org-get-buffer-tags)) + table))))) (condition-case nil - (setq tg (completing-read - "Tag: " - (or buffer-tags - (with-current-buffer buf - (setq buffer-tags - (org-get-buffer-tags)))))) + (setq tg (completing-read "Tag: " tab-tags)) (quit (setq tg ""))) (when (string-match "\\S-" tg) - (cl-pushnew (list tg) buffer-tags :test #'equal) + (cl-pushnew (list tg) tab-tags :test #'equal) (if (member tg current) (setq current (delete tg current)) (push tg current)))