From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dalanicolai Newsgroups: gmane.emacs.bugs Subject: bug#54438: 27.2; inconsistent-behavior-global-vs-local-hook Date: Fri, 18 Mar 2022 10:11:29 +0100 Message-ID: References: <871qz0m6qa.fsf@web.de> <161a1515-187d-18c2-f9f1-86f4ea29614c@gmx.at> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000df777d05da7a8895" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20818"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Heerdegen , 54438@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 18 10:12:11 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 1nV8eY-0005GY-5N for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Mar 2022 10:12:10 +0100 Original-Received: from localhost ([::1]:52168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nV8eW-00057Z-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Mar 2022 05:12:08 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nV8eQ-00057R-BZ for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 05:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nV8eQ-000108-3J for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 05:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nV8eP-0001jH-V0 for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 05:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dalanicolai Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Mar 2022 09:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54438 X-GNU-PR-Package: emacs Original-Received: via spool by 54438-submit@debbugs.gnu.org id=B54438.16475947086620 (code B ref 54438); Fri, 18 Mar 2022 09:12:01 +0000 Original-Received: (at 54438) by debbugs.gnu.org; 18 Mar 2022 09:11:48 +0000 Original-Received: from localhost ([127.0.0.1]:56268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nV8eC-0001ii-GG for submit@debbugs.gnu.org; Fri, 18 Mar 2022 05:11:48 -0400 Original-Received: from mail-yw1-f179.google.com ([209.85.128.179]:46050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nV8eA-0001iG-9J for 54438@debbugs.gnu.org; Fri, 18 Mar 2022 05:11:46 -0400 Original-Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-2e5ad7166f1so72112347b3.12 for <54438@debbugs.gnu.org>; Fri, 18 Mar 2022 02:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HyiVzaSXTlKNq5jlXk+ZG5WJPavXRR+XIKQNanY5mWo=; b=g0UX2S61QNHDLpwRvmFFbUP8glgPN0k5HVHzHUjiqrACLowXYiPGtHPl9AkYw+ZJJ9 p60+XtooHLp4JzDgCfiZG4WTlTB/AH/hXpWxf7gFpyA/vS6TxUFCtxmAJtgC3uHlIQqv 6WrGteW5hkz8FYrC9Zu2rvUGkjvYFsEjiAnuXYVGv55m3xI/R7MI3eRCpsjSOw5o/M8D xR+10FSMQ9WDrVRWlk5l0ddiMvJDetDBBcgTJRCMfkDWM1a/TgvGotMvChaS+j9SMz/o DLWy7R3KrFGngWcD/JQ8ZbV6X6Ab+sEdsFh0wWlDcK2JvXdmW/avGPSePM6eO+kwgAJb GWLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HyiVzaSXTlKNq5jlXk+ZG5WJPavXRR+XIKQNanY5mWo=; b=HB1dAMM9B4ll9GYjKKfWzvTnGUuQMLHey7GSMmN0th16PgW4pmYuIQ2i6bQAmW5L4u mpk8GiZo06+dwvS16Nfx/foXEkoc/UDcRv9YjGO4YnRWoE3deTH7oNgM4SsOEjeBp6v4 T3vkx21xgFX3ABWXRsnaP2sm30dQXv15VLQP4XTtlePZfFPp7ckEknmBH/MaNJJF+iN3 mUUocV94kI7PjRTcxLkiYmYcAYSASsRuGKZaQLWreR0OCd4pyDNGn9y3rkP0u540gxu7 mxMbRm97kUuvbmD9q4/36tGjS+zpIsYdVAHU7au6qpnxT3vw75byxr7KB7xofeqcYlda u7Ig== X-Gm-Message-State: AOAM531lYp8oSgpsthIBuXYCTF4bA7r9W8K+AEc9fgaz/Vo6v8upzL9k 72v/aPhWGkib6i8FmrRWFpKy2sqyc5ddqBVUHMM= X-Google-Smtp-Source: ABdhPJwb0yTmgbuv/bKGAPu25I8cM4Y35JIH68Uqe0AoQ6IGRDo/1W2/ktwnQ9iSfrgwexdhJoesr342LtESHS4vaj4= X-Received: by 2002:a81:8983:0:b0:2dd:4537:4e9 with SMTP id z125-20020a818983000000b002dd453704e9mr10362546ywf.452.1647594700763; Fri, 18 Mar 2022 02:11:40 -0700 (PDT) In-Reply-To: <161a1515-187d-18c2-f9f1-86f4ea29614c@gmx.at> 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:228534 Archived-At: --000000000000df777d05da7a8895 Content-Type: text/plain; charset="UTF-8" Thank you for the reply. Ah, sorry I forgot to remove the parens to include the `pop-to-buffer` within the defun. About the 'restoring mechanism'; the global hook seems not to restore the window selected before running the hook. So here are the two separated test cases (they both use the 'pop-up' function) (defun pop-up () (pop-to-buffer "pop-up")) (defun test () (interactive) (with-current-buffer (get-buffer-create "test") (add-hook 'window-configuration-change-hook #'pop-up) (pop-to-buffer "test"))) ;; evaluate code to remove the (global) hook (remove-hook 'window-configuration-change-hook #'pop-up) (defun test () (interactive) (with-current-buffer (get-buffer-create "test") (add-hook 'window-configuration-change-hook #'pop-up nil t) (pop-to-buffer "test"))) So the 'restoring mechanism' works like you explained for the local hook but not for the global hook (where after calling 'test', the pop-up buffer will be selected). Also, I would expect that a hook just calls the hook function, and it would not 'restore the window selected before the hook'. I would say the restoring is undesired behavior. On Fri, 18 Mar 2022 at 09:37, martin rudalics wrote: > > I think it's a bad idea to do something that changes the window > > configuration in `window-configuration-change-hook'. It's not > > unexpected to get an infinite recursion or any other unpredictable > > behavior. > > People should avoid it in packages because they could easily step on > each other's toes. Written carefully, it could be useful in private > code. > > martin > --000000000000df777d05da7a8895 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for the reply. Ah, sorry I forgot to remove= the parens to include the `pop-to-buffer` within the defun.

