From unknown Tue Sep 09 18:22:04 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#28229 <28229@debbugs.gnu.org> To: bug#28229 <28229@debbugs.gnu.org> Subject: Status: 26.0.50; outline-minor-mode-hook run twice when reverting buffer Reply-To: bug#28229 <28229@debbugs.gnu.org> Date: Wed, 10 Sep 2025 01:22:04 +0000 retitle 28229 26.0.50; outline-minor-mode-hook run twice when reverting buf= fer reassign 28229 emacs submitter 28229 Kaushal Modi severity 28229 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 25 08:14:48 2017 Received: (at submit) by debbugs.gnu.org; 25 Aug 2017 12:14:48 +0000 Received: from localhost ([127.0.0.1]:53771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlDVg-0007gw-4h for submit@debbugs.gnu.org; Fri, 25 Aug 2017 08:14:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55460) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlDVf-0007gi-47 for submit@debbugs.gnu.org; Fri, 25 Aug 2017 08:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlDVY-0008Jy-8i for submit@debbugs.gnu.org; Fri, 25 Aug 2017 08:14:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dlDVY-0008Jj-5N for submit@debbugs.gnu.org; Fri, 25 Aug 2017 08:14:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlDVW-0007Z6-HV for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2017 08:14:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlDVV-0008Id-18 for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2017 08:14:38 -0400 Received: from mail-yw0-x22d.google.com ([2607:f8b0:4002:c05::22d]:36450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dlDVU-0008I2-RP for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2017 08:14:36 -0400 Received: by mail-yw0-x22d.google.com with SMTP id h127so11816703ywf.3 for ; Fri, 25 Aug 2017 05:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=eO0ZFMJeQwN2BEDuGjn/8p3tJmXf3RrpMzXeiQHcUE8=; b=ilmkldVWe64Upd+hTU8Jg+PRyb8VUU4am6h75JMGl+nPBwdZIslgB4k1xlBMbkdtNh nAu05iczxLUl2/8lcLX6wCJIAiLinVUU/d1qrVX6Sw5ytWaqg97yFwF2uPFYVHC3VBk/ XmdhO1bZrL2KUe4+0LRw+YX+KKuqNZ9z2uGUeQ+o8LrnCW2fvTXa+z+vaKGOrqUhqBwv W1JFUnI7OoXF1NijAhDUN+MjgZcOv0DcgUaMbmNKyCUy9WkQ89iluIKqg7+dtgr0GmD3 cxenFiHxWxLvyFbN2P1HNYQKxT2MA8saFWJaYv4LLOJouYO++DVoh1PFmH7KCc4eQpxf kFYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eO0ZFMJeQwN2BEDuGjn/8p3tJmXf3RrpMzXeiQHcUE8=; b=HueCL9FytsH74dsuD//gzI0N9gRsgnlKsiOwlG26ADPlgWbd/AV6Pl8CLXGRcmPcTZ LBiDZiXaq7bowW7+36l4KCpYoy3xkS3k6abNKRHfbTr6oLuG0Aw2dRznWORNiD2iWo7B nMie4757Tjht8yXRyN8ptvpuj5eDjjWnmuwmYpzqxBtfptihzmCJ5aJ2EuBosbdlfV8B onjmzbW0Zli3fuD7rZ/8BqP0zjd/Ea3blIzVjxJy97FIGP0w1Yoy/0ag9phz0OFkxj5m ZsznFBlStAlREP5roWgLO2nEzkAcCO+M26qI2NJmbIzJatpCDO0jx+tV0w/mQREWSJ9q 7bKg== X-Gm-Message-State: AHYfb5hyae/xg0sPfSDJtyK0voRxoNNjfaO3fng+tzgfi13pgCQr9Ti+ 0e1wm0n2eaVNudIa5echuLvi9ZITBA== X-Received: by 10.13.202.1 with SMTP id m1mr8069029ywd.304.1503663274466; Fri, 25 Aug 2017 05:14:34 -0700 (PDT) MIME-Version: 1.0 From: Kaushal Modi Date: Fri, 25 Aug 2017 12:14:23 +0000 Message-ID: Subject: 26.0.50; outline-minor-mode-hook run twice when reverting buffer To: "bug-gnu-emacs@gnu.org" Content-Type: multipart/alternative; boundary="001a114f1e5a5624cf055792e389" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --001a114f1e5a5624cf055792e389 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I recently discovered an anomaly with my outline mode customization and it boiled down to this unexplained behavior.. the outline-minor-mode-hook was getting triggered twice on doing revert-buffer. Here is a recipe to recreate that in emacs -Q: (defun modi/debug () (message "In outline debug") (message "buf name: `%S'" (buffer-name)) (message "major-mode: `%S'" major-mode)) (add-hook 'outline-minor-mode-hook #'modi/debug) (add-hook 'text-mode-hook #'outline-minor-mode) (global-set-key (kbd "") (lambda () (interactive) (revert-buffer :ignore-auto :noconfirm))) - Evaluate the above - Create a foo.txt file and save it. - Hit F5 - You will notice the modi/debug function called twice. In GNU Emacs 26.0.50 (build 38, x86_64-pc-linux-gnu, GTK+ Version 2.24.23) of 2017-08-24 Repository revision: fa5e63e40412f6152dbe079a766845112d598479 Windowing system distributor 'The X.Org Foundation', version 11.0.60900000 System Description: Red Hat Enterprise Linux Workstation release 6.6 (Santiago) Recent messages: buf name: =E2=80=98"b.txt"=E2=80=99 major-mode: =E2=80=98text-mode=E2=80=99 In outline debug buf name: =E2=80=98"b.txt"=E2=80=99 major-mode: =E2=80=98text-mode=E2=80=99 You can run the command =E2=80=98revert-buffer=E2=80=99 with M-x rev-b RET major-mode: =E2=80=98text-mode=E2=80=99 Mark activated next-line: End of buffer Making completion list... Configured using: 'configure --with-modules --prefix=3D/home/kmodi/usr_local/apps/6/emacs/master '--program-transform-name=3Ds/^ctags$/ctags_emacs/' 'CPPFLAGS=3D-I/home/kmodi/usr_local/6/include -I/usr/include/freetype2 -I/usr/include' 'CFLAGS=3D-ggdb3 -O0' 'CXXFLAGS=3D-ggdb3 -O0' 'LDFLAGS=3D-L/home/kmodi/usr_local/6/lib -L/home/kmodi/usr_local/6/lib64 -ggdb3'' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK2 X11 MODULES Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=3Dnone locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils noutline outline easy-mmode elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 99816 10196) (symbols 48 20978 1) (miscs 40 68 180) (strings 32 29838 1379) (string-bytes 1 811740) (vectors 16 15125) (vector-slots 8 511402 11453) (floats 8 55 306) (intervals 56 375 62) (buffers 992 14) (heap 1024 28574 803)) --=20 Kaushal Modi --001a114f1e5a5624cf055792e389 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

I recently disco= vered an anomaly with my outline mode customization and it boiled down to t= his unexplained behavior.. the outline-minor-mode-hook was getting triggere= d twice on doing revert-buffer.

Here is a recipe t= o recreate that in emacs -Q:

(defun modi/debug ()<= /div>
=C2=A0 (message "In outline debug")
=C2=A0 (m= essage "buf name: `%S'" (buffer-name))
=C2=A0 (mess= age "major-mode: `%S'" major-mode))
(add-hook '= outline-minor-mode-hook #'modi/debug)
(add-hook 'text-mod= e-hook #'outline-minor-mode)

(globa= l-set-key (kbd "<f5>") (lambda () (interactive) (revert-buf= fer :ignore-auto :noconfirm)))

- Evaluate th= e above
- Create a foo.txt file and save it.
- Hit F5
- You will notice the modi/debug function called twice.
=

In GNU Emacs 26.0.50 (build 38, x86_64-pc-lin= ux-gnu, GTK+ Version 2.24.23)
=C2=A0of 2017-08-24=C2=A0
Repository revision: fa5e63e40412f6152dbe079a766845112d598479
Wi= ndowing system distributor 'The X.Org Foundation', version 11.0.609= 00000
System Description: = Red Hat Enterprise Linux Workstation release 6.6 (Santiago)

<= /div>
Recent messages:
buf name: =E2=80=98"b.txt"= =E2=80=99
major-mode: =E2=80=98text-mode=E2=80=99
In ou= tline debug
buf name: =E2=80=98"b.txt"=E2=80=99
major-mode: =E2=80=98text-mode=E2=80=99
You can run the comman= d =E2=80=98revert-buffer=E2=80=99 with M-x rev-b RET
major-mode: = =E2=80=98text-mode=E2=80=99
Mark activated
next-line: E= nd of buffer
Making completion list...

C= onfigured using:
=C2=A0'configure --with-modules
= =C2=A0--prefix=3D/home/kmodi/usr_local/apps/6/emacs/master
=C2=A0= '--program-transform-name=3Ds/^ctags$/ctags_emacs/'
=C2= =A0'CPPFLAGS=3D-I/home/kmodi/usr_local/6/include -I/usr/include/freetyp= e2
=C2=A0-I/usr/include' 'CFLAGS=3D-ggdb3 -O0' 'C= XXFLAGS=3D-ggdb3 -O0'
=C2=A0'LDFLAGS=3D-L/home/kmodi/usr_= local/6/lib -L/home/kmodi/usr_local/6/lib64
=C2=A0-ggdb3''= ;

Configured features:
XPM JPEG TIFF GIF= PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELI= NUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS G= TK2 X11 MODULES

Important settings:
=C2= =A0 value of $LANG: en_US.UTF-8
=C2=A0 value of $XMODIFIERS: @im= =3Dnone
=C2=A0 locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes i= n effect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mo= de: t
=C2=A0 eldoc-mode: t
=C2=A0 electric-indent-mode:= t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode: t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t<= /div>
=C2=A0 global-font-lock-mode: t
=C2=A0 font-lock-mode: = t
=C2=A0 blink-cursor-mode: t
=C2=A0 auto-composition-m= ode: t
=C2=A0 auto-encryption-mode: t
=C2=A0 auto-compr= ession-mode: t
=C2=A0 line-number-mode: t
=C2=A0 transi= ent-mark-mode: t

Load-path shadows:
None= found.

Features:
(shadow sort mail-extr= emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compi= le cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc8= 22 mml easymenu mml-sec password-cache epa derived epg
epg-config= gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mai= l-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
= rfc2045 ietf-drums mm-util mail-prsvr mail-utils noutline outline
easy-mmode elec-pair time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
<= div>term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
<= div>term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp5193= 2
hebrew greek romanian slovak czech european ethiopic indian cyr= illic
chinese composite charscript charprop case-table epa-hook j= ka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded n= advice loaddefs
button faces cus-face macroexp files text-propert= ies overlay sha1 md5
base64 format env code-pages mule custom wid= get hashtable-print-readable
backquote dbusbind inotify dynamic-s= etting system-font-setting
font-render-setting move-toolbar gtk x= -toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 99816 10196)
= =C2=A0(symbols 48 20978 1)
=C2=A0(miscs 40 68 180)
=C2= =A0(strings 32 29838 1379)
=C2=A0(string-bytes 1 811740)
=C2=A0(vectors 16 15125)
=C2=A0(vector-slots 8 511402 11453)
=C2=A0(floats 8 55 306)
=C2=A0(intervals 56 375 62)
=
=C2=A0(buffers 992 14)
=C2=A0(heap 1024 28574 803))

--

Kaushal Modi

--001a114f1e5a5624cf055792e389-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 25 09:08:54 2017 Received: (at 28229) by debbugs.gnu.org; 25 Aug 2017 13:08:54 +0000 Received: from localhost ([127.0.0.1]:53823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlEM1-0000XY-TN for submit@debbugs.gnu.org; Fri, 25 Aug 2017 09:08:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlEM0-0000XM-B5 for 28229@debbugs.gnu.org; Fri, 25 Aug 2017 09:08:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlELs-00057O-2W for 28229@debbugs.gnu.org; Fri, 25 Aug 2017 09:08:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlELr-00057G-VR; Fri, 25 Aug 2017 09:08:44 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2644 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dlELp-0004T5-AU; Fri, 25 Aug 2017 09:08:43 -0400 Date: Fri, 25 Aug 2017 16:08:01 +0300 Message-Id: <83o9r37q32.fsf@gnu.org> From: Eli Zaretskii To: Kaushal Modi In-reply-to: (message from Kaushal Modi on Fri, 25 Aug 2017 12:14:23 +0000) Subject: Re: bug#28229: 26.0.50; outline-minor-mode-hook run twice when reverting buffer References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28229 Cc: 28229@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Kaushal Modi > Date: Fri, 25 Aug 2017 12:14:23 +0000 > > I recently discovered an anomaly with my outline mode customization and it boiled down to this unexplained > behavior.. the outline-minor-mode-hook was getting triggered twice on doing revert-buffer. Isn't this expected behavior? revert-buffer calls normal-mode, which first kills all local variables, which involves turning off outline-minor-mode by calling (outline-minor-mode -1) And that calls your hook. The other time is when normal-mode turns outline-minor-mode ON. The doc string of outline-minor-mode-hook (and any other hook created by define-minor-mode) clearly says: Hook run after entering or leaving ‘outline-minor-mode’. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 25 11:06:35 2017 Received: (at 28229-done) by debbugs.gnu.org; 25 Aug 2017 15:06:35 +0000 Received: from localhost ([127.0.0.1]:54572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlGBv-0003SY-I3 for submit@debbugs.gnu.org; Fri, 25 Aug 2017 11:06:35 -0400 Received: from mail-yw0-f175.google.com ([209.85.161.175]:35089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlGBu-0003SG-7I for 28229-done@debbugs.gnu.org; Fri, 25 Aug 2017 11:06:34 -0400 Received: by mail-yw0-f175.google.com with SMTP id x21so446035ywg.2 for <28229-done@debbugs.gnu.org>; Fri, 25 Aug 2017 08:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LDLRHxN5bRy4+9QOvNGedEcc86opF5+wQR2MN3g58iI=; b=JVF05tMU+4v3hlUcLm8nVEUIRYgGqc4mrUVnKVWNwemPg+v1V3Ts1dBNP7YXm1c/TC TLOvHKZqbWjoCIPJu12Ptn4U32slEX1e4CApBRKwmPm6QJNTZfzuRRk77JSNnRJCAj/K 5wqn//kABJXWTBSfPZuchnC8KPDnMW6NiJw0XMgDmQRXs2O75K0LV7xmknxgo7uXHQ50 K0fbAffDuEOyCAir9AhdhOgcqJ/7wiIvV3zUwFPELLKdiyj6hSYf02qEIb8A5dAu3FqF JbRUlN0Z3Af/R6qQHAh01ZEJSZ6vJrKpl46JcWQ9VSHEGVto9IRveqwNd5jviN1j0Z78 fRyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LDLRHxN5bRy4+9QOvNGedEcc86opF5+wQR2MN3g58iI=; b=UC5Xd1Y6HZPk5CkNWMv7CIhbdyxscdEvfiCh8SB7mWlrEurPc5o7bl2jRg0YJe2GFv LB4AY1FekgncOOSLmYsAQ0jGm1MbyVhVcjOYNfJAgqrwmnPe0M2cQHUjU3OYPXISCk/0 K6TOaT6Ox2Axt6Gm59gzzoluoFpaK/1YOItikQfzAttQoc31z1g4mN+tdiYxhJrpIm+M Bxcy3V9+AR3lsbLgzM4ksB5MnRTOZkrO+OqXQUTrr6kraFLjn4pAO5B/PT8OzSmwtuwP 28fsc6cEkDoDzLnrQYiJcbLtZmVq2JQUo8ZQLuPWFXtwHY/KkKBVSVvrMu7sn60St/Z7 zwJQ== X-Gm-Message-State: AHYfb5jgcJNv3JG9GktkSfhhTCLKSWlsD0/gcIHYR1/JjI18ZPepf1JZ 8OfMJgelCXnNRMaF2vl0cGa2IV15Mw== X-Received: by 10.37.112.135 with SMTP id l129mr8106747ybc.316.1503673588092; Fri, 25 Aug 2017 08:06:28 -0700 (PDT) MIME-Version: 1.0 References: <83o9r37q32.fsf@gnu.org> In-Reply-To: <83o9r37q32.fsf@gnu.org> From: Kaushal Modi Date: Fri, 25 Aug 2017 15:06:16 +0000 Message-ID: Subject: Re: bug#28229: 26.0.50; outline-minor-mode-hook run twice when reverting buffer To: Eli Zaretskii Content-Type: multipart/alternative; boundary="001a114889041399700557954a4f" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 28229-done Cc: 28229-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) --001a114889041399700557954a4f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Aug 25, 2017 at 9:08 AM Eli Zaretskii wrote: > > From: Kaushal Modi > > Date: Fri, 25 Aug 2017 12:14:23 +0000 > > > > I recently discovered an anomaly with my outline mode customization and > it boiled down to this unexplained > > behavior.. the outline-minor-mode-hook was getting triggered twice on > doing revert-buffer. > > Isn't this expected behavior? revert-buffer calls normal-mode, which > first kills all local variables, which involves turning off > outline-minor-mode by calling > > (outline-minor-mode -1) > > And that calls your hook. > > The other time is when normal-mode turns outline-minor-mode ON. > > The doc string of outline-minor-mode-hook (and any other hook created > by define-minor-mode) clearly says: > > Hook run after entering or leaving =E2=80=98outline-minor-mode=E2=80=99= . > Hi Eli, Thanks for reviewing the report. I have now fixed the problem at my end. Here is an updated MWE to exactly show the problem I was facing: - I needed to update a local var specific to the major mode. - The minor mode needed a act a bit differently based on the value of that local variable. - The problem was that that local variable was getting wiped out after the first call of the minor mode hook and it wasn't getting set correctly by my/text-mode-customization (below example) =3D=3D=3D=3D=3D (defvar-local my/var 'unknown "This var is set to the major mode locally.") (defun modi/debug () (message "In outline debug") (message "buf name: `%S'" (buffer-name)) (message "major-mode: `%S'" major-mode) (message "my/var: `%S'" my/var)) (add-hook 'outline-minor-mode-hook #'modi/debug) (add-hook 'text-mode-hook #'outline-minor-mode :append) (defun my/text-mode-customization () (message "In text mode customization") (setq-local my/var major-mode)) (remove-hook 'text-mode-hook #'my/text-mode-customization) (add-hook 'text-mode-hook #'my/text-mode-customization :append) ;Culprit! (global-set-key (kbd "") (lambda () (interactive) (revert-buffer))) =3D=3D=3D=3D=3D On doing C-h v text-mode-hook, I saw: (outline-minor-mode text-mode-hook-identify my/text-mode-customization) That explained that the outline-minor-mode's hook ran before my/text-mode-customization can set the my/var correctly. The fix was simply to keep the APPEND arg of add-hook at its default value nil. The fix was simple but the debug was mind-numbing.. thanks for the help! --=20 Kaushal Modi --001a114889041399700557954a4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Aug 25= , 2017 at 9:08 AM Eli Zaretskii <eliz@gn= u.org> wrote:
> From: Kau= shal Modi <k= aushal.modi@gmail.com>
> Date: Fri, 25 Aug 2017 12:14:23 +0000
>
> I recently discovered an anomaly with my outline mode customization an= d it boiled down to this unexplained
> behavior.. the outline-minor-mode-hook was getting triggered twice on = doing revert-buffer.

Isn't this expected behavior?=C2=A0 revert-buffer calls normal-mode, wh= ich
first kills all local variables, which involves turning off
outline-minor-mode by calling

=C2=A0 (outline-minor-mode -1)

And that calls your hook.

The other time is when normal-mode turns outline-minor-mode ON.

The doc string of outline-minor-mode-hook (and any other hook created
by define-minor-mode) clearly says:

=C2=A0 Hook run after entering or leaving =E2=80=98outline-minor-mode=E2=80= =99.

Hi Eli,

T= hanks for reviewing the report. I have now fixed the problem at my end.

Here is an updated MWE to exactly show the problem I = was facing:

- I needed to update a local var speci= fic to the major mode.
- The minor mode needed a act a bit differ= ently based on the value of that local variable.
- The problem wa= s that that local variable was getting wiped out after the first call of th= e minor mode hook and it wasn't getting set correctly by my/text-mode-c= ustomization (below example)

=3D=3D=3D=3D=3D
=
(defvar-local my/var 'unknown
=C2=A0 "This var is s= et to the major mode locally.")

(defun modi/d= ebug ()
=C2=A0 (message "In outline debug")
= =C2=A0 (message "buf name: `%S'" (buffer-name))
=C2= =A0 (message "major-mode: `%S'" major-mode)
=C2=A0 = (message "my/var: `%S'" my/var))
(add-hook 'out= line-minor-mode-hook #'modi/debug)
(add-hook 'text-mode-h= ook #'outline-minor-mode :append)

(defun my/te= xt-mode-customization ()
=C2=A0 (message "In text mode custo= mization")
=C2=A0 (setq-local my/var major-mode))
= (remove-hook 'text-mode-hook #'my/text-mode-customization)
(add-hook 'text-mode-hook #'my/text-mode-customization :append) ;= Culprit!

(global-set-key (kbd "<f5>&quo= t;) (lambda () (interactive) (revert-buffer)))=C2=A0
=3D=3D=3D=3D= =3D

On doing C-h v text-mode-hook, I saw:

(outline-minor-mode text-mode-hook-identify my/text-mode-c= ustomization)

That explained that the outline-= minor-mode's hook ran before my/text-mode-customization can set the my/= var correctly.

The fix was simply to keep the APPE= ND arg of add-hook at its default value nil.

The f= ix was simple but the debug was mind-numbing.. thanks for the help!
--

Kaushal Modi

--001a114889041399700557954a4f-- From unknown Tue Sep 09 18:22:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 23 Sep 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator