From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YJTXJAp2d19hXAAA0tVLHw (envelope-from ) for ; Fri, 02 Oct 2020 18:48:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aPGFIAp2d1+KQwAAbx9fmQ (envelope-from ) for ; Fri, 02 Oct 2020 18:48:42 +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 1A2EA9402A4 for ; Fri, 2 Oct 2020 18:48:41 +0000 (UTC) Received: from localhost ([::1]:45470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOQ6h-00046E-4b for larch@yhetil.org; Fri, 02 Oct 2020 14:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOQ4V-0002gh-9v; Fri, 02 Oct 2020 14:46:23 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:37545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kOQ4T-0002uA-DD; Fri, 02 Oct 2020 14:46:22 -0400 Received: by mail-qt1-x82f.google.com with SMTP id m23so2294974qtq.4; Fri, 02 Oct 2020 11:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=HHS1aF3od7Di+T/LgYsVn8LNqJgK4hn+hIUZRMbTgEs=; b=EM3KfVb/ot0fz1Lbc72ZUdRI6gPmKJyoxvj72V4rTkNCU/GSvf8IBikj1G2c8Gu205 NKxl+4WWm/CdwRoVVNpJt08KKOA5HK7eu0VvJCjKKzWcExpolAJOz0SC4UDptSsqNdTQ G+fyfVm+X6yup5zEusarZoc2dliBW53q+BzsjFdOL0yGBve0fMWU6nWoUvIjhmQS5knB GL9a+NZYLmPqTZ0S387sfX73ahB2GsKPS5V3X9uUYCwOdF017fW3Y+trVt+wCFpBXbgd Yxr+k9oyfrb7EovfDhoj3NeGnvLpReBtQLzVqBSGnwQpwSPenrGWiUvrtUe4WCFhKjiF 1DMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=HHS1aF3od7Di+T/LgYsVn8LNqJgK4hn+hIUZRMbTgEs=; b=DC8oonLuHZeRzLfzayhGTM6iV2eZwinNPRhGS6IfIprfnB1aZKVNZregZJDoHH5tfP DvtIM4OemmoYvQo+EdrxHVv4HDlunxCbvPd9/BYYYrArBY4lmygihKo/UbMAwhwx9Pus jQmOTbzN5RgHa54pYNvg86Vc/K0ZNikpNuapaDZwzXAwFIe55u8di5aDidJr4i3dDrpt ewJ7LjvWvUwRdABipu5t/KZC9/yb32h4B/ltOW8lug/dsj0fyb51RRf0/Vo+z8c3/Tg5 boRPDMm1d2CtiG4h84VrtJWqZItn7gbfz34aE3C8KN+qnWida3RUSelqEIAnqeOUjieu eIew== X-Gm-Message-State: AOAM532S4s5hFAvqMjGefGjkRtvwpXH6waL+ND0nz3iBGZr4bga4+U7J jA1WMLM5QT+3MDvTjYqZaSzsGzg056NykQ== X-Google-Smtp-Source: ABdhPJyK6yCsgiA+z2E5KZJ4g/vONUbv4iaxHegbDNLmDOM9ogGYWJYnJUYcQXOKB91+a/mvSnFmGA== X-Received: by 2002:ac8:71cb:: with SMTP id i11mr3697057qtp.108.1601664378844; Fri, 02 Oct 2020 11:46:18 -0700 (PDT) Received: from arch ([2601:8b:c300:1024:1266:d0ff:1635:f964]) by smtp.gmail.com with ESMTPSA id p205sm1635452qke.2.2020.10.02.11.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 11:46:17 -0700 (PDT) References: <87lfgrdegt.fsf@gmail.com> User-agent: mu4e 1.5.5; emacs 28.0.50 From: No Wayman To: emacs-orgmode@gnu.org Cc: emacs-orgmode-request@gnu.org Subject: Re: org-capture at point In-reply-to: <87lfgrdegt.fsf@gmail.com> Date: Fri, 02 Oct 2020 14:46:16 -0400 Message-ID: <87ft6wwjnr.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qt1-x82f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=EM3KfVb/; 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-Spam-Score: -1.71 X-TUID: C+RsnLvdE+fU --=-=-= Content-Type: text/plain; format=flowed > Looks like it was introduced with: > > f5573e6a0 org-capture.el: Fix heading's level when inserting a > template "here" I believe the issue is due to `org-back-to-heading' moving point when calculating the heading level. The attached patch corrects the issue on my end. Tested by running: #+begin_src emacs-lisp :lexical t (dotimes (n 3) (let ((org-capture-templates `(( "e" "test" entry (file "/temp/null.org") ,(format "* %d" n) :immediate-finish t :no-save t)))) (goto-char (point-max)) (org-capture 0 "e"))) #+end_src With a buffer containing: * foo ** one *** two **** three *** four Which results in: * foo ** one *** two **** three *** four *** 0 *** 1 *** 2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-capture.el-Fix-heading-s-position-when-inserting.patch Content-Description: capture-here-position >From 5a35577f22cdc849ebcede6bac7b7f22da7eb16b Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Fri, 2 Oct 2020 14:01:35 -0400 Subject: [PATCH] org-capture.el: Fix heading's position when inserting a template "here" * lisp/org-capture.el (org-capture-place-entry): Fix heading's position when inserting a template "here" with C-0 M-x org-capture. --- lisp/org-capture.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 67c58ffdd..020feb4d6 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1150,10 +1150,11 @@ may have been stored before." (insert-here? ;; FIXME: level should probably set directly within (let ...). (setq level (org-get-valid-level - (if (or (org-at-heading-p) - (ignore-errors (org-back-to-heading t))) - (org-outline-level) - 1)))) + (if (or (org-at-heading-p) + (ignore-errors + (save-excursion (org-back-to-heading t)))) + (org-outline-level) + 1)))) ;; Insert as a child of the current entry. ((org-capture-get :target-entry-p) (setq level (org-get-valid-level -- 2.28.0 --=-=-=--