From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#51809: 29.0.50; [PATCH] Support for outline default state in Diff buffers Date: Mon, 13 Dec 2021 08:55:45 +0100 Message-ID: <871r2hc51a.fsf@gmail.com> 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> 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="22549"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 51809@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 13 08:56:11 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 1mwgBu-0005iM-PQ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 08:56:10 +0100 Original-Received: from localhost ([::1]:49086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwgBs-00070V-HY for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 02:56:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwgBm-00070J-QJ for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 02:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwgBm-0005fD-Ho for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 02:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwgBm-0005ew-Ex for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 02:56:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Dec 2021 07:56: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.163938215621742 (code B ref 51809); Mon, 13 Dec 2021 07:56:02 +0000 Original-Received: (at 51809) by debbugs.gnu.org; 13 Dec 2021 07:55:56 +0000 Original-Received: from localhost ([127.0.0.1]:53935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwgBg-0005eb-4o for submit@debbugs.gnu.org; Mon, 13 Dec 2021 02:55:56 -0500 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:46054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwgBc-0005eM-TJ for 51809@debbugs.gnu.org; Mon, 13 Dec 2021 02:55:54 -0500 Original-Received: by mail-wr1-f43.google.com with SMTP id o13so25405683wrs.12 for <51809@debbugs.gnu.org>; Sun, 12 Dec 2021 23:55:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=gLRXiwU7+S++uM5mYo7JKoieAqn0EwjL0sCvvOdT5Yg=; b=MYXuyoq0hPNamnvhgtQ/ddJbdgTmXO8VQEuQ+TL+LVoA2jdrwLne6ku1xvuWzJY8M/ q20zfYXATRc9sJ31vD83+hy5zIW3FTtQrn/5eQ6kUJ2i4iICw3ovvIEzxfmdC4xhsPia BwxsjZCzN7bah2XOKJr2bf3pil7n+mkCNj5Qzk1FlxfayYsK+klHfLqckWQscm/0ftAR btI0USRalqGik8zvSw7aDQWMI4ZGls7zIFyMgSpj8vvFbnXK9wbQdRdFLilBbi/1O4/u t4PKSLozdI7RUIJIKdSNjG5tgAsbrMm2C7pz0fpArA/2Toy7UTajRKFQXJli8R5Rf2OF lSeQ== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=gLRXiwU7+S++uM5mYo7JKoieAqn0EwjL0sCvvOdT5Yg=; b=x1MVtEmqyxDnydXrMEW7qzLkjWDGnYi5SVFkpYbqYN2//zo6RQfT0coyHqnrJio4jo QZ8rOk9z+iVLKGFAe/IBkA1JSn/sdzKax7Bzcd0c6dUwQG5CLdQifGJMjtTd/ruJ1q19 soN5AOGNMw75QyWdqJjQ1Cn3NBmV2jblIp9op3KP0H/jbQhPJr1mmFBjqQ6tu69bKAHH PueZj84J1lCOca4wwteTfRsaWR0e0QPf4GShpYcUG/Uypb76x9wjSQLAAxD35ofczLYs VAuJGPmHeo4hUyMyqqf//cZM70N2aNJmH7bmNqOhlb8BkhmPTIzIcFjIIC3qkHYNmdle 4fvw== X-Gm-Message-State: AOAM532rCX441k8vlJZ34VUMQMPShRMCDcQOGIKxcDwBNM0oZE/J7qPw bE3j5UbhaJ+Kyvms0yAsd5ChZgiKQXo= X-Google-Smtp-Source: ABdhPJxVTd/3oJImtVHsLYa+QhnDr1QBMiRj/3AkWY3QhkG71htiqFGYddq8k0+QKfVvy69/0+0Cwg== X-Received: by 2002:adf:f0c8:: with SMTP id x8mr30473924wro.290.1639382146703; Sun, 12 Dec 2021 23:55:46 -0800 (PST) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id p12sm10025162wro.33.2021.12.12.23.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 23:55:46 -0800 (PST) In-Reply-To: <86ilvu6w6k.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 12 Dec 2021 10:43:39 +0200") 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:222296 Archived-At: Juri Linkov writes: >> I've this simple patch for the outline.el part. > > Thanks, this is a good starting point to add just the basic functionality > like org-mode initial visibility supported by =E2=80=98org-startup-folded= =E2=80=99 and > per-file settings: > > #+STARTUP: fold (or =E2=80=98overview=E2=80=99, this is e= quivalent) > #+STARTUP: nofold (or =E2=80=98showall=E2=80=99, this is eq= uivalent) > > #+STARTUP: content > #+STARTUP: showlevels ( =3D 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'. >> + :local t >> + :safe t) >> +;; TODO fix variable being set through file local variable > >> One thing that bothers me is that I am not able to store the wanted >> default visibility state as a local variable... Any suggestion welcome! > > For example, `outline-minor-mode-cycle' and `outline-minor-mode-highlight' > have no `:local t', but when visiting a file that sets these file local v= ariables, > then automatically become local. > >> +(defun outline-apply-default-state () >> + "Apply the outline state defined by `outline-default-state'." >> + (interactive) >> + (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... > >> + ((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. 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'.=20 > I think the direction is right: first outline could support > the initial visibility feature, then later various modes > could use it: in diff-mode, xref, etc. That's my plan. 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. Thanks for reading the patch! I'll send another one, hopefully taking your remarks into account, when support of local variables is fixed. --=20 Matthias