From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers Date: Mon, 13 Dec 2021 10:58:42 +0200 Organization: LINKOV.NET Message-ID: <86fsqwc01d.fsf@mail.linkov.net> References: <87lf1sw6ji.fsf@gmail.com> <86h7cgdk4v.fsf@mail.linkov.net> <87ee7kvshn.fsf@gmail.com> <87a6i7x5iq.fsf@gmail.com> <86k0hbam7r.fsf@mail.linkov.net> <878rxrmy7q.fsf@gmail.com> <86y256uc0v.fsf@mail.linkov.net> <87r1ajknsr.fsf@gmail.com> <86ilvu6w6k.fsf@mail.linkov.net> <871r2hc51a.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3456"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 51809@debbugs.gnu.org To: Matthias Meulien Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 13 10:57:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1mwi4v-0000hS-S6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 10:57:05 +0100 Original-Received: from localhost ([::1]:38096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwi4u-0004H1-6D for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 04:57:04 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwhx9-0006oD-0z for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwhx8-0006Lz-Oo for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwhx8-00007D-Hd for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Dec 2021 09:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51809 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51809-submit@debbugs.gnu.org id=B51809.1639388905393 (code B ref 51809); Mon, 13 Dec 2021 09:49:02 +0000 Original-Received: (at 51809) by debbugs.gnu.org; 13 Dec 2021 09:48:25 +0000 Original-Received: from localhost ([127.0.0.1]:54174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwhwW-00006G-MH for submit@debbugs.gnu.org; Mon, 13 Dec 2021 04:48:25 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:47557) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwhwU-00005j-0i for 51809@debbugs.gnu.org; Mon, 13 Dec 2021 04:48:23 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id C67DA1C0002; Mon, 13 Dec 2021 09:48:14 +0000 (UTC) In-Reply-To: <871r2hc51a.fsf@gmail.com> (Matthias Meulien's message of "Mon, 13 Dec 2021 08:55:45 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222301 Archived-At: >> Thanks, this is a good starting point to add just the basic functionality >> like org-mode initial visibility supported by ‘org-startup-folded’ and >> per-file settings: >> >> #+STARTUP: fold (or ‘overview’, this is equivalent) >> #+STARTUP: nofold (or ‘showall’, this is equivalent) >> #+STARTUP: content >> #+STARTUP: showlevels ( = 2..5) >> #+STARTUP: showeverything >> >>> @@ -1058,13 +1060,16 @@ outline-show-heading >>> -(defun outline-hide-sublevels (levels) >>> +(defun outline-hide-sublevels (levels &optional fun) >> >> It seems you don't use this argument in this patch? > > It will be necessary for `diff-mode' to provide its own default state > functions that decide of the visibility of each heading > individually. You're right, it's not needed right now so I'll remove it > and reintroduce it when working on `diff-mode'. When we will have enough outline functions to be used as values of `outline-default-state', then `diff-mode' doesn't need to provide its own default state functions - `diff-mode' could just set a suitable buffer-local value of `outline-default-state' from the list of options provided by `outline-default-state'. Also `outline-default-state' could support a string value applied as a regexp on outline heading lines to decide whether to hide or show that outline. >>> + (cond >>> + ((not outline-default-state) (outline-show-all)) >> >> It seems this change doesn't keep the current default behavior. >> Maybe the result will look like it currently works, maybe not. >> Who knows what effect will have calling `outline-show-all' >> by default in some user configurations. > > Good point. I can remove that line but one must be aware that calling > `outline-apply-default-state' interactively after changing some headings > visibility won't restore the default state. Not very intuitive... `outline-default-state' could provide an explicit value that will show all outlines. Maybe even the default value of `outline-default-state' could be changed to this explicit value. Then calling `outline-apply-default-state' interactively will show all outlines. This way it will be more clear to users what is going on. >>> + ((eq outline-default-state 'only-headings) >>> + (outline-show-all) >>> + (outline-hide-region-body (point-min) (point-max))) >>> + ((integerp outline-default-state) >>> + (outline-hide-sublevels outline-default-state)) >>> + ((when (functionp outline-default-state) >>> + (funcall outline-default-state))))) >> >> Maybe some other values from org-mode could be supported too? > > Sure. Ideally, there should be an outline-mode function for most values, so there should be no need for special handling, e.g. instead of special handling of `only-headings', an outline command should handle this by funcall (maybe there is an existing function that does this?) Only integer and string values should have special handling here. > Let me first fix handling of local values. I saw that `outline-mode' is > set *before* local variables when I visit a file whose major mode > default to `outline-mode'. I don't know where is the problem. For example, in etc/compilation.txt these lines set local variables correctly: ;;; outline-minor-mode-cycle: t ;;; outline-minor-mode-highlight: t ;;; mode: outline-minor > For xref mode I am wondering whether "regexp" based outline mode is the > right thing to use. Should there be an outline mode based on > text-properties? The buffer content is built internally and we know > where "headings" are inserted... But it's another topic. Good idea.