From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Simon Katz Newsgroups: gmane.emacs.bugs Subject: bug#50042: 26.3; Post-command hooks slow with M-x commands Date: Fri, 13 Aug 2021 12:52:32 +0100 Message-ID: Reply-To: sk@nomistech.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000409e1e05c96f7d8d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2795"; mail-complaints-to="usenet@ciao.gmane.io" To: 50042@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 13 13:54: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 1mEVlK-0000VR-LC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Aug 2021 13:54:10 +0200 Original-Received: from localhost ([::1]:33878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEVlI-0007vj-Ou for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Aug 2021 07:54:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEVlC-0007vK-9B for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 07:54:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEVlC-0006lX-2T for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 07:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mEVlC-0007Jq-1j for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 07:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simon Katz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Aug 2021 11:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50042 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162885562128106 (code B ref -1); Fri, 13 Aug 2021 11:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Aug 2021 11:53:41 +0000 Original-Received: from localhost ([127.0.0.1]:40663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEVkr-0007JG-6l for submit@debbugs.gnu.org; Fri, 13 Aug 2021 07:53:41 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:49614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mEVkm-0007J4-8T for submit@debbugs.gnu.org; Fri, 13 Aug 2021 07:53:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEVkl-0007v4-W9 for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 07:53:36 -0400 Original-Received: from s30.dg.net.uk ([91.224.108.30]:42502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEVkj-0006A5-Gp for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 07:53:35 -0400 Original-Received: from mail-wr1-f50.google.com ([209.85.221.50]:39480) by s30.dg.net.uk with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1mEVjv-00076E-UV for bug-gnu-emacs@gnu.org; Fri, 13 Aug 2021 12:52:43 +0100 Original-Received: by mail-wr1-f50.google.com with SMTP id q6so1398935wrv.6 for ; Fri, 13 Aug 2021 04:52:43 -0700 (PDT) X-Gm-Message-State: AOAM531rJAXov3lf9upCPmTo2TcyKj3oK9sc1cszcujFbuf7+oGaD+Pz grmBeQix37J8LOeQsCV8OlQ+hzH43+nobqrb4mY= X-Google-Smtp-Source: ABdhPJzPTVJhC/kgj9/DtHb2JUB2ghcEvquyctPXyd5rBajh0fo8GtcP8fa0gc5L8aP9yHcJ0Zh5z0vwq89wCw3HTKw= X-Received: by 2002:adf:fc50:: with SMTP id e16mr2731013wrs.382.1628855563491; Fri, 13 Aug 2021 04:52:43 -0700 (PDT) X-Gmail-Original-Message-ID: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s30.dg.net.uk X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nomistech.com X-Get-Message-Sender-Via: s30.dg.net.uk: authenticated_id: non-junk@nomistech.com X-Authenticated-Sender: s30.dg.net.uk: non-junk@nomistech.com Received-SPF: pass client-ip=91.224.108.30; envelope-from=sk@nomistech.com; helo=s30.dg.net.uk X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:211737 Archived-At: --000000000000409e1e05c96f7d8d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Post-command hooks are slow to run for commands invoked using `M-x ...`. I'm using Emacs 26.3 (which produced this bug report), but I've checked with 27.2.2 and I get the same behaviour. Here's a startup file that can be used to show this (also at https://github.com/simon-katz/demo-post-command-hook-slow-with-m-x-commands= .el/blob/8e7b96fc322f6372fb1531f04ab6008d59ab9b9e/demo-post-command-hook-sl= ow-with-m-x-commands.el#L1 ). ;;; demo-post-command-hook-slow-with-m-x-commands.el --- Demo that post-sommand hooks are slow with M-x commands -*- lexical-binding: t; -*- ;; This demonstrates an issue with `(add-hook 'post-command-hook ...)`. ;; To reproduce the problem: ;; - Run `emacs -q -l demo-post-command-hook-slow-with-m-x-commands.el` (that's ;; this file). ;; - Enter `M-x next-line`. ;; - Observe that the message displayed by the `say-something` function ;; takes a while to appear. ;; - Contrast with hitting the down-arrow key, when the message appears ;; immediately. ;;; Code: (require 'package) (setq debug-on-error t no-byte-compile t package-archives '(("melpa" . "https://melpa.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/")) package-user-dir (expand-file-name (make-temp-name "flycheck-tmp-elpa") user-emacs-directory) custom-file (expand-file-name "custom.el" package-user-dir)) (defun say-something () (let ((inhibit-message t)) (message "With `M-x next-line` (for example), this message is slow to appear"))= ) (add-hook 'post-command-hook 'say-something) (display-buffer "*Messages*") (provide 'demo-post-command-hook-slow-with-m-x-commands) ;;; demo-post-command-hook-slow-with-m-x-commands.el ends here In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-09-02 built on builder10-14.porkrind.org Windowing system distributor 'Apple', version 10.3.1894 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. With =E2=80=98M-x next-line=E2=80=98 (for example), this message is slow to= appear [13 times] You can run the command =E2=80=98next-line=E2=80=99 with C-n With =E2=80=98M-x next-line=E2=80=98 (for example), this message is slow to= appear [10 times] Quit With =E2=80=98M-x next-line=E2=80=98 (for example), this message is slow to= appear [7 times] Making completion list... With =E2=80=98M-x next-line=E2=80=98 (for example), this message is slow to= appear [6 times] Configured using: 'configure --with-ns '--enable-locallisppath=3D/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS Important settings: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: tooltip-mode: t global-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 blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort map mail-extr emacsbug message rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec epa derived epg 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 demo-post-command-hook-slow-with-m-x-commands package easymenu epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win 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 threads kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 213714 7973) (symbols 48 21049 1) (miscs 40 83 191) (strings 32 31839 1672) (string-bytes 1 863206) (vectors 16 36747) (vector-slots 8 745240 8812) (floats 8 57 65) (intervals 56 214 0) (buffers 992 13)) --000000000000409e1e05c96f7d8d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Post-command hooks are slow to run for commands invoked us= ing `M-x ...`.

I'm using Emacs 26.3 (which produced this bug rep= ort), but I've checked with 27.2.2 and I get the same behaviour.

Here's a startup file that can be used to show this (also at https://github.com/simon-katz/demo-post-= command-hook-slow-with-m-x-commands.el/blob/8e7b96fc322f6372fb1531f04ab6008= d59ab9b9e/demo-post-command-hook-slow-with-m-x-commands.el#L1).

= ;;; demo-post-command-hook-slow-with-m-x-commands.el --- Demo that post-som= mand hooks are slow with M-x commands =C2=A0 =C2=A0 =C2=A0-*- lexical-bindi= ng: t; -*-

;; This demonstrates an issue with `(add-hook 'post-c= ommand-hook ...)`.

;; To reproduce the problem:
;; - Run `emacs -= q -l demo-post-command-hook-slow-with-m-x-commands.el` (that's
;; = =C2=A0 this file).
;; - Enter `M-x next-line`.
;; - Observe that the = message displayed by the `say-something` function
;; =C2=A0 takes a whil= e to appear.
;; - Contrast with hitting the down-arrow key, when the mes= sage appears
;; =C2=A0 immediately.

;;; Code:

(require = 9;package)

(setq debug-on-error t
=C2=A0 =C2=A0 =C2=A0 no-byte-co= mpile t
=C2=A0 =C2=A0 =C2=A0 package-archives '(("melpa" .= "https://melpa.org/packages/<= /a>")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0("gnu" . "
https://elpa.gnu.org/packages/"))
=C2= =A0 =C2=A0 =C2=A0 package-user-dir (expand-file-name (make-temp-name "= flycheck-tmp-elpa")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0user-emacs-directory)
=C2=A0 =C2=A0 =C2=A0 cu= stom-file (expand-file-name "custom.el" package-user-dir))
(defun say-something ()
=C2=A0 (let ((inhibit-message t))
=C2=A0 =C2= =A0 (message
=C2=A0 =C2=A0 =C2=A0"With `M-x next-line` (for example= ), this message is slow to appear")))

(add-hook 'post-comma= nd-hook 'say-something)

(display-buffer "*Messages*")<= br>
(provide 'demo-post-command-hook-slow-with-m-x-commands)
;;; = demo-post-command-hook-slow-with-m-x-commands.el ends here



<= br>

In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit= -1671.20 Version 10.14.3 (Build 18D109))
=C2=A0of 2019-09-02 built on builder10-14.porkrind.orgWindowing system distributor 'Apple', version 10.3.1894
Recent = messages:
For information about GNU Emacs and the GNU system, type C-h C= -a.
With =E2=80=98M-x next-line=E2=80=98 (for example), this message is = slow to appear [13 times]
You can run the command =E2=80=98next-line=E2= =80=99 with C-n
With =E2=80=98M-x next-line=E2=80=98 (for example), this= message is slow to appear [10 times]
Quit
With =E2=80=98M-x next-lin= e=E2=80=98 (for example), this message is slow to appear [7 times]
Makin= g completion list...
With =E2=80=98M-x next-line=E2=80=98 (for example),= this message is slow to appear [6 times]

Configured using:
=C2= =A0'configure --with-ns '--enable-locallisppath=3D/Library/Applicat= ion
=C2=A0Support/Emacs/${version}/site-lisp:/Library/Application
=C2= =A0Support/Emacs/site-lisp' --with-modules'

Configured featu= res:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREA= DS

Important settings:
=C2=A0 value of $LANG: en_GB.UTF-8
=C2= =A0 locale-coding-system: utf-8-unix

Major mode: Fundamental

= Minor modes in effect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mod= e: 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
=C2=A0 global-font-lock-mode: t
=C2=A0 blink-cursor-mode: t=C2=A0 auto-composition-mode: t
=C2=A0 auto-encryption-mode: t
=C2= =A0 auto-compression-mode: t
=C2=A0 buffer-read-only: t
=C2=A0 line-n= umber-mode: t
=C2=A0 transient-mark-mode: t

Load-path shadows:None found.

Features:
(shadow sort map mail-extr emacsbug messag= e rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec epa deriv= ed epg 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
demo-post-command-hook-slow-= with-m-x-commands package easymenu
epg-config url-handlers url-parse aut= h-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache u= rl-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib e= lec-pair time-date tooltip eldoc
electric uniquify ediff-hook vc-hooks l= isp-float-type mwheel term/ns-win
ns-win ucs-normalize mule-util term/co= mmon-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list rep= lace newcomment text-mode
elisp-mode lisp-mode prog-mode register page m= enu-bar rfn-eshadow
isearch timer select scroll-bar mouse jit-lock font-= lock syntax facemenu
font-core term/tty-colors frame cl-generic cham geo= rgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean j= apanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european eth= iopic indian
cyrillic chinese composite charscript charprop case-table e= pa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded= nadvice
loaddefs button faces cus-face macroexp files text-properties o= verlay
sha1 md5 base64 format env code-pages mule custom widget
hasht= able-print-readable backquote threads kqueue cocoa ns multi-tty
make-net= work-process emacs)

Memory information:
((conses 16 213714 7973)<= br>=C2=A0(symbols 48 21049 1)
=C2=A0(miscs 40 83 191)
=C2=A0(strings = 32 31839 1672)
=C2=A0(string-bytes 1 863206)
=C2=A0(vectors 16 36747)=
=C2=A0(vector-slots 8 745240 8812)
=C2=A0(floats 8 57 65)
=C2=A0(= intervals 56 214 0)
=C2=A0(buffers 992 13))
--000000000000409e1e05c96f7d8d--