From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: master 2ef6f943abd: Add option to control default outlining in 'C-h b' Date: Mon, 29 May 2023 15:16:08 +0200 Message-ID: <87ttvv2s87.fsf@gmail.com> References: <168233653969.13461.3810563138120581789@vcs2.savannah.gnu.org> <20230424114219.F2AEAC0004A@vcs2.savannah.gnu.org> <877cu1bf6q.fsf@gmail.com> <834jp5xn7v.fsf@gnu.org> <87a5ywn4qj.fsf@web.de> <83r0s8wjcf.fsf@gnu.org> <87leig9xm8.fsf@gmail.com> <838regwcnt.fsf@gnu.org> <87fs8o9spe.fsf@gmail.com> <835y9kw5ix.fsf@gnu.org> <86h6t3rjl8.fsf@mail.linkov.net> <83leifvqsz.fsf@gnu.org> <878refyfrc.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23408"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Juri Linkov , emacs-devel@gnu.org, orontee@gmail.com To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 29 15:17:03 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3ckB-0005vS-8v for ged-emacs-devel@m.gmane-mx.org; Mon, 29 May 2023 15:17:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3cjR-000124-3u; Mon, 29 May 2023 09:16:17 -0400 Original-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 1q3cjP-00011w-QF for emacs-devel@gnu.org; Mon, 29 May 2023 09:16:15 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q3cjN-0005wu-66; Mon, 29 May 2023 09:16:15 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f6094cb2d2so33851475e9.2; Mon, 29 May 2023 06:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685366169; x=1687958169; h=content-transfer-encoding:mime-version:message-id:date :gmane-reply-to-list:references:in-reply-to:subject:cc:to:from:from :to:cc:subject:date:message-id:reply-to; bh=9sYuLzfoBDlC2aiHnGIvy9XHNvODgMo94IhyPQwdvIM=; b=PLelBwivgmtQ7LnCaGNExVezIJeygsSP2QOv+Z2FAGzd1cTlqclpiB204b89qX2MQo QgrtvW91I25VoYeqDEi+y2swV/09zh53hHR2henchK0x+0sAGCYnKhDdpBRgbEU4Z/UK x4LvdeBpMTommc/busxQi9vNdnBuo1YcYGa4+vwp5vsJfxT19f24SB0iRgUzX06d1PYt 6Sep2M1IT8xiyq26bB9X/qf4+w8vWFutT8lUBtShvKc+uLXjm3GRdiOsCo23oOlW7j2w IeBDrgBquFcZ7Z2o6VRKGt3P90aWxLITen2KAHoPeO7/oR6kwEAcJdjZQfKZELyCLTLz 7yCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685366169; x=1687958169; h=content-transfer-encoding:mime-version:message-id:date :gmane-reply-to-list:references:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9sYuLzfoBDlC2aiHnGIvy9XHNvODgMo94IhyPQwdvIM=; b=fjRz+Q7Jf6+BANpf2Tvf3PaGUDjMBo0W64YCVVag7TyFnt6rDLCU8/yOnuOZ6SFf9Z XrpWp8vzvt4I7P1LOoj6bkDHuCWMVTCZKSDpQjXZ+Ad9ZnNktS2/DBbp1lNjhN1IuWsN 56zhdTVvSo4Nlnpf5IABY/p7S8+0UHj85yZzvY/gnNXkaGSYWCyUSTjtr7GSjalS76o4 kfpRfHeVMzMpoRbwSdUwo2GD1ATqw+NQU905BsIKL1rR0AUyLdwdSFlS8mZymODyebKP EK+H+U5FdZF3PER9QetlGxac0T5RJf9fv1qG50JD79G/ro1Y2XrH30bQVC/sdQ1ff+Kw Y9IQ== X-Gm-Message-State: AC+VfDyR2KZdgKtFbVCXDlkYeow2kRjdkiyilNgZrUznGXXqoamBm7mZ HfFb3CEwAanEvxD72yVbkKA= X-Google-Smtp-Source: ACHHUZ5t+1NHk4GuiuBTWezzKYYBWT3o6WqhKSbiwLGM/TovWkR2u0GhluBC1kVFet9KSnUevdBUWg== X-Received: by 2002:a1c:7515:0:b0:3f7:5d:4a0b with SMTP id o21-20020a1c7515000000b003f7005d4a0bmr3553284wmc.1.1685366169404; Mon, 29 May 2023 06:16:09 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id b21-20020a05600c4e1500b003f4283f5c1bsm26470834wmq.2.2023.05.29.06.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 06:16:08 -0700 (PDT) In-Reply-To: <878refyfrc.fsf@web.de> (Michael Heerdegen's message of "Tue, 25 Apr 2023 20:32:23 +0200") Gmane-Reply-To-List: yes Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=rpluim@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306387 Archived-At: >>>>> On Tue, 25 Apr 2023 20:32:23 +0200, Michael Heerdegen said: Michael> Eli Zaretskii writes: >> What is the purpose of requesting a custom function to actually >> hide/unhide the headings, i.e. to know enough about the structure and >> internal details of Outline mode to do its job? Michael> I guess the idea is to let the user decide _how_ to unhide a s= ublevel: Michael> reveal only one level, N levels, everything, only a certain le= af and Michael> its parents, etc. That's a useful feature. Michael> A nice semantics for the custom-function, although not backward Michael> compatible, that would still allow doing this, could be: if th= e non-nil Michael> return value of the custom-function is functionp, we call it. = Other Michael> non-nil values mean we perform some default action, like showi= ng the Michael> complete subbranch. Or we could have a 100% backwards compatible implementation like this, which I=CA=BCd push to emacs-29 if it wasn=CA=BCt in pre-release :-) >From a7883d52f808568816e3f144fadbeacdd6f2cdfe Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 25 Apr 2023 12:21:36 +0200 Subject: [PATCH] Make outline-default-rules custom-function a predicate To: emacs-devel@gnu.org * lisp/outline.el (outline--show-headings-up-to-level): Add `predicate' as an option: hide the entry if it returns non-nil. (outline-default-rules): Adjust docstring to behavior change. --- lisp/outline.el | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lisp/outline.el b/lisp/outline.el index 97a51c9b92a..c5631cf12e2 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -1519,10 +1519,11 @@ outline-default-rules =20 When nil, the subtree is hidden unconditionally. =20 -When equal to a list, each element should be one of the following: +When equal to a list, each element should be one of the +following, which are checked in order: =20 - A cons cell with CAR `match-regexp' and CDR a regexp, the - subtree will be hidden when the outline heading match the + subtree will be hidden when the outline heading matches the regexp. =20 - `subtree-has-long-lines' to only show the heading branches when @@ -1532,11 +1533,17 @@ outline-default-rules - `subtree-is-long' to only show the heading branches when its subtree contains more than `outline-default-line-count' lines. =20 -- A cons cell of the form (custom-function . FUNCTION) where +- A cons cell of the form (predicate . FUNCTION) where FUNCTION is a lambda function or function name which will be - called without arguments with point at the beginning of the - heading and the match data set appropriately, the function - being expected to toggle the heading visibility." + called without arguments, with point at the beginning of the + heading, and the match data set appropriately. If the function + returns nil the subtree will be shown, otherwise it is hidden. + +- A cons cell of the form (custom-function . FUNCTION). This is + similar to the `predicate' form, in that the FUNCTION will be + called, but its return value is ignored. The function is + expected to set the visibility of the subtree directly using + `outline-hide-entry', `outline-show-branches' etc." :version "29.1" :type '(choice (const :tag "Hide subtree" nil) (set :tag "Show subtree unless" @@ -1546,6 +1553,8 @@ outline-default-rules subtree-has-long-lines) (const :tag "Subtree is long" subtree-is-long) + (cons :tag "Predicate" + (const predicate) function) (cons :tag "Custom function" (const custom-function) function)))) =20 @@ -1608,6 +1617,9 @@ outline--show-headings-up-to-level (memq 'subtree-is-long outline-default-rules)) (check-long-lines (memq 'subtree-has-long-lines outline-default-rules)) + (predicate + (cdr-safe + (assoc 'predicate outline-default-rules))) (custom-function (cdr-safe (assoc 'custom-function outline-default-rules)))) @@ -1651,6 +1663,10 @@ outline--show-headings-up-to-level ;; show only branches when long lines are detected ;; in subtree (outline-show-branches)) + (predicate + (if (funcall predicate) + (outline-hide-entry) + (outline-show-subtree))) (custom-function ;; call custom function if defined (funcall custom-function)) --=20 2.38.1.420.g319605f8f0