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 sF8rECeI42M7bgEAbAwnHQ (envelope-from ) for ; Wed, 08 Feb 2023 12:31:51 +0100 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 2CoQECeI42NnbAEAauVa8A (envelope-from ) for ; Wed, 08 Feb 2023 12:31:51 +0100 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 164CE2DCD1 for ; Wed, 8 Feb 2023 12:31:49 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPifF-0002oO-Aq; Wed, 08 Feb 2023 06:31:01 -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 1pPif7-0002mX-Bj for emacs-orgmode@gnu.org; Wed, 08 Feb 2023 06:30:53 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPif5-0005pi-6K for emacs-orgmode@gnu.org; Wed, 08 Feb 2023 06:30:53 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B6C392403E0 for ; Wed, 8 Feb 2023 12:30:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1675855848; bh=ISulEec46X7sneoMZpK9IKGr5wmjv0eH9PFcYckOXbk=; h=From:To:Cc:Subject:Date:From; b=DnnPcBX/RurMzzB33xy++kvuU4CtdirSdcx5SpqmBX8Vx14SaHOiEDChhI9CXQvxS UVOihs2MURFGVTrm2/Jsa4L+V4hryZ505Ql61TvacOIsmHqmDxX29dSBX9ohm3S38V f1so2wpePjq9btkxohA7FV/2iZIsclCxMrQGdIttem3GRFIAI8tfcQNR8jupQdLaEK yRgEmpNmApe17jEHMwkgE/zApPT7TzpejTceFWZRop1c/zk8yQH03XBFaDwhAcLAAe xMnImmpyP9e0DT3yr0m56vu0Twk/O0oShij5yfSbh7wRWCszjaLGCwtfSduAiVxPdv VNsmwlZ/mGhGQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PBd9351nJz9rxB; Wed, 8 Feb 2023 12:30:47 +0100 (CET) From: Ihor Radchenko To: Laurenz Wiskott Cc: emacs-orgmode@gnu.org Subject: Re: new org mode, changed folding behavior could be improved / more consistent In-Reply-To: References: Date: Wed, 08 Feb 2023 11:31:26 +0000 Message-ID: <874jrwe6lt.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="DnnPcBX/"; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675855910; a=rsa-sha256; cv=none; b=PlvlcdaSqgYiRlhh+6vcR03zwrdDmIN3F35DfG+qolNE2uNHramDfbrYcrN6hn4QvPVlDE sAMFZuIrwf9Z/y56g4gqQ3JvEOvUna7ASGRIZI01pY7NtsiuCzhwRzFhoHeYdHVtswzPbK s3OhUK+HVEEwI093WMM4BlxQgsgEEcjSPN0epJKU6Qesltey7WOMxq6vGR5hSzWqcPRks0 N6D5DrrZpZkrB6AsQ47oyFkYhVAvRgIcRkZytPFi82Ab7YaHt4RdMaXgyDR4h5yeN6NLYy clt+g0bFp2EUxE7Hfckya/5R09QtUpx9q1Hw3ss6MgorAbzbn6amI3j5Kilgwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675855910; 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=TKW48UiJQ8rnkywHx0QUDc/HsyMt8OdmgeVbl48OCMk=; b=kxBGDu5M3uOixfqI9/1HXN1c7ezzclaYCEQE5FvzYqrEGjKJ7g049b5V+/oRB86FeAOf4j HZL5G9OdLK8MI0/72tX3YrUpWIG2ddevS0W//kWV2dttMPtJFh5UW/nQDV/YbpHaabz9to rpF7FV+PcVA+0Sm/PpHtfuw9oTAMoKIQY3VRxSxnHA1O//UnEatuH83IN1jBTjd+ZX33U/ miCaafge/EXov7PNiIliabmOjybBCHV2hE64LoHXVlKt8NcFoNQ2IUI3NnvNp4Uiv1ZUFb 8287i/tuVD3wqrIPctokpeOORBA1gSyAOzCx2GifiKbiMlsl37+kZfFsraSBVg== X-Migadu-Queue-Id: 164CE2DCD1 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="DnnPcBX/"; 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"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Spam-Score: -7.86 X-Spam-Score: -7.86 X-TUID: ZVMez4EBlNGQ --=-=-= Content-Type: text/plain Laurenz Wiskott writes: > There is one feature however that I really miss: It used to be that I could add an entry > with a certain number of stars in the first line, and then 'org-global-cycle' using S-TAB > would allow to make all the headlines visible only up to that many stars. For instance, > a file with > > > *** - > * 1 > ... > after one or two S-TAB (depending on the initial folding state) would look like > > *** - > * 1 > ** 2 > *** 3 > > without the 4-star headline visible. If I remove one star in the first line and type > S-TAB once or twice, then it looks like > > ** - > * 1 > ** 2 > > I found that a convenient way of controlling the depth of the CONTENT view (I believe it > is called). That does not work any more. Typing S-TAB once or twice leads to the > CONTENTS view that shows all headlines, no matter how many stars and independently of the > first line. This was not documented and caused by implementation detail. > Here is an example for 'org-cycle' > > * 1 > *** - > ** A > *** Aa > ... > Typing TAB once or twice (depending on the initial folding state) on the main headline (* > 1) yields the view: > > * 1 > *** - > ** A > *** Aa > ** B > *** Ba It is a bug in `org-fold-show-children'. The reason your example works has nothing to do with what the function intends to do. Fix is attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-fold-show-children-Only-display-direct-children-.patch >From a5e8062b258fc7c4e4d4129278101a8d20bb43c4 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Wed, 8 Feb 2023 14:29:30 +0300 Subject: [PATCH] org-fold-show-children: Only display direct children by default * lisp/org-fold.el (org-fold-show-children): Clarify the docstring emphasizing that direct children are always displayed. Fix grandchildren being displayed when the first child has deeper level than the next children. --- lisp/org-fold.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lisp/org-fold.el b/lisp/org-fold.el index 1b7ca22b0..f9c604155 100644 --- a/lisp/org-fold.el +++ b/lisp/org-fold.el @@ -419,20 +419,21 @@ (defun org-fold-show-siblings () (defun org-fold-show-children (&optional level) "Show all direct subheadings of this heading. -Prefix arg LEVEL is how many levels below the current level -should be shown. Default is enough to cause the following -heading to appear." +Prefix arg LEVEL is how many levels below the current level should be +shown. If direct subheadings are deeper than LEVEL, they are still +displayed." (interactive "p") (unless (org-before-first-heading-p) (save-excursion (org-with-limited-levels (org-back-to-heading t)) (let* ((current-level (funcall outline-level)) + (parent-level current-level) (max-level (org-get-valid-level - current-level + parent-level (if level (prefix-numeric-value level) 1))) + (min-level-direct-child most-positive-fixnum) (end (save-excursion (org-end-of-subtree t t))) (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)") - (past-first-child nil) ;; Make sure to skip inlinetasks. (re (format regexp-fmt current-level @@ -448,11 +449,12 @@ (defun org-fold-show-children (&optional level) ;; MAX-LEVEL. Since we want to display it anyway, adjust ;; MAX-LEVEL accordingly. (while (re-search-forward re end t) - (unless past-first-child - (setq re (format regexp-fmt - current-level - (max (funcall outline-level) max-level))) - (setq past-first-child t)) + (setq current-level (funcall outline-level)) + (when (< current-level min-level-direct-child) + (setq min-level-direct-child current-level + re (format regexp-fmt + parent-level + (max min-level-direct-child max-level)))) (org-fold-heading nil)))))) (defun org-fold-show-subtree () -- 2.39.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--