From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MMXkObJ5kGIAKQEAbAwnHQ (envelope-from ) for ; Fri, 27 May 2022 09:11:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cIXfObJ5kGJkOgEA9RJhRA (envelope-from ) for ; Fri, 27 May 2022 09:11:46 +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 6FC93E7DF for ; Fri, 27 May 2022 09:11:46 +0200 (CEST) Received: from localhost ([::1]:34378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuU8P-0007jZ-Hu for larch@yhetil.org; Fri, 27 May 2022 03:11:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuU6z-0007jL-Sc for emacs-orgmode@gnu.org; Fri, 27 May 2022 03:10:17 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:41611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuU6x-0005sL-VC for emacs-orgmode@gnu.org; Fri, 27 May 2022 03:10:17 -0400 Received: by mail-pl1-x636.google.com with SMTP id s14so3407833plk.8 for ; Fri, 27 May 2022 00:10:15 -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=eyORCLHodJpuUVUV8K2agjlB74ivpghwJ4te2wVPkys=; b=EoWkpbm/la0tm3BYdjz3YITSVC97g9ah6i/llAzqx8fvdceS/2v9gRNCnG7Kp59iPi DDAbcj7AnQWJYLLgjNEf3bVYzzjopAbQBXajt/o7GEA7vyrl8pP+X6P5tW5H9fMcfkyc wWvcEhg9IapTUa5TUAeAR5OVhrEBgX8Mxd6bjYaMaLv/I+u5hFHybMvo5O9E9hF4jC/C qinMB6Z8/ErWeWPARcCzIVsxV/2fp58Rto4GsgsTOFOjYEX+c5/+S0zPFIwRePN6b6SN T5fQF5CvZt+J24ZJ8u98aqWCLxwAd7xkaTbJDlxwtF5s0DcRO7A+wreaOEbbnjriIYLd b6jA== 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=eyORCLHodJpuUVUV8K2agjlB74ivpghwJ4te2wVPkys=; b=VRfz7PTNSolVu+Sb83Rh0fvNez7UX0KtAFGMuI2VwTrnP485mrZxhI795XMMWPPdt1 SnDp7izMHBudAHiz0qMJ/1Y89UEfZq1XG7T5ZrVxxO5Wl/l7IMBqrFyvAsgp23ld6F8W H88/sjX6y9T5IdiC/pVis30gappybeYhWFIxNqdQE2ZaDtL0sD0cATpPNOX3MFVtjOzg i3l/0CssSLUdB7hVZrqhSygtjKqdwgqszMkparKvIcU2YbsII6+Tk7+rEKlzI4dGKSf/ lVu5WCkJ3A6RBVdh+ZWLXta+EINK94D5VM32bOyy+FVKsvzixyU9ta2dVIQF2grn43IB YBCw== X-Gm-Message-State: AOAM5300AdsMLzzYEmOpM5gXnxwXlHExRoZKfThYhbZPbHU6Cbjp6mz6 sBJ9l7mH0d8weDD4PtFGXdW6IIVQFqFVsXAKubg= X-Google-Smtp-Source: ABdhPJzZjtJamRb5Oy2zecZwW8WI/uF+Zauhi8l/pLIyuCVOl0biBqC0vOFBmLf5cEDVtuHrwUHRHA== X-Received: by 2002:a17:902:d54b:b0:161:8f46:8207 with SMTP id z11-20020a170902d54b00b001618f468207mr42346756plf.67.1653635414207; Fri, 27 May 2022 00:10:14 -0700 (PDT) Received: from localhost ([104.223.86.8]) by smtp.gmail.com with ESMTPSA id z9-20020a056a001d8900b0050dc76281fbsm2604093pfw.213.2022.05.27.00.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 00:10:13 -0700 (PDT) From: Ihor Radchenko To: Tor Kringeland Cc: "emacs-orgmode@gnu.org" Subject: [PATCH] Re: Change in `org-cycle-hook' breaks behavior In-Reply-To: References: Date: Fri, 27 May 2022 15:10:53 +0800 Message-ID: <87a6b3zc02.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=yantar92@gmail.com; helo=mail-pl1-x636.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=1653635506; 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=eyORCLHodJpuUVUV8K2agjlB74ivpghwJ4te2wVPkys=; b=h9Sv5tFW7mvEBxQiO18cnLVDqqhGYf29tmTJyOU0InNW7QP/oELaOqF581e4Fp9kGjBDY2 ja0HkZLxK12klTEz193qo4C0qMKIS9fd4xiMbmNJEdxculnSD5vzuwMwQFw9LOJp5mm2qp vsFpogHjDbzZGFfUjX1rd4HpJREOh9VY45tac/cyYtgzCAzB9FuYnhEwC6S5hPZGhrR2J3 vV9OqPHeqyM/OcAn+TMcJSKpOQzYNeuY2Ueqad8L8X359Ah3KQxkswy05W31Hf6xy4kqON wgDG9sXgzTrY/5E5tU3Z3itHP+CDSCq/OKq3waq+iNVWMjZsM9b51BbwdAAazw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653635506; a=rsa-sha256; cv=none; b=VbBuQfvlci1iy2SU6F0LkbaGUyJEN1IRs+qL+jRI6BDCt9Y2+vmU6X9R83kA1mFoJGlmhZ ko5sxyGV4KrSwX6vSnJ3JTdDmgthOJ6xdYer8jNOAnvkxP0/7YUVwQEa4U/lYDBOXr0n5o 6UIcHhoFtBQu1myYHBiKirc0K7X86C9PhNyl9g/PwQpVJP1VjXNcgPXlyeZv/dXOv0db28 QbvrPfvy3UgTc1kOn/fddgrRmuMlhruE+TNFAd6FkqKoCCCSJi+E01SMFTUCo6rLFcmBlv 18vEZrRBzXD8KskmwGRQTPw59AgefTAMez8bixFXYU+NFimpsEiS8641CfuQ1g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="EoWkpbm/"; 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: -3.54 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="EoWkpbm/"; 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: 6FC93E7DF X-Spam-Score: -3.54 X-Migadu-Scanner: scn1.migadu.com X-TUID: yhperaA+SG1b --=-=-= Content-Type: text/plain Tor Kringeland writes: > In Org 9.5, `org-cycle-hook' includes `org-cycle-hide-drawers', which > hides the drawer after opening the contents of a headline with > `org-cycle'. However, if you removed `org-cycle-hide-drawers' from the > hook, `org-cycle' would show you the drawers (at least the PROPERTIES > one). I relied on this behavior, as I wanted the drawers to be shown > when I opened a headline. I assume that you have org-startup-folded set to 't. Then, what you are seeing is caused by org-cycle-set-startup-visibility that folds all the drawers unless org-startup-folded is set to 'showeverything. Previously, the folded drawers (or folded anything) inside folded headline would be automatically unfolded when you unfold the headline. Now, the folding state is independent and we don't need to re-fold the drawers upon unfolding the headline. > Maybe a function `org-cycle-show-drawers' could be added? Implicitly it > seems like `org-cycle' previously did contain this functionality. > Adding such a function to `org-cycle-hook' would solve my problem. A more efficient way could be introducing a new customization similar to org-cycle-hide-block-startup. Say, it can be org-cycle-hide-drawer-startup. See the attached patch. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-cycle.el-New-custom-setting-org-cycle-hide-drawe.patch >From 2312e9280e5267cdcb72406a24068d6ec0a3696e Mon Sep 17 00:00:00 2001 Message-Id: <2312e9280e5267cdcb72406a24068d6ec0a3696e.1653635423.git.yantar92@gmail.com> From: Ihor Radchenko Date: Fri, 27 May 2022 15:09:16 +0800 Subject: [PATCH] org-cycle.el: New custom setting `org-cycle-hide-drawer-startup' * lisp/org-cycle.el (org-cycle-hide-drawer-startup): * lisp/org-cycle.el (org-cycle-set-startup-visibility): Add new customization to control initial folding state of the drawers. * lisp/org.el (org-startup-options): Provide #+STARTUP option for the new setting. Fixes https://list.orgmode.org/m235gww8wg.fsf@ntnu.no/T/#u --- etc/ORG-NEWS | 22 ++++++++++++++++++++++ lisp/org-cycle.el | 12 +++++++++++- lisp/org.el | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 35af94f92..e1e4beaf0 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -271,6 +271,28 @@ The new variable name is =org-plantuml-args=. It now applies to both jar PlantUML file and executable. ** Miscellaneous +*** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers + +Previously, all the drawers were always folded when opening an Org +file. This only had an effect on the drawers outside folded +headlines. The drawers inside folded headlines were re-folded because +=org-cycle-hide-drawers= was present inside =org-cycle-hook=. + +With the new folding backend, running =org-cycle-hide-drawers= is no +longer needed if all the drawers are truly folded on startup: [[*Folding +state of the drawers is now preserved when cycling headline +visibility]]. However, this has an unwanted effect when a user does +not want the drawers to be folded (see [[id:1d0e0874-8771-40e4-97ac-6746a0e97438][this bug report]]). + +The new custom setting gives more control over initial folding state +of the drawers. When set to =nil= (default is =t=), the drawers are +not folded on startup. + +The folding state can also be controlled on per-file basis using +=STARTUP= keyword: + +: #+startup: hidedrawers +: #+startup: nohidedrawers *** Styles are customizable in ~biblatex~ citation processor diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el index b15ead788..fb7ff4749 100644 --- a/lisp/org-cycle.el +++ b/lisp/org-cycle.el @@ -119,6 +119,16 @@ (defcustom org-cycle-hide-block-startup nil :group 'org-cycle :type 'boolean) +(defcustom org-cycle-hide-drawer-startup t + "Non-nil means entering Org mode will fold all drawers. +This can also be set in on a per-file basis with + +#+STARTUP: hidedrawers +#+STARTUP: nohidedrawers" + :group 'org-startup + :group 'org-cycle + :type 'boolean) + (defcustom org-cycle-global-at-bob nil "Cycle globally if cursor is at beginning of buffer and not at a headline. @@ -603,7 +613,7 @@ (defun org-cycle-set-startup-visibility () (when org-cycle-hide-block-startup (org-fold-hide-block-all)) (org-cycle-set-visibility-according-to-property) (org-cycle-hide-archived-subtrees 'all) - (org-cycle-hide-drawers 'all) + (when org-cycle-hide-drawer-startup (org-cycle-hide-drawers 'all)) (org-cycle-show-empty-lines t))) (defun org-cycle-set-visibility-according-to-property () diff --git a/lisp/org.el b/lisp/org.el index 0eb819f23..be9900d68 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3984,6 +3984,8 @@ (defconst org-startup-options ("noptag" org-tag-persistent-alist nil) ("hideblocks" org-hide-block-startup t) ("nohideblocks" org-hide-block-startup nil) + ("hidedrawers" org-hide-drawer-startup t) + ("nohidedrawers" org-hide-drawer-startup nil) ("beamer" org-startup-with-beamer-mode t) ("entitiespretty" org-pretty-entities t) ("entitiesplain" org-pretty-entities nil)) -- 2.35.1 --=-=-=--