From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#57672: [PATCH] Add prefix argument to outline-cycle-buffer Date: Thu, 08 Sep 2022 11:15:21 +0200 Message-ID: <874jxii5w6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11906"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 57672@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 08 11:16:25 2022 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 1oWDe4-0002sA-Es for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Sep 2022 11:16:24 +0200 Original-Received: from localhost ([::1]:54854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWDe3-0003kR-5w for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Sep 2022 05:16:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWDdi-0003jC-Sz for bug-gnu-emacs@gnu.org; Thu, 08 Sep 2022 05:16:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWDdi-0000DD-L4 for bug-gnu-emacs@gnu.org; Thu, 08 Sep 2022 05:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oWDdi-0007dm-Fy for bug-gnu-emacs@gnu.org; Thu, 08 Sep 2022 05:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Sep 2022 09:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57672 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166262853429325 (code B ref -1); Thu, 08 Sep 2022 09:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Sep 2022 09:15:34 +0000 Original-Received: from localhost ([127.0.0.1]:57254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWDdF-0007cv-Ky for submit@debbugs.gnu.org; Thu, 08 Sep 2022 05:15:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWDdD-0007cn-L0 for submit@debbugs.gnu.org; Thu, 08 Sep 2022 05:15:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWDdD-0003Xi-GQ for bug-gnu-emacs@gnu.org; Thu, 08 Sep 2022 05:15:31 -0400 Original-Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:43805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWDdB-00009I-Gj for bug-gnu-emacs@gnu.org; Thu, 08 Sep 2022 05:15:31 -0400 Original-Received: by mail-ej1-x634.google.com with SMTP id gb36so36528151ejc.10 for ; Thu, 08 Sep 2022 02:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date; bh=vDDGhnh5r64Lifib1Sbm0s20NONPWRQrealxKHNGdW8=; b=PWR9izNuZxATod6Eu5a6qnYPdKkxVlr6mYKfJBSSp/W8vA2fRktL1GNXSL4fFGL1lm sfS04qekE/C9RzZC0FNgBkI/xEE3gCmc4FjpVTx1vDMhCPrYQUgwWpcMo+HT5MgfBUCu /qTdgLt3yFF096ooQi/AWfBhIoKQdYa2PEOHp/u6mumYaAYap0vSnKNT6JjmzR2uj8BL 24iNktJ/bGRfH2SzF0YefhJD99319sP0aRVDEZcg42ADywwhhdKO5kNnszlOiT2ZkKXE MSeJ2G3ck3r6wIAuPredfxY0RMN5tKUIPN8+b1JM1/dDjNYb7uljZ60+VLnbUNSsa1jy lJuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date; bh=vDDGhnh5r64Lifib1Sbm0s20NONPWRQrealxKHNGdW8=; b=p+vRkujFp0kte3TiQS9yRGmpWJYUKdXTFViQvuhF0mX+9wtC2C2ccdxQ2X9EH85B08 SUgiEknVEQnzQokcLxB9n4UeaGYhSFtrpKox/c1OUmCrCjHYslzDXFa2KOmgbnF5RhXa VO4z0edf7fefHghJkaOSQowJaXb6sVAemnlRFu4I80QiId9cbdvvCxH+VnEWQpUQXOV2 3nkyO6Ln278ychtXdblOuN0aAtwmJdDk1r8t5XowZnjQ1IunMGvMrlpXGqzrjTKGFuyX VaFmHO/t584SLfaELkKnyV7mkMyNQiT9TNtjk7zWMoTsgqev06ovUAvW/n6u/g3lqFP8 HwQA== X-Gm-Message-State: ACgBeo0NB8Y2tk/4CcY18HEMN2uPSUAFFj1Wge5dXw2PvAHv3c6qWdVI +EiSeYAllaBrQBh5zQ1p8IpV3e8B/v0= X-Google-Smtp-Source: AA6agR5lEUP7dUiLb6PkyipMKWTCnZkULgJS7/EZW0Q0ZZiG9M9aI5j3RXDMRRZRcsJDiAvvzkn+ow== X-Received: by 2002:a17:907:7da8:b0:730:fdad:4af8 with SMTP id oz40-20020a1709077da800b00730fdad4af8mr5480369ejc.401.1662628523883; Thu, 08 Sep 2022 02:15:23 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::157b]) by smtp.gmail.com with ESMTPSA id by12-20020a0564021b0c00b00445e1489313sm11975746edb.94.2022.09.08.02.15.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 02:15:23 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x634.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: 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:241849 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Similar org-mode, this allows showing only headings up to a given level. Also, handle the edge case where the lowest outline level is bigger than 1, where previously we just gave up. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-prefix-argument-to-outline-cycle-buffer.patch >From 6ca5337a986fea7252a81887827e6c451fd8a9e9 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Thu, 8 Sep 2022 09:56:59 +0200 Subject: [PATCH] Add prefix argument to outline-cycle-buffer * lisp/outline.el (outline-cycle-buffer): Add prefix argument to show headings up to a given level. Handle the case where the top heading level is not 1. --- lisp/outline.el | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lisp/outline.el b/lisp/outline.el index 178cbe3071..f09481f7ea 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -1581,7 +1581,7 @@ outline-cycle (defvar-local outline--cycle-buffer-state 'show-all "Internal variable used for tracking buffer cycle state.") -(defun outline-cycle-buffer () +(defun outline-cycle-buffer (&optional level) "Cycle visibility state of the body lines of the whole buffer. This cycles the visibility of all the subheadings and bodies of all @@ -1590,20 +1590,28 @@ outline-cycle-buffer `Hide all' means hide all the buffer's subheadings and their bodies. `Headings only' means show all the subheadings, but not their bodies. -`Show all' means show all the buffer's subheadings and their bodies." - (interactive) - (let (has-top-level) +`Show all' means show all the buffer's subheadings and their bodies. + +With a prefix argument, show headings up to that LEVEL." + (interactive (list (when current-prefix-arg + (prefix-numeric-value current-prefix-arg)))) + (let (top-level) (save-excursion (goto-char (point-min)) - (while (not (or has-top-level (eobp))) - (when (outline-on-heading-p t) - (when (= (funcall outline-level) 1) - (setq has-top-level t))) + (while (not (or (eq top-level 1) (eobp))) + (when-let ((level (and (outline-on-heading-p t) + (funcall outline-level)))) + (when (< level (or top-level most-positive-fixnum)) + (setq top-level (max level 1)))) (outline-next-heading))) (cond + (level + (outline-hide-sublevels level) + (setq outline--cycle-buffer-state 'all-heading) + (message "All headings up to level %s" level)) ((and (eq outline--cycle-buffer-state 'show-all) - has-top-level) - (outline-hide-sublevels 1) + top-level) + (outline-hide-sublevels top-level) (setq outline--cycle-buffer-state 'top-level) (message "Top level headings")) ((or (eq outline--cycle-buffer-state 'show-all) -- 2.37.3 --=-=-=--