=
About the 'restoring mechanism'; the global hook seems n= ot to restore the window selected before running the hook.

So here are the two separated test cases (they both use the 'p= op-up' function)

(defun pop-up ()
=C2=A0 (p= op-to-buffer "pop-up"))

(defun test ()
=C2=A0 (interact= ive)
=C2=A0 (with-current-buffer (get-buffer-create "test")=C2=A0 =C2=A0 (add-hook 'window-configuration-change-hook #'pop-up= )
=C2=A0 =C2=A0 (pop-to-buffer "test")))

;; evaluate co= de to remove the (global) hook
(remove-hook 'window-configuration-ch= ange-hook #'pop-up)

(defun test ()
=C2=A0 (interactive)
= =C2=A0 (with-current-buffer (get-buffer-create "test")
=C2=A0 = =C2=A0 (add-hook 'window-configuration-change-hook #'pop-up nil t)<= br>=C2=A0 =C2=A0 (pop-to-buffer "test")))


So the 'restoring mechanism' works like you explai= ned for the local hook but not for the global hook
(where after c= alling 'test', the pop-up buffer will be selected).

<= /div>
Also, I would expect that a hook just calls the hook function, an= d it would not 'restore the window
=C2=A0selected before the = hook'. I would say the restoring is undesired behavior.
<= br>


On Fri, 18 Mar 2022 at 09:37, martin rudalics <<= a href=3D"mailto:rudalics@gmx.at" target=3D"_blank">rudalics@gmx.at>= wrote:
=C2=A0&g= t; I think it's a bad idea to do something that changes the window
=C2=A0> configuration in `window-configuration-change-hook'.=C2=A0 I= t's not
=C2=A0> unexpected to get an infinite recursion or any other unpredictab= le
=C2=A0> behavior.

People should avoid it in packages because they could easily step on
each other's toes.=C2=A0 Written carefully, it could be useful in priva= te
code.

martin
--000000000000df777d05da7a8895--