From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uN5VJ3HZ0GLjFgEAbAwnHQ (envelope-from ) for ; Fri, 15 Jul 2022 05:05:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id KENeJ3HZ0GJuZgEA9RJhRA (envelope-from ) for ; Fri, 15 Jul 2022 05:05:21 +0200 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 30E2A2EFED for ; Fri, 15 Jul 2022 05:05:21 +0200 (CEST) Received: from localhost ([::1]:36876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oCBdo-0006uz-E3 for larch@yhetil.org; Thu, 14 Jul 2022 23:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oC6Jq-0005XT-CI for emacs-orgmode@gnu.org; Thu, 14 Jul 2022 17:24:22 -0400 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]:38461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oC6Jo-00048W-G2 for emacs-orgmode@gnu.org; Thu, 14 Jul 2022 17:24:21 -0400 Received: by mail-il1-x136.google.com with SMTP id c17so654934ilq.5 for ; Thu, 14 Jul 2022 14:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chasecaleb-com.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=lzqJ50rws2Vk0IYTOldi4Q2C+stHBPD6gkwn1SG9xRA=; b=gGmF54FG76WtgVXBlVf5CrNGHdMBFlMyaFl7+oSuZyyEFib6p0eYD+FMKO4gpc2P7V kFWtgx1pm82qZNOeMTVLBTPP3hx5IRwTl0O5zYPyyQzDXik5WzNJyLkyfnM+yFJU8Mpo PcXB/s/nN0TIMRp73/t1E7Qy+OAoSY0za8jrbf0EKuYVBiQrq6adEvAgim+/3YVPd6G9 dzDPMsFWF8CXbQU5f9xLH43OtonnhHfjL5s7XiijI05aouUbwIA5i3onTdGx8kOXvsr2 WPewpfKcTDvaSphRof5WmFXxuEgSPAJFIWSMNSgIAOrD9K7H//swsKMzv0RVMB72QuKL oeiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lzqJ50rws2Vk0IYTOldi4Q2C+stHBPD6gkwn1SG9xRA=; b=UG4f3pxjHgZlObLP49BULVY5tloP9scRUfg3WEfAWhZynoW0ux33LZM6JIiBG+U+/y 9jsfg6oL+EyAQai57aEoTkfDDjoCTcK+a0ZPg8rSDJL5tlXwSXNx3ZAE7KNpb27mpLdN glmPMu3wSenEL2Vzq8/o2N+MqFF9/1mwuhWoeYLVFVRreXUn4z3D4uuxB4kAJtrTeCv2 xiEvgt5kMlDxzQfkJQ+R+vkYZw159h6QQZrSHLw/IFPFUQgWSU6NHlg4telchw2k19Og aTiYMw9YBLf0ACI4TSFvbE5alHAQAJfkYKzSC5HYqxYlsyMBjoF0plyl2dUrv6cOMXob zyRg== X-Gm-Message-State: AJIora/aPcc7hOlg78O+mn5+tyocA6q93wkPaOp8B/ecVJnrd+PE3hxu rdzlqqkIF2Mu4zXjwC5KruPVfG4vHmIw2GZaHh2xwvpyLOSsWA== X-Google-Smtp-Source: AGRyM1vgbJNlXzReKsAiGl105zwGRxa/ea70bEH2zweg6iDWdB1T3l4Uz4z5hCOzSgdo9KCk5Djqb2i4jSgimAJ2cB8= X-Received: by 2002:a05:6e02:170a:b0:2dc:685c:5fdd with SMTP id u10-20020a056e02170a00b002dc685c5fddmr5605248ill.274.1657833858003; Thu, 14 Jul 2022 14:24:18 -0700 (PDT) MIME-Version: 1.0 From: Caleb Chase Date: Thu, 14 Jul 2022 16:24:07 -0500 Message-ID: Subject: [BUG] org-capture-kill: doesn't remove the right text region To: emacs-orgmode@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=2607:f8b0:4864:20::136; envelope-from=caleb@chasecaleb.com; helo=mail-il1-x136.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 14 Jul 2022 23:04:38 -0400 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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1657854321; 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=lzqJ50rws2Vk0IYTOldi4Q2C+stHBPD6gkwn1SG9xRA=; b=nL1vR1fKv1klYIXzSzoiiDjR8ZR6s1FwMDqH3cBWzM6OMXEKCnSJv756JBhA916Mju/mtH EbDuUjxMF47Cc0TU1mgToLKiuJGEV0u/95jEI+6jWOg2n8nM7E7/ev8bnTB5M7+4lqYlf8 4yZaLQdvkGFbLooEmgmOomU29qGCxOY8Mse3oeBVuE6Gib0Cg4jVqty7nXSXSHgKfFlzrG ee+jjzO1UVQ0O2UFvxw+SabmtEz0wGmy98IFAbUraoVT2Hx8zf4wv0e6qY5uflO5iEqyY0 z1UMJuabREAqJxuk572gE/+jqPip0/vN9hBmLlS4GyTfXKyi8Ji63vXJ9AVWCQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657854321; a=rsa-sha256; cv=none; b=aZpvjxmwO8sCK22o1kcMhYT5ryojvUGxw2azcDS6vBE85ha7B6GQTGrGiVy6m7+en0n1H+ 6mOK6FVHFlNdNiDO58PnTthQUsSE0mAEGUH5KYpzv+EllnHc2SWzjZu43/Zna1wotksLG7 dlqW/j9LP4U/jC+lIv4OMTMpuq2mh4gnXknAAZMkoY0bcKn+uWlG3qWodFK+8c9t2xcQb1 2QVG8s4ADZpwaZz6Mh8lAO1HYyByaIdAV6tqRlmPXE7pTSBiTRwI6zveGcua0jE/gG76HT veJamJ7Tmae47v/WvQ/894VIJKkxcuBCBM9Ih+JVLnjicdp6ocepqCP3jErdiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=chasecaleb-com.20210112.gappssmtp.com header.s=20210112 header.b=gGmF54FG; 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: -4.75 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=chasecaleb-com.20210112.gappssmtp.com header.s=20210112 header.b=gGmF54FG; 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: 30E2A2EFED X-Spam-Score: -4.75 X-Migadu-Scanner: scn0.migadu.com X-TUID: cQXytyz4tAnr I discovered a bug with org-capture and org-capture kill when canceling an item or plain type template on a heading that has only an empty line for content. Minimal reproduction is as follows: 1. Add the following to =/tmp/capture-bug-init.el=: #+begin_src emacs-lisp :noeval t (require 'org) (setq org-capture-templates '(("i" "Repro: item type" item (file+headline "/tmp/test-capture.org" "Foo") nil :unnarrowed t) ("p" "Repro: plain type" plain (file+headline "/tmp/test-capture.org" "Foo") "Plain capture: %?" :unnarrowed t))) (with-temp-buffer ;; FIXME BUG: occurs with empty line between headings. (insert "* Foo\n\n* Bar\n") ;; FIXME WORKING: no empty line between headings. ;; (insert "* Foo\n* Bar\n") ;; FIXME WORKING: existing item between headings. ;; (insert "* Foo\n- Some note\n* Bar\n") (write-file "/tmp/test-capture.org")) (find-file "/tmp/test-capture.org") (org-capture nil "i") #+end_src 2. Run Emacs: =emacs -Q --load /tmp/capture-bug-init.el= 3. Cancel the capture with =C-c C-k= 4. Bug occurs: the dash is left behind, so the last line is now =-* Bar= instead of =* Bar=. You can also reproduce this bug with the plain type template I have above. Notice the different commented-out variants illustrating when it behaves properly. This bug occurs when there is a single blank empty line between the two headings, but does not occur if there is not empty line or if there is an existing item. --- *POSSIBLE ROOT CAUSE* I suspect the =:begin-marker= capture marker is determined incorrectly for plain and item capture types. I haven't dug into the relevant functions, =org-capture-place-item= and =org-capture-place-plain-text= closely enough to know exactly what is going on, but here's a workaround I came up with. It's obviously not the Right Solution (TM), but at least it illustrates the problem: #+begin_src emacs-lisp :noeval t (defun capture-cancel-bug-fix () (let ((begin (org-capture-get :begin-marker 'local))) (unless (equal (char-before begin) (string-to-char "\n")) (setq org-capture-current-plist (plist-put org-capture-current-plist :begin-marker (1- begin)))))) (add-hook 'org-capture-mode-hook #'capture-cancel-bug-fix) #+end_src --- *CONTEXT* - Emacs version: 28.1 - Org version: 9.5.4. More specifically, tested on current bugfix branch revision 6dc785288d3514af4071f210dac0a18c14a6c45b and current main branch revision d9479887226ad79a1a8de739e7be0fc1fffec536.