From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2GXZGu4GjGAhdQEAgWs5BA (envelope-from ) for ; Fri, 30 Apr 2021 15:32:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id gDJ4Fu4GjGCTKQAAB5/wlQ (envelope-from ) for ; Fri, 30 Apr 2021 13:32:30 +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 DE0E01CEE8 for ; Fri, 30 Apr 2021 15:32:29 +0200 (CEST) Received: from localhost ([::1]:43926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcTFs-0000uW-U1 for larch@yhetil.org; Fri, 30 Apr 2021 09:32:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcSsB-00083i-5e for emacs-orgmode@gnu.org; Fri, 30 Apr 2021 09:07:59 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:41939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcSs9-000116-2Y for emacs-orgmode@gnu.org; Fri, 30 Apr 2021 09:07:58 -0400 Received: by mail-lj1-x22b.google.com with SMTP id a36so69872969ljq.8 for ; Fri, 30 Apr 2021 06:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:cc:date:message-id :mime-version; bh=XQAsHi3kvk19WkgTO7ZaRGgmL4kvIGHLiORD2wXxcG8=; b=XQwrQYADSeb0wncvZLT/WoAuwy99i23sTAfjS9S0Twsd0RhJHac+/LEAGV5167pJqF fEe+Dx22ryf2468h++bquccDnh000oa3R6wDgSTSBAIHIgM/cVznMJC+2XPs6gmnAa+d K9GrPKg8euX4z6bi7bvyFUdZFNj+SIVPIafo8Z46C0BhPwHcfEDAlouOTXUxOvLsgJtM ygYWCtRLKGTsfL18KqXHBJWheZjs+Tol54RVN92k6MxhHmcFCq1fqjhorPBwlxZYNZ+B 2yGuM5KaFkdjRnPooWQJL6mkjMgwwrj2aZDOHShinAwwECCaLpfkdGmhkUw/6R7xun9M q5lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date :message-id:mime-version; bh=XQAsHi3kvk19WkgTO7ZaRGgmL4kvIGHLiORD2wXxcG8=; b=c+0+TANp++WiKzoU47SNeCQctnVuPmbH9W5EUT+Ti+Ub63udYpXoIGzSwRr1Eu1hAr 5LTQs/OBuAb7E8f9Au+OK+IAkUKdZkPM1zAXmSUBzyptb6Ff7xe7PgXl+KNUgUS2lblu LPEJm+QeSN3hfDeLM5Gt2BWQtdLxeJVArf6oKZYQFWjKHY43Jg+wEaPk+D4DlwkHACLj TMVTVowcC0jSyfYGMwlmsgjqqFn4iUSl6K8av4IcGFNaITlVrJ+CMy2tWM1vl2UIPp50 IohdJX50FVXPYUlkZZxBPdl+V7xPxNneaXeTQSwsrEqZQpCd+wL1wZkeW652nki2W7Aj rpWg== X-Gm-Message-State: AOAM531Gun3K738CtI1rZRNBDm2xZzmfE+Juq12IWMsUgI2lJtLbR+3m T+vH1s6hYffXrpr/bS5GbnU= X-Google-Smtp-Source: ABdhPJwTiEt/OWErEjMZFldSZm1QftVmaw+bS8kGokq5VzzKIQvyElzLaV5MCuREVlukR0I6pBQUOA== X-Received: by 2002:a2e:7505:: with SMTP id q5mr3656815ljc.322.1619788074960; Fri, 30 Apr 2021 06:07:54 -0700 (PDT) Received: from localhost ([141.105.67.194]) by smtp.gmail.com with ESMTPSA id d26sm67601lfa.118.2021.04.30.06.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Apr 2021 06:07:54 -0700 (PDT) From: Ihor Radchenko To: Tim Visher Subject: Re: org-attach-attach in an org-capture template? In-Reply-To: References: Date: Fri, 30 Apr 2021 21:12:17 +0800 Message-ID: <877dkjrk5q.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=yantar92@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, RCVD_IN_DNSWL_NONE=-0.0001, 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: Emacs Org Mode mailing list 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=1619789550; h=from:from:sender:sender: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=XQAsHi3kvk19WkgTO7ZaRGgmL4kvIGHLiORD2wXxcG8=; b=XOaA/YVuOBV6BRJ15doGu0n4RtRY7GJgPu/WuwMn4nmYyexL1onj8VrANpLKqi5cfSa+aj sDSl7ZUSB4i7vHOsqQXbiCGlVMZQ5cTXypXqMQ3XySqi7L0Si9qJyD1SUMpZ66QhLQQ2q6 sMhHe46VkeoYXG5PAtLtWBa0OXHevpsOQN6XBGzwMeoB+IcztLu83RxLC7tL0cotQOoQqI i1pvO4O28rfGD8YBJjdqE7EVWfCLAkG92zvtmG0YzrUGVVkZaubkwgJBdE7J1QZRaRhyDh JVaUKeMXCZH6/UacdhdvLH/R4BIvDyH/l9V71yk/HT+Rd5pKTO2yZwTFj91aLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619789550; a=rsa-sha256; cv=none; b=sQbezRyGCM7PFnAZpw1/hpgbEq5hzWtTVq5XjIavtW38IdU0Fic6fnr9jNrExCCkIUB7TV vCqN/omY1s8fNXY9qKYvmOkw4fk+Ksydo1PrCIvCBpyxpwBP4/hgLiuUJh5y/yetgvUu2R PTlZa7fO74SXYEo1Kvcuyfg89cFg4rdveshnkRoGvkY4OtDdqrL6TnA61vyHulInN9/rCX GuTPdMR3Nti7Sg2c0KZ6B6SmGqWb0fFEq7cIsZ/vmMdyUbiyDzVT5ke4m3fIkCUn2NW6li PhvcqGMtxAx/4tHffZ/jTr3PeZyyE5tfuBKdVCzJfTgQ5tbsUJdWy1VGWiDgsQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=XQwrQYAD; 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: -1.66 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=XQwrQYAD; 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: DE0E01CEE8 X-Spam-Score: -1.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: xE+jIbABqqDj Tim Visher writes: > I also believe I could do this with one of the org-capture hooks but > examining them I didn't see the obvious right one to add my function to. I > would think it would be the org-capture-prepare-finalize-hook and I may > just give that a try. Capture hooks should be the right place to do what your want. I recommend org-capture-before-finalize-hook since it will not run if you abort the capture for any reason. Otherwise, you may attach the file, abort capture (via C-c C-k or because of some error), and your attached file will hang somewhere unreferenced. Your first idea with %()-expansion have the same problem. > ... I further assume then that I'd need to to apply the > advice here > > and > check for what template I'm in with (plist-get org-capture-plist :key) or > similar. I recommend using doct [1] with :before-finalize keyword. It will take care that your function runs for the right template. [1] https://github.com/progfolio/doct#hooks > So my question is whether there's anything I can do to get org-attach-attach to > recognize the file it's in. I'm assuming that when it's expanding it's in a > temporary buffer of some kind which is why it's failing. You are right, template expansion is done in separate "*Capture*" buffer using org-capture-fill-template. The buffer is not associated with any file. Best, Ihor