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 ms0.migadu.com with LMTPS id pz7CBG9TpGEXWgAAgWs5BA (envelope-from ) for ; Mon, 29 Nov 2021 05:13:35 +0100 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 uAdpO25TpGF/PwAA1q6Kng (envelope-from ) for ; Mon, 29 Nov 2021 04:13:34 +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 60DF62F6A9 for ; Mon, 29 Nov 2021 05:13:34 +0100 (CET) Received: from localhost ([::1]:60310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrY2n-0002Sw-E8 for larch@yhetil.org; Sun, 28 Nov 2021 23:13:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrXf8-0006RM-Jh for emacs-orgmode@gnu.org; Sun, 28 Nov 2021 22:49:06 -0500 Received: from [2a00:1450:4864:20::42f] (port=45780 helo=mail-wr1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mrXf6-0005cR-C6 for emacs-orgmode@gnu.org; Sun, 28 Nov 2021 22:49:06 -0500 Received: by mail-wr1-x42f.google.com with SMTP id o13so33519557wrs.12 for ; Sun, 28 Nov 2021 19:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MTCZNeJ4kitZ7SLGJkYFdyWtgh1W1jlMmUEiA8nvPIA=; b=Pt5gjnyg/QB640US/ODl6mCYAyhxML4ZeDcOXILBDQ4Q2XQhthDk5YlLxvXmSnZImR zKleQSyYGvc2IDNGhPDJunSANOepXxPUyNQQUvRTgJ8MMRdN5gHnhb2xAYjwxdi7WMTO pdpWX9VBnhkq5A1YcWiQE7GTSS/jFned2vHcSYz9VcHvnODHytpN/E9QZksKIPMyLDt+ RJlwa3jacmnMB92U6qDNGipSWREMTvMPc1IF1igtl8NpH2mMPH5yDcZmkUaxbUiVI0/E OxrLNKw3WKmacSpNqw55tqOs3YGdSgRt1p/BuABgaiswEeDrTkejF7q9s8Pu/Zv96Cnc 122A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MTCZNeJ4kitZ7SLGJkYFdyWtgh1W1jlMmUEiA8nvPIA=; b=PVR6KglpaUB45MNA35bZoNdmWzS72X+QB/zxMxfXHBxwNeCY68VAKCpsSNEH6AQzSY EezLPLotU4qVFI+0dCm0FkZARri0Y+D+H0MKCpltkhTk0wCqhVh0aZHyFcycYy4KGLgA yiYsUvTtE3uTJ2qsYzl59JUfQGBagb7hPowa4AHPZsE21hQDXjr9TrjaYrdQ7Dm5BMD7 yyIoi4VQZmN9Z8UIiKLe2ct1O9KNexeve0p4lFmVOLQQKCkQKL40vfAsKh55LlgXMXyJ LqcoEanjiWLzAG+IXhLLMn0usq2wPVmON07j/GSnzA8dHPnI2o/H5sI5KDbuz/HsFu7X yqgg== X-Gm-Message-State: AOAM5336x7byotqK6cxizimsB5lkJ3FzEQWtwFR85Nws/qm/242C9bhQ KzOoEjPBdThYRooJe/VabJ0OFVqs0/Y= X-Google-Smtp-Source: ABdhPJz/tl2Sm9ZYet/Sje7GsSCHLNlSRfQKcA1ufj4V04Dlse6d5WaToc9iAK5Hfum93ehqrmphSA== X-Received: by 2002:a5d:6702:: with SMTP id o2mr31417936wru.108.1638157742125; Sun, 28 Nov 2021 19:49:02 -0800 (PST) Received: from pluto.localnet (aaubervilliers-654-1-90-23.w86-212.abo.wanadoo.fr. [86.212.178.23]) by smtp.gmail.com with ESMTPSA id v15sm12460963wro.35.2021.11.28.19.49.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 19:49:01 -0800 (PST) From: chris To: emacs-orgmode@gnu.org Subject: Re: org-tag-persistent-alist AND per-file dynamic tags Date: Mon, 29 Nov 2021 04:49:00 +0100 Message-ID: <5046398.lFmPd3n6S9@pluto> In-Reply-To: <87ilx5ws5j.fsf@svictor.net> References: <87ilx5ws5j.fsf@svictor.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart17811975.WXT9y3RtGH" Content-Transfer-Encoding: 7Bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=inkbottle007@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638159214; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=MTCZNeJ4kitZ7SLGJkYFdyWtgh1W1jlMmUEiA8nvPIA=; b=bGGSZbfyHikkVXQp6uz0ejfUoEbSwrMJgsFhRI28mb9C1D2A0wW/suD+Yd4bgjpUd+O7dg XuaHn3AS7RYsc17kFb2v2+SNufRUJgKEa+60k2vKc1PWiaB7jwIgVzL2egf0QKEADABF3Y 3CeHKKzY9vnXV9c8fHKrpSJvCSILomYys6/DkSZAhT8W+9Rb6dBUlfoBI5OPh2C70NOvfx ZSLteP8tvEhDWqLyoUTJHFpwW1842FYWbUFRxMargtmKUyZDb3EIdMeiGZgTQ2fhao7BN/ m/RNYPngolvfMc5oDgnu85L3y7BKX1vYr5lnn7isr2pKnRsUUrLAXAYOOHnLAQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638159214; a=rsa-sha256; cv=none; b=IeY4EXlrjaZ+j8V8CPguvnTontOICfRfcCwRlymDo+OkazuwwyHJW9UJwpx7sOiYsisUyr oL5+453n4Af9dK3a0nWjfAPIoVr/uS+tyPgkszXVoJ+m7qYIDbxqwvMzb2lod7dTnJIJnn F2qH7u0nsfUt3rfKGa2i/azIbDiGKjVhAWO7PSEthxZCeTUhQ82koibMPpxbWW+567iVFm 4eYKiQp/AI8BykoCHqIeDn1dc566ZOqB/a6I+1VRpbRqX9CkRK3Pf2ULcnwXeXAgEcoI/5 dmoVyma9aXTlF+uoUVIiytkAoAqupOATt+PPliW5vdQCGGwSiND1erq/EAs0hw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Pt5gjnyg; dmarc=pass (policy=none) header.from=gmail.com; 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-Spam-Score: -2.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Pt5gjnyg; dmarc=pass (policy=none) header.from=gmail.com; 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: 60DF62F6A9 X-Spam-Score: -2.11 X-Migadu-Scanner: scn1.migadu.com X-TUID: CtU84L+wJnlo This is a multi-part message in MIME format. --nextPart17811975.WXT9y3RtGH Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" On Saturday, 6 November 2021 10:10:55 CET Victor A. Stoichita wrote: > Greetings to all, >=20 > Reading the manual about setting glopal/per-file tags [1], I wonder if > it is possible to use org-tag-persistent-alist AND per-file > dynamic tags. I use footnote 53 from https://orgmode.org/manual/Setting-Tags.html[1]. I put my tags in `tags-file.org`, using `#+TAGS:`. I've put the next two lines in `init.el`. (setq org-agenda-files (list "~/path-to/tags-file.org") org-complete-tags-always-offer-all-agenda-tags t) And I have completion on both the tags in `tags-file.org` and tags in the c= urrent buffer. I don't use `org-tag-alist`, so the comments made in https://emacs.stackexc= hange.com/q/ 69369#comment111307_69369[2], would not apply. I use a script to collect the tags, based on Kitchin's https://stackoverflo= w.com/a/ 27527252[3], and help from `#emacs`. I use `with-temp-buffer` because otherwise all the files accessed by `org-m= ap-entries` are=20 showing when I do `C-x C-b` and I find it cumbersome. The tags are sorted by frequency, which is not necessary here, but it's rea= lly nice. I suppose you could put a `defun nice-function-name` on top of it, but so f= ar, it's only a=20 hack. `~/path-to-directory` and `tags-file.org` should be tweaked to your needs. = `default- directory` can be used for the former, too. (caveat: the script makes use of `-flatten`, `-map` and `-uniq, from `dash.= el`. It also=20 makes use of `mapcar` where `-map` would do, `seq-sort` where `-sort` would= do, `seq- reduce` where `-reduce` would do. Standard elisp has `flatten-tree`, for `-= flatten`,=20 `mapcar` for `-map`, `delete-dups` for `-uniq`. https://github.com/Droogans/ unmaintainable-code[4]) (let* ((dir "~/path-to-directory") (all-tags (-flatten (-map (lambda (fpath) (with-temp-buffer (insert-file-contents fpath) (org-mode) (org-map-entries (lambda () (let ((tag-string (car (last (org-heading-components))))) (when tag-string (split-string tag-string ":" t)))) nil nil))) (directory-files-recursively dir "^[^#].*org$"))))) (let ((tags-count (cl-loop for tag in (-uniq all-tags) collect (cons tag (cl-count tag all-tags :test 'string=3D= ))))) (let ((tags-list (mapcar 'car (seq-sort (lambda (a b) (< (cdr b) (cdr a))) tags-c= ount)))) (let ((tags-string (cl-reduce (lambda (a b) (concat a " " b)) tags-list))) (let ((filled-tags-string (with-temp-buffer (setq fill-column 70 fill-prefix "#+TAGS: ") (insert (concat "#+TAGS: " tags-string)) (fill-paragraph) = (buffer-string)))) (with-temp-file "tags-file.org" (insert filled-tags-string))))))) >=20 > When using org-set-tags-command, I=E2=80=99d like to select from a list > comprising both: > 1. the list of predefined tags in org-tag-persistent-alist > 2. the list of all the tags that are already in use in the current > buffer (some of which might not be in the persistent alist). I don=E2= =80=99t > want to use the #+TAGS keyword at file-level, just the list of tags > already attached to some headline in the buffer. >=20 > The manual says: > > If you have globally defined your preferred set of tags using the > > variable org-tag-alist, but would like to use a dynamic tag list in > > a specific file, add an empty =E2=80=98TAGS=E2=80=99 keyword to that fi= le >=20 > And then it says: > > If you have a preferred set of tags that you would like to use in every > > file, in addition to those defined on a per-file basis by =E2=80=98TAGS= =E2=80=99 > > keyword, then you may specify a list of tags with the variable > > org-tag-persistent-alist. >=20 > I tried to combine both behaviors by putting an empty =E2=80=99TAGS=E2=80= =99 keyword at > the top of my file. But this still only gives me the tags in > org-tag-persistent-alist. What would be the best way to add to it for > completion the tags already used in the buffer? >=20 > Regards, --nextPart17811975.WXT9y3RtGH Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8"

On Saturday, 6 November 2021 10:10:55 CET Victor A. Stoichita wrote:

>= ; Greetings to all,

>= ;

>= ; Reading the manual about setting glopal/per-file tags [1], I wonder if

>= ; it is possible to use org-tag-persistent-alist AND per-file

>= ; dynamic tags.


I use footnote 53 from https://orgmode.org/manual/Setting-Tags.html.

I p= ut my tags in `tags-file.org`, using `#+TAGS:`.

I'v= e put the next two lines in `init.el`.


(setq org-agenda-files (list "~/path-to/tags-file.org")

&nb= sp;        org-complete-tags-always-offe= r-all-agenda-tags t)


And I have completion on both the tags in `tags-file.org` and tags in th= e current buffer.

I d= on't use `org-tag-alist`, so the comments made in https://emacs.stackexchange.= com/q/69369#comment111307_69369, would not apply.


I use a script to collect the tags, based on Kitchin's https://stackoverflow.com/a/27527252, a= nd help from `#emacs`.

I u= se `with-temp-buffer` because otherwise all the files accessed by `org-map-= entries` are showing when I do `C-x C-b` and I find it cumbersome.

The= tags are sorted by frequency, which is not necessary here, but it's really= nice.

I s= uppose you could put a `defun nice-function-name` on top of it, but so far,= it's only a hack.

`~/= path-to-directory` and `tags-file.org` should be tweaked to your needs. `de= fault-directory` can be used for the former, too.

(ca= veat: the script makes use of `-flatten`, `-map` and `-uniq, from `dash.el`= =2E It also makes use of `mapcar` where `-map` would do, `seq-sort` where `= =2Dsort` would do, `seq-reduce` where `-reduce` would do. Standard elisp ha= s `flatten-tree`, for `-flatten`, `mapcar` for `-map`, `delete-dups` for `-= uniq`. https://= github.com/Droogans/unmaintainable-code)


(let* ((dir "~/path-to-directory")

&nb= sp;      (all-tags

&nb= sp;       (-flatten

&nb= sp;        (-map

&nb= sp;         (lambda (fpath)

&nb= sp;           (with-temp-= buffer

&nb= sp;            = (insert-file-contents fpath)

&nb= sp;            = (org-mode)

&nb= sp;            = (org-map-entries

&nb= sp;            =   (lambda ()

&nb= sp;            =     (let ((tag-string (car (last (org-heading-components))))= )

&nb= sp;            =       (when tag-string

&nb= sp;            =         (split-string tag-string ":= " t)))) nil nil)))

&nb= sp;         (directory-files-recurs= ively dir "^[^#].*org$")))))

&nb= sp; (let ((tags-count

&nb= sp;        (cl-loop for tag in (-uniq al= l-tags)

&nb= sp;            =      collect (cons tag (cl-count tag all-tags :test 'st= ring=3D)))))

&nb= sp;   (let ((tags-list

&nb= sp;          (mapcar 'car (seq= =2Dsort (lambda (a b) (< (cdr b) (cdr a))) tags-count))))

&nb= sp;     (let ((tags-string

&nb= sp;            (cl-r= educe (lambda (a b) (concat a " " b)) tags-list)))

&nb= sp;       (let ((filled-tags-string

&nb= sp;            =   (with-temp-buffer

&nb= sp;            =     (setq fill-column 70

&nb= sp;            =           fill-prefix "#+= TAGS: ")

&nb= sp;            =     (insert (concat "#+TAGS: " tags-string)) (fill= =2Dparagraph) (buffer-string))))

&nb= sp;         (with-temp-file "t= ags-file.org" (insert filled-tags-string)))))))



>

>= ; When using org-set-tags-command, I=E2=80=99d like to select from a list

>= ; comprising both:

>= ; 1. the list of predefined tags in org-tag-persistent-alist

>= ; 2. the list of all the tags that are already in use in the current

>= ;    buffer (some of which might not be in the persistent al= ist). I don=E2=80=99t

>= ;    want to use the #+TAGS keyword at file-level, just the = list of tags

>= ;    already attached to some headline in the buffer.

>= ;

>= ; The manual says:

>= ; > If you have globally defined your preferred set of tags using the

>= ; > variable org-tag-alist, but would like to use a dynamic tag list in<= /p>

>= ; > a specific file, add an empty =E2=80=98TAGS=E2=80=99 keyword to that= file

>= ;

>= ; And then it says:

>= ; > If you have a preferred set of tags that you would like to use in ev= ery

>= ; > file, in addition to those defined on a per-file basis by =E2=80=98T= AGS=E2=80=99

>= ; > keyword, then you may specify a list of tags with the variable

>= ; > org-tag-persistent-alist.

>= ;

>= ; I tried to combine both behaviors by putting an empty =E2=80=99TAGS=E2=80= =99 keyword at

>= ; the top of my file. But this still only gives me the tags in

>= ; org-tag-persistent-alist. What would be the best way to add to it for

>= ; completion the tags already used in the buffer?

>= ;

>= ; Regards,

>= ; Victor

>= ;

>= ; Footnotes:

>= ; [1]  https://orgmode.org/manual/Setting-Tags.html



--nextPart17811975.WXT9y3RtGH--