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 2/l5CDBh0l7kNgAA0tVLHw (envelope-from ) for ; Sat, 30 May 2020 13:35:44 +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 uDzLAzBh0l7YUgAAbx9fmQ (envelope-from ) for ; Sat, 30 May 2020 13:35:44 +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 852B0940308 for ; Sat, 30 May 2020 13:35:43 +0000 (UTC) Received: from localhost ([::1]:53648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jf1eG-0005A8-UE for larch@yhetil.org; Sat, 30 May 2020 09:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jf1dv-00058g-6K for emacs-orgmode@gnu.org; Sat, 30 May 2020 09:35:19 -0400 Received: from sender4-of-o51.zoho.com ([136.143.188.51]:21149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jf1du-0001iS-Bm for emacs-orgmode@gnu.org; Sat, 30 May 2020 09:35:18 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1590845715; cv=none; d=zohomail.com; s=zohoarc; b=ltIUtsrZYOqtJrqicr1B9XlnBCB1NSquCL5Tob80Bykx+NJAObDZGnJWBU6X6jipDb1cF/dtzoG/MAa7cmb2tytbjEEvR1zWF733rneseTBvZ+nnqY14CTMhhPrhVVG6vr2Tq+Mdq34+zRiMxTyCUdr3TTeM4/1hW3UbCVw/U14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590845715; h=Content-Type:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=iwsOei/QRzvUCV7NWwWyABjphkhy7MuzTFui97ZmkIY=; b=eeWBwIXerwp3fYaV977CYhGDBKs0Rf7eUzhpzneI9wRcyX0I+nE4D6oAC27NgJCvWa5nmoSqnFVUn3+2lY6VG24vsE+oKcSz/NYGugxOd2CV6Qn8qdDekZo1GAb0qG3AD/iGGj1fqCx0pl6nUYgZRc0Lt4MMkuXemyKhIwyJS4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=nivekuil.com; spf=pass smtp.mailfrom=kevin@nivekuil.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1590845715; s=mail; d=nivekuil.com; i=kevin@nivekuil.com; h=References:From:To:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type; bh=iwsOei/QRzvUCV7NWwWyABjphkhy7MuzTFui97ZmkIY=; b=irWQoJDJgVhlDbMQkK2nOlSEG1g0dsIbjEaZO7gDjVZtX+y8gxG8ki/tWNJ//0RP 2FJ/pausGAq4flSmtNuJ4vvqgEDJF25UdhsE+CISFaF0S1qN0n0EThbzqEUX39ApQbs 2+UEj7o5rzvBy07yp3qZ3UzEzrO/KI+Um02VEbKc= Received: from machina (71.212.158.154 [71.212.158.154]) by mx.zohomail.com with SMTPS id 1590845714063846.3323591100622; Sat, 30 May 2020 06:35:14 -0700 (PDT) References: <87d06lpn3o.fsf@nivekuil.com> User-agent: mu4e 1.5.1; emacs 27.0.91 From: Kevin Liu To: emacs-orgmode@gnu.org Subject: Re: [PATCH] Fix org-narrow-to-subtree smaller than subtree In-reply-to: <87d06lpn3o.fsf@nivekuil.com> Date: Sat, 30 May 2020 06:35:13 -0700 Message-ID: <877dwtpmum.fsf@nivekuil.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-ZohoMailClient: External X-Zoho-Virus-Status: 1 Received-SPF: none client-ip=136.143.188.51; envelope-from=kevin@nivekuil.com; helo=sender4-of-o51.zoho.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/30 09:29:52 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, T_DKIM_INVALID=0.01, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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=none (invalid DKIM record) header.d=nivekuil.com header.s=mail header.b=irWQoJDJ; dmarc=none; 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: -2.01 X-TUID: niXfZJfni/ss --=-=-= Content-Type: text/plain Oh, of course I attached the wrong patch again. Wish mu4e-compose could preview these. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-narrowed-subtree-same-size-as-the-subtree-not-1.patch >From 5f7cf68f92d3fa82d01646f7f1e12a4d18bad2fb Mon Sep 17 00:00:00 2001 From: nivekuil Date: Sat, 30 May 2020 00:11:19 -0700 Subject: [PATCH] Make narrowed subtree same size as the subtree, not 1 char less Right now a narrowed subtree is one char smaller than the actual subtree. (org-mark-element) on a narrowed subtree will select a region 1 char out of bounds, for example. There doesn't seem like a good reason for this to be the case. * lisp/org.el (org-toggle-narrow-to-subtree): Just use (org-end-of-subtree) as the end of the subtree. * testing/lisp/test-ob.el (test-ob/parse-header-args2): Since we're no longer subtracting the narrowed subtree size by 1, the subtree text here is now 1 character longer. I think this is reasonable and shouldn't be surprising enough to ruin anyone's day. If it isn't, then (org-end-of-subtree) should be changed rather than org-narrow-to-subtree. * testing/lisp/test-org-datetree.el (test-org-datetree/find-date-create): (test-org-datetree/find-iso-week-create): No more double newlines between months in datetree, but this just seems like incidental behavior more than deliberate behavior to begin with. --- lisp/org.el | 4 +--- testing/lisp/test-ob.el | 2 +- testing/lisp/test-org-datetree.el | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 0808fc210..f69919b20 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7748,9 +7748,7 @@ If yes, remember the marker and the distance to BEG." (org-with-limited-levels (narrow-to-region (progn (org-back-to-heading t) (point)) - (progn (org-end-of-subtree t t) - (when (and (org-at-heading-p) (not (eobp))) (backward-char 1)) - (point))))))) + (progn (org-end-of-subtree t t) (point))))))) (defun org-toggle-narrow-to-subtree () "Narrow to the subtree at point or widen a narrowed buffer." diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 7c44622ef..2a2a66952 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -233,7 +233,7 @@ this is simple" (should (string-match (regexp-quote "this is simple") (org-babel-ref-resolve "simple-subtree"))) (org-babel-next-src-block) - (should (= 14 (org-babel-execute-src-block))))) + (should (= 15 (org-babel-execute-src-block))))) (ert-deftest test-ob/inline-src-blocks () (should diff --git a/testing/lisp/test-org-datetree.el b/testing/lisp/test-org-datetree.el index 5557d5e23..f7247766a 100644 --- a/testing/lisp/test-org-datetree.el +++ b/testing/lisp/test-org-datetree.el @@ -58,7 +58,7 @@ ;; Sort new entry in right place. (should (string-match - "\\`\\* 2012\n\\*\\* 2012-02 .*\n\\*\\*\\* 2012-02-01 .*\n\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" + "\\`\\* 2012\n\\*\\* 2012-02 .*\n\\*\\*\\* 2012-02-01 .*\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" (org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012)) @@ -161,7 +161,7 @@ ;; Sort new entry in right place. (should (string-match - "\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\n\n\\*\\* 2015-W36\n\\*\\*\\* 2015-09-01 .*\\'" + "\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\n\\*\\* 2015-W36\n\\*\\*\\* 2015-09-01 .*\\'" (org-test-with-temp-text "* 2015" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-iso-week-create '(9 1 2015)) -- 2.26.2 --=-=-=--