From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id gESpN3/JPmeWdgAA62LTzQ:P1 (envelope-from ) for ; Thu, 21 Nov 2024 05:47:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id gESpN3/JPmeWdgAA62LTzQ (envelope-from ) for ; Thu, 21 Nov 2024 06:47:43 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iKFR9duj; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1732168063; a=rsa-sha256; cv=none; b=SA0Iqf67ptXUjpspKbAsm8LQ9pVhWn3y28jdSntQdvia/c3Fq5RgviP7cw2Oidtm+j9pr9 8xccoc/PhAHLZ+zqEuM7bW/sV0VLwLUkGa0jKYe2glkmWPmtaIOP+b3/Dryl1mBbvMzfqU UVDZINz1BU5NZ+uRu1SiZdoKJw9zK2zZveciu0/k6L9HnqRBgBuuPRYBYGLRCekR7HVALb 4o1eaeV4wqpUveXjotBKKdEPtu12h+plX9kNM0d9WLfkB8/rpiqzXEV13mNsTotiWJH+2f /0ZvUaq06+bIQmQZRe1xxfg5bLrjerR/5qjCmaHlvfVXVFSq6xEnFQUVKM4etA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iKFR9duj; dmarc=pass (policy=none) header.from=gmail.com; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1732168063; 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:dkim-signature; bh=08bvSZ6GqjS+wVWVkjxKdriAukCoxETgoX2luo3hRP0=; b=rarB4hV5A4h6d8Vf9Wm81Ntd0D8jFy952xD/Qp8qLNffxB5Ku0g0Bo9bKhy5SlX0XY2xQr xbxLX4AzaQ5AFFvP/ZcF6UOC8YsN1XGCro8KrFboOoFpIzFzzbQ83iExbxINnIWLZCSaBv OCO2niAqYo44+xbpd68RARoOK2EiHOL8lMuaFnk7J8/gqviVoRlteI+YFyJTv10HQi0JLQ dkAArezOs568Ihb1/i+aly1SVyTmD85+U0UX3saoBZ6HgHl+n1xsSBqQzQEa210qQ+y896 LeCJHEFiPFfkJwhIZRwQbyw57VK42OZD7ieL6QiOs26g5sgYW7qxOChLJV3szw== 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 B2A1C57DEF for ; Thu, 21 Nov 2024 06:47:43 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE01w-0008B7-3a; Thu, 21 Nov 2024 00:47:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tE01u-0008Aj-O0 for emacs-orgmode@gnu.org; Thu, 21 Nov 2024 00:47:02 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE01t-0000Lk-5N for emacs-orgmode@gnu.org; Thu, 21 Nov 2024 00:47:02 -0500 Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-21116b187c4so3734355ad.3 for ; Wed, 20 Nov 2024 21:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732168019; x=1732772819; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=08bvSZ6GqjS+wVWVkjxKdriAukCoxETgoX2luo3hRP0=; b=iKFR9duju3DNLrX1Rqu3oBcyrJnWzI/xCbigHeSYMOZuk+UEPr9gUg+NC7heQxM8Za Sl8yFWedsGcw32Oy+fNWwbLL1ii3Rmii9YQ9q7dgUbhGI4tYNLWMbhAypAeOLQG04vFa zx68yiSLC8I3IKgQFZ327rqHlXhGbPGN/XP4lDsd+lMjFSrYfdEMzWG9bxol7eWtCEgy okQbG3iCfZhJLxES1sTrMIgi6SlZg/bia3Ck4B/kOYLIuynrV54v+OqnMXYZLZ6Hav17 BnjlYTEeP4eQvCWeFaGT/+k7q8YFfRplIBwmpfb52pkSP9YWQuqrVV9Q4A+nfoNkXBZg eWEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732168019; x=1732772819; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=08bvSZ6GqjS+wVWVkjxKdriAukCoxETgoX2luo3hRP0=; b=HTgnV0uCmelnr4geLDAIqu4QpUcSdoZGYBj1vi7KZJf+SSd0aCgbb0fxmkwkSHcJXX YEbSRDAWc+ZOYYuGP4/NIeSdQfAOGAONMdG8a2SQ/IwMF3eJTnMpO8LVz+H/0U/0xlJr Hc/MzbrmYAfSr4H91XUNo3t9Id2r/NYFvtCWDqSTRkZzZGFV9S+C2siK09cCPBrcYzZM T4IIufh86pPLlFevsfr2MZ3SG/pih6K9JYcUJCP0/i80KA7I3N6M+ndSIoS8R3qzqbMX ZX18FONZSAK7MhAA9OSeyTYALqKgEr+TeywfK535et6fSYyOB2cKcx41f9uXreBt/arw 0k+Q== X-Gm-Message-State: AOJu0YzInXlgk7tnaeXPsAie7TlKhFfwohXFjvCrjtNnxeyTqz5h1Ij0 qKO/5mCRQ2LmuZZQieZUUuTrgIVpxrEiaoHPvf51XZpAF87o5rK1vgGeX7q92Lo= X-Google-Smtp-Source: AGHT+IE+d5h8rzKZygMS42KkZklvzf84f0b9euTPEAee1pB/TXGndH721bkxHGDxzMKIvIsLjX21oA== X-Received: by 2002:a17:902:ebce:b0:20b:a9f3:796d with SMTP id d9443c01a7336-2126a475220mr64208685ad.44.1732168018689; Wed, 20 Nov 2024 21:46:58 -0800 (PST) Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212878a9287sm5192015ad.78.2024.11.20.21.46.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 21:46:57 -0800 (PST) From: Visuwesh To: org-mode-email Subject: Bad interaction between org-capture entry type and file+function target? Date: Thu, 21 Nov 2024 11:16:45 +0530 Message-ID: <87h681b0l6.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x642.google.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, 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.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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: B2A1C57DEF X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -5.28 X-Spam-Score: -5.28 X-TUID: xDYwTHxO2rPe --=-=-= Content-Type: text/plain In the attached file "test.org", I want to capture new headings above "Projects" always. To achieve this, I used a file+function target to move the point above "Projects" like below (let* ((heading "test") (file "tttt.pdf") (org-capture-templates `(("n" "blah" entry (file+function "/tmp/test.org" ,(lambda () (goto-char (point-min)) (re-search-forward "^\\* Projects") (goto-char (match-beginning 0)) (insert "\n") (forward-char -1))) ,(concat "* " heading "\n" ":PROPERTIES:\n" ":NOTER_DOCUMENT: " file "\n" ":END:\n\n") :immediate-finish t :empty-lines-before 1)))) (org-capture nil "n")) However, when evaluating this sexp, the heading "test" is always appended to the end of file contrary to what the docstring says: (file+function "path/to/file" function-finding-location) A function to find the right location in the file This is because of the 'else' clause in the cond form in org-capture-place-entry: (when exact-position (goto-char exact-position)) (cond ;; Force insertion at point. (insert-here? ....) ;; Insert as a child of the current entry. ((org-capture-get :target-entry-p) ...) ;; Insert as a top-level entry at the beginning of the file. (reversed? ...) ;; Otherwise, insert as a top-level entry at the end of the file. (t (goto-char (point-max)) ^^^^^^^^^^^^^^^^^^^^^^^ ;; Make sure that last point is not folded. (org-fold-core-cycle-over-indirect-buffers (org-fold-region (max 1 (1- (point-max))) (point-max) nil)))) Should this be here? Am I misunderstanding the documentation? After all, it is too terse (the same text is in the Info manual too). The documentation for the 'entry' type does not mention this quirk either: entry an Org node, with a headline. Will be filed as the child of the target entry or as a top-level entry. Its default template is: "* %?\n%a" The documentation for :prepend does mention that entries will be inserted at the end if it is nil but I would think that using a function would rule this out. Changing the type to 'plain' from 'entry' works as expected though. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=test.org * Heading 1 blah blah blah * Heading 2 AAAAAAAA * Projects ** Some subheading something else here * Glossary ** Some more subheading something here --=-=-=--