From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.bugs Subject: bug#52980: elide-head and revert-buffer interaction stops elide-head-show from working Date: Tue, 04 Jan 2022 18:08:37 +0100 Message-ID: <87v8yzsa22.fsf@miha-pc> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9706"; mail-complaints-to="usenet@ciao.gmane.io" To: Stefan Kangas , 52980@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 04 18:06:22 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 1n4nGP-0002FT-1r for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jan 2022 18:06:21 +0100 Original-Received: from localhost ([::1]:51406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4nGN-0007Gb-UG for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jan 2022 12:06:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4nDD-0003q3-30 for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 12:03:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n4nDC-0004TH-5C for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 12:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n4nDB-0001KQ-Ri for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 12:03:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Jan 2022 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52980 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52980-submit@debbugs.gnu.org id=B52980.16413157705088 (code B ref 52980); Tue, 04 Jan 2022 17:03:01 +0000 Original-Received: (at 52980) by debbugs.gnu.org; 4 Jan 2022 17:02:50 +0000 Original-Received: from localhost ([127.0.0.1]:38574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4nD0-0001Jz-Am for submit@debbugs.gnu.org; Tue, 04 Jan 2022 12:02:50 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:42294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4nCx-0001Jq-7p for 52980@debbugs.gnu.org; Tue, 04 Jan 2022 12:02:50 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id 715E49CA87; Tue, 4 Jan 2022 17:02:45 +0000 (UTC) In-Reply-To: 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:223649 Archived-At: Just one minor suggestion from me: Stefan Kangas writes: > tags 52980 + patch > thanks > > Stefan Kangas writes: > >> I started looking into a solution with {before,after}-revert-hook, but >> that just seems duplicate what we would get from just using a minor >> mode. So I'm starting to think that `elide-head' and `elide-head-show' >> should be obsoleted in favor of a new local minor mode >> `elide-head-mode'. >> >> That would also save me from having to add a third command >> `elide-head-toggle' to toggle the hiding on or off. > > Here's a patch. > [...] > > +;;;###autoload > +(define-minor-mode elide-head-mode > + "Toggle eliding (hiding) header material in the current buffer. > + > +When Elide Header mode is enabled, headers are hidden according > +to `elide-head-headers-to-hide'. > + > +This is suitable as an entry on `find-file-hook' or appropriate > +mode hooks." > + :group 'elide-head > + (if elide-head-mode > + (progn > + (elide-head--hide) > + (add-hook 'before-revert-hook 'elide-head--delete-overlay nil 'local)) > + (elide-head--show) > + (remove-hook 'before-revert-hook 'elide-head--delete-overlay 'local))) Perhaps change-major-mode-hook would be more appropriate as suggested by "(elisp) Creating Buffer-Local". That would make the minor mode clean up its overlay if the user executes M-x normal-mode in addition to M-x revert-buffer. > [...] Best regards.