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 ms5.migadu.com with LMTPS id IG4iMfErsWKsYAAAbAwnHQ (envelope-from ) for ; Tue, 21 Jun 2022 04:24:49 +0200 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 KHMaMfErsWJZVwAAauVa8A (envelope-from ) for ; Tue, 21 Jun 2022 04:24:49 +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 5FD031A258 for ; Tue, 21 Jun 2022 04:24:49 +0200 (CEST) Received: from localhost ([::1]:37588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3TZQ-0007iT-9z for larch@yhetil.org; Mon, 20 Jun 2022 22:24:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3TYD-0006vO-F9 for emacs-orgmode@gnu.org; Mon, 20 Jun 2022 22:23:34 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:41501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3TYA-00014e-9V for emacs-orgmode@gnu.org; Mon, 20 Jun 2022 22:23:32 -0400 Received: by mail-oi1-x235.google.com with SMTP id p8so15512179oip.8 for ; Mon, 20 Jun 2022 19:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=QSJ8I7Wlt/D/8quGhUMkh56lI2h11Flop5ZkF+GJGaA=; b=CnTOuEuHIvDXsrTgcjx8pbEcZRGjkX1JpuxqHG+6Ay1VlS14WrhftxihMKDX1FPhCV ysoZLFqHjOTvajG28EMWBjm6wPGtWGLRURlWmsExEuGoeVWbaR+/r6hRrx4dTs8n+sxG vCN6zm/3D9GhJrOtPrRf6MKauzGs+bZWYrLjPKh92QSLjAmOJ2LP3scwb/UlbhjOFxPR GJhchvV4SUOPCupYPvxvh21HNot6/Z1Y36JmKG3MBFa640FCHJObLo/UuTCRJDr4avBF ER5QgaYJkHZlRStKIGfLkUggmZQPx9EFApAS7iOeufdHNO+ygEsRX8QuSxMQjUalDV+/ uTQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=QSJ8I7Wlt/D/8quGhUMkh56lI2h11Flop5ZkF+GJGaA=; b=gArPsQmgGAAdfqEFoUyMgXiMpLIX/YeSLCTlFqKvjUkNJmG+DYR0CoVXoMpca/f9Nd S2t0V62RF6u2gCWiCxunUSc1I976nftqBpww60X5s0WiPvGApaZg1GbQ01+QKjPXCClJ VQJELUEkGKjY6dWU9esFB1le0v4sHEaz+xB6Hv/JQuIEv/QGh3kdsTdxUhB1ZaIOKlgF KBCvEQ131A8BIMt4HAZaNz6c+h+UL/MfPfry5uzx3R07S1bMPZH3pqnehLiEHnjEUxAz 9Dm5sB8zS2vu3J1oUVIhLsPlaVBFjHl2Inv3PIOKclSqx+pgd36jCuW6AorXnWmJPlbv QvWA== X-Gm-Message-State: AOAM533ZqrAsebGLf18PT422cM91oapVljh9Mj/u3M5Cz3M0rFsCGUZ7 eMKAfKR9MK8HZQC74mWl3qDuVos81YNdfA== X-Google-Smtp-Source: ABdhPJziOk85Fy03gm3bMw6bxI7teuNDEL0g9+PigGxdp9UtrODMfzQXesZJmfAXTIoCxqpGbEUFug== X-Received: by 2002:aca:4b93:0:b0:32e:7196:9908 with SMTP id y141-20020aca4b93000000b0032e71969908mr17407919oia.201.1655778208301; Mon, 20 Jun 2022 19:23:28 -0700 (PDT) Received: from localhost ([207.126.88.10]) by smtp.gmail.com with ESMTPSA id m186-20020aca3fc3000000b00328c9e63389sm8318957oia.11.2022.06.20.19.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 19:23:27 -0700 (PDT) From: Ihor Radchenko To: Tor Kringeland Cc: "emacs-orgmode@gnu.org" Subject: [PATCH] Re: [BUG] Adding note to heading without newline at the end In-Reply-To: References: <87o7yn3117.fsf@localhost> Date: Tue, 21 Jun 2022 10:24:39 +0800 Message-ID: <87fsjysqhk.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=yantar92@gmail.com; helo=mail-oi1-x235.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, 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, 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-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=1655778289; 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=QSJ8I7Wlt/D/8quGhUMkh56lI2h11Flop5ZkF+GJGaA=; b=PMzpxIy63PjlbzrjGq8yl1Sy2QnTC6EUt93fp/64/OR5Stzt0bF6WptqtmnYc6Q76p2JkU /DjWsLSJkLqWsyoarYAo6SPT0zK+k1C7khqzoJXBIT++9TIdbhJ7U7dMPQHhvwjV42UPHY oh3n9S0UwV5yMPBtc1500GCb/KwER4ISjhYDXDLX4u0Hahxo6xwjw8qV0mRJRQHlrxCaZY 6S//iDSSY/k4cEj/ZTmLD8FtCHV4yeofKPJhVu4Bn1xnEJmBI1fJyxPutZ6DTViHd52do+ euc/wCxBdt0EV6okKgAFLGQd6n6eoyHWDi3ntjviMdHsvRV1CinPFGg+5S9p2A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655778289; a=rsa-sha256; cv=none; b=EAE5jjdoDmPnHQP+WEerFKJUMtoCO1TZxmOVXeGwBYdKi0vgpywK0T8qzSRG/3iEFEnpBg 2eUkM7f5GJ7aGIhzUVi2sVshzslQc34butaKL7nuaET6k5ClOAEgcnrMSUWHJBAqlWSgiQ OI8tq4ZFLXrRQMBB79hfQSVhxPTFneiVEB3TjqXAsaZf3fy1Oc3LpY+BPpGJn2O4eqzsRD CvztoWQjql1sG7fMA0azqGku3lbd6yZPsnXU+FMVtXww6OBDaqB81UFz0oDuVtaWzGMdS3 xeC0eQBEQMg9BCG3cXibKO5Sg6wDffGXK600xLf1s6Fh4KJyHjB0L/5xg9MssA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CnTOuEuH; 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" X-Migadu-Spam-Score: -5.77 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CnTOuEuH; 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" X-Migadu-Queue-Id: 5FD031A258 X-Spam-Score: -5.77 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7UYyeECkOlVs --=-=-= Content-Type: text/plain Tor Kringeland writes: > Ihor Radchenko writes: > >> Can you reproduce the problem starting from emacs -Q? > > I did. The bug only occurs if there is no newline at the end. So for > example if you open a new buffer and don't save it, the bug should > occur. Aha. Not saving is an important piece of information. (said the person with compulsive saving syndrome) Can you test the attached patch? Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-log-beginning-Fix-for-headline-at-eob-with-no-tr.patch >From 7c40a003166c9ab8f5f034b8bb6d506ed2b8b62f Mon Sep 17 00:00:00 2001 Message-Id: <7c40a003166c9ab8f5f034b8bb6d506ed2b8b62f.1655778085.git.yantar92@gmail.com> From: Ihor Radchenko Date: Tue, 21 Jun 2022 10:18:58 +0800 Subject: [PATCH] org-log-beginning: Fix for headline at eob with no trailing newline * lisp/org.el (org-log-beginning): Fix edge case when there is a headline at the end of buffer and that headline does not have a trailing newline. Fixes https://orgmode.org/list/m24k0ffjyd.fsf@ntnu.no --- lisp/org.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 220210992..78f51f9ad 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10121,12 +10121,17 @@ (defun org-log-beginning (&optional create) (end-of-line -1)))) (t (org-end-of-meta-data org-log-state-notes-insert-after-drawers) - (skip-chars-forward " \t\n") - (beginning-of-line) - (unless org-log-states-order-reversed - (org-skip-over-state-notes) - (skip-chars-backward " \t\n") - (beginning-of-line 2))))) + (let ((endpos (point))) + (skip-chars-forward " \t\n") + (beginning-of-line) + (unless org-log-states-order-reversed + (org-skip-over-state-notes) + (skip-chars-backward " \t\n") + (beginning-of-line 2)) + ;; When current headline is at the end of buffer and does not + ;; end with trailing newline the above can move to the + ;; beginning of the headline. + (when (< (point) endpos)) (goto-char endpos))))) (if (bolp) (point) (line-beginning-position 2)))) (defun org-add-log-setup (&optional purpose state prev-state how extra) -- 2.35.1 --=-=-=--