From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CKI/FpMp+2FtAQEAgWs5BA (envelope-from ) for ; Thu, 03 Feb 2022 02:02:11 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id oPwiE5Mp+2EmFwEAauVa8A (envelope-from ) for ; Thu, 03 Feb 2022 02:02:11 +0100 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 0009F1C076 for ; Thu, 3 Feb 2022 02:02:10 +0100 (CET) Received: from localhost ([::1]:43114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFQVm-0007Ob-4n for larch@yhetil.org; Wed, 02 Feb 2022 20:02:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFQRm-0007OP-4G for emacs-orgmode@gnu.org; Wed, 02 Feb 2022 19:58:02 -0500 Received: from mout-p-101.mailbox.org ([80.241.56.151]:44716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1nFQRi-0007T4-Lf for emacs-orgmode@gnu.org; Wed, 02 Feb 2022 19:58:01 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:105:465:1:4:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Jq0dT4SBBz9sRM for ; Thu, 3 Feb 2022 01:57:49 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de From: Kevin Foley To: Org Mode List Subject: [PATCH] Org Capture Add Tags with org-toggle-tag Date: Wed, 02 Feb 2022 19:57:38 -0500 Message-ID: <87h79gydfh.fsf@kevinjfoley.me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=80.241.56.151; envelope-from=kevin@kevinjfoley.me; helo=mout-p-101.mailbox.org X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643850131; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=AbD/uoOxNhbwQ29dcwQ2eq3HwjGWdXnO446BfEKPayY=; b=bUvIbwj/1zEErhHoNjAvBdJGSSJFhuheTYZbphWBvfUutWbUfNnrG9mYDZPiSuthgI/dD5 pW4td8bjpBILiQv8S2IvrzFEMFSEeupJrfYGC2TIBt0UVOsACNKyUAGnWhlTR4Jwagdq7z VdloDUbT9MEb3zpEx+nFARCEsQJhJ2/Vl5PpLmnfui5UHmKqze1KJhFuEUdjQ6SrHTjxoI mUWttRBOXkQ1EDGmonYyWBAFxYoYBB0TothOgyUKzhsUsUMP3sngndw4yC4XF6ln09Ow4x 3+ojaziEqg38z8vL4hPClyhUC1ZezT+icS0+d4NGpf1Kyog7TWm8b8bWsN3KhQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643850131; a=rsa-sha256; cv=none; b=ODOprM7yINvy/peIfjFl1xC68CplcT7GYtnMOpEczO5mO2BRR6ikXsOT1xBI4bGF7EwRXa tO9gDmtMKav4d+QBnlgJzg7bESFnoJzWMkGXDoh90PWxB7t2oqSYNIAERc51RvMAiTKY27 obiD9wBC58v4KgLfW8DhDwOaC/3URAtP5D+wbxHsJUZMfPRMJOX2jKjVBVd9vX54O2jZ/j tgTr2JELZtad+9Lc8/GkCqk5CeKordNKx5GfUOJZvDWIa1/GJx/vdV0/Q57fbKavFv8JzX SD7G16IZJ/bmapjF5YFLejiZHP7dRSk79FGj/w9t90Y8jQM00EjTKuqK/Xr0JA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.33 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 0009F1C076 X-Spam-Score: -3.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: PGpZWUZW4TEN --=-=-= Content-Type: text/plain I have a capture template which utilizes %^g to prompt me for a tag to add to a headline which already has a tag. An example to demonstrate is: * TODO %? %^g :foo: If I call this template and give it "bar" when prompted for a tag, it results in (where | is the cursor position): * TODO | :bar: :foo: And bar is recognized as a tag. I've been able to resolve this with the attached patch. However, looking at the git history of that code it seems the intent might have been to prevent some recursive resolution so I'm not sure if this breaks that. I've realized I could also attach the %^g to :foo: tag in the template and things work as expected but if that's the expectation then I think it's worth mentioning in the docstring for org-capture-templates. Thanks, Kevin --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-capture.el.diff diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 5195b785e..b27de40fe 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1753,9 +1753,7 @@ (defun org-capture-fill-template (&optional template initial annotation) 'org-tags-history)) ":"))) (when (org-string-nw-p ins) - (unless (eq (char-before) ?:) (insert ":")) - (insert ins) - (unless (eq (char-after) ?:) (insert ":")) + (org-toggle-tag ins 'on) (when (org-at-heading-p) (org-align-tags))))) ((or "C" "L") (let ((insert-fun (if (equal key "C") #'insert --=-=-=--