From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Smith Newsgroups: gmane.emacs.bugs Subject: bug#57367: [PATCH] Speed up em-smart Date: Tue, 23 Aug 2022 16:06:21 -0400 Message-ID: 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="18395"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: johnw@gnu.org To: 57367@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 23 22:07:12 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 1oQaB6-0004ba-50 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Aug 2022 22:07:12 +0200 Original-Received: from localhost ([::1]:40934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQaB4-0003zK-Ni for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Aug 2022 16:07:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQaAw-0003uz-KN for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 16:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQaAw-0001TQ-BV for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 16:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQaAw-00078C-6d for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 16:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Aug 2022 20:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57367 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.166128519527380 (code B ref -1); Tue, 23 Aug 2022 20:07:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Aug 2022 20:06:35 +0000 Original-Received: from localhost ([127.0.0.1]:45097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQaAU-00077Y-UO for submit@debbugs.gnu.org; Tue, 23 Aug 2022 16:06:35 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:48840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQaAT-00077P-BY for submit@debbugs.gnu.org; Tue, 23 Aug 2022 16:06:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQaAT-0003bQ-5X for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 16:06:33 -0400 Original-Received: from mail-bn7nam10olkn2063.outbound.protection.outlook.com ([40.92.40.63]:7264 helo=NAM10-BN7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQaAP-0001QI-QK; Tue, 23 Aug 2022 16:06:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZUwYqZsxhFy1PIEjraJltzSuTsWmFGZacDotMP/EDAUyMvGSWkuBk/kCzmffXpZTcC4jRNGCkt3/4nDB2GAJFtuGsQQLC3pAANG0UkdMdrFlhO3SWvJsMOXvSJezf8yQdwz4KqS7+YEUgrq9drVuqRnvJtHb997PPUfn6Xuv8x1Mba2/h+MEfJpqArrhgwqiGJvXgjDhDiAi7r/lgI35SWy9NnaTK1C+PA553czuGtXRbpr+CieaW95swgx0mr+f5e+ucYWTu5tomxFxX/71Qa0Mf3TJyOXiQL/A34a0oXOwinMoZBSp+/90o2ruJ5Kvbp4kgWbP0pOyH5TV1omKsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tn0fiqnxtK33/esIh0H7kuQVT6CCwP6naEksxlZirS8=; b=XvVYcYarb70a7TgxngCAzvYI9iiWlULy2Q5jxykZyj3f9xCT6n4QnlVwxYJgMYNojSgTbZMeC/D3wS9SFjKyheLE2NMsw46uvgBxboDCIJj9vqDfDdrSzQx4o6dpn1f32vgnIQ3OJRn6zvyfTbel6PlRlLMAakQLBa0cRcAJXxPTxe/tnZZlVz9l20w0uq0w5dJYF3vfprSJJN6RjXhFMvHAQB31TJhPHirvAN9ciPRhRvb3Ph1oL0eZQSOzu4qgE6NwXy9fVOAB0TVu2GKTZZlFI0j5ucffoIZl736N8tojwwI/5kq4AwJR2RpCCMIaxyLYkX5eNY4ym84LYPkmMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tn0fiqnxtK33/esIh0H7kuQVT6CCwP6naEksxlZirS8=; b=Yu6uM0wwblCPf3JB9w1E5fPl8ytnr9WBYgcFPnvuj6/KRE3mEhqeX8O+CdoJqvjIPiHHtErXJPPOb9v1kHzxwNsmQNOgJwUmivFn683Etfpqx2m706gp8mR4yqG0BRodZym2Z/5Em0bEdR8LpFqB2RsyZZ5zvN1XjQ4M2ccKoK31g93EoyhRay/7d6xvDVLczTA9kwdvRfIRdnF7dE8VWweITAmLT7KhpOaNff2lkk2aYCrRaZT88IKkik1i7LWwEIvDqsGi6onikAD674Lgzq6mpcj5yNDg/OoeSVhZAcIz9ATy1F72xYF5QxYkm0wJiQSYsR984LTLdx7YeDTcGQ== Original-Received: from DM5PR03MB3163.namprd03.prod.outlook.com (2603:10b6:4:40::24) by SJ0PR03MB6469.namprd03.prod.outlook.com (2603:10b6:a03:398::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Tue, 23 Aug 2022 20:06:25 +0000 Original-Received: from DM5PR03MB3163.namprd03.prod.outlook.com ([fe80::1cf8:e25b:a93b:ffac]) by DM5PR03MB3163.namprd03.prod.outlook.com ([fe80::1cf8:e25b:a93b:ffac%6]) with mapi id 15.20.5546.023; Tue, 23 Aug 2022 20:06:25 +0000 X-TMN: [7UmaKUrDG2Rfom4x2SB/yoQQO0om2d85] X-ClientProxiedBy: BL1PR13CA0211.namprd13.prod.outlook.com (2603:10b6:208:2bf::6) To DM5PR03MB3163.namprd03.prod.outlook.com (2603:10b6:4:40::24) X-Microsoft-Original-Message-ID: <87k06y9136.fsf@outlook.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 855b028d-53ba-4b0f-98e9-08da8542f416 X-MS-TrafficTypeDiagnostic: SJ0PR03MB6469:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RTZr4gxcq93RE7OEN+EtmnXnwMq8arHPaxCrp2ZAjay7sqS9VfwurwKG195rsVWxVOXLwYZu0vpVVuegW8Txtb/cioZfBCJ4juvhFE3kxCYabH4iQjd8o4xucKCylpmNZsMEBvNDk4ynIN+MufBpc1NFApoToEOVzLRBaYI1iINJYXA0JhlvckPkL5FuYyIvaHA+1A2DgZ23Gz/FBZBl3OepfA3GUuSA+BsfWdvjUn6/15jCJFM/1Qji5N9wrgLXpgz0AT0EaHm30aEyQ3tgpD9PwXbti9rEsL/bUaiFKQyEXpQYOSX14FWAfw9H8LXRpihRDvbgbGHOjKdg9X2DoHRUBvAhON19Cn2ibnJ4sYQjnrjKk2BU+z2pXxf/JeH2JPBqHehsObS25jijal0IjVvJRV2QReZC/cb6RRGlSmvs9ws8lWiJIwgZOz8Lfna4e454arw5NDM0PtwSwNLk09zXsggJf0tPwUZVvvy4FqUO9/v2WuUK5Qq2i0rlstPn3fJ1Ch4CsaWU0QUyl6zDwFJmJt34M8dTUyTKCEe4PAWR2YLsEdGwt6OXom4+OC2S6VXM6BZ3ygYRor7KCl/nnIuKKatDm/XIveLp6PXX7IZqVG4jRGAQQhQt7UAu8miQ11gGVjP65179DLcp+O4wMA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OwSL9del8ujAQ2ZrSj+xs8LWSqI/89FNjUk8lzndPoh1kawQ1TpXu8ysaAd+oOpn2U9Q0/FrBTXYuJ2yHh4pGR0fL5uc6uofNah7XCBXND1JimAyezzO4j5bA7+qWVF+jorrIxjAEZgknuQP9u190GKw2y6IObJx0g8w/FoPcmgZqNaHIIGslyRrWmgoZIbLWIU3V3/KNQvHOBM4zZGjX3bIOqJg4gecNL6pK2Jt4EI5kmCCjgT+UFuK858jG0ecar/W0hM6KJe111DTQUg0dnZOXIut/LSxaR+iH60110uc9ukz6/MVpizcalmAseobetO5oO6qFigslGCV1mF35MUFCphcDVC/f2tve+uiMHJMHtsBsvREZSyEFDm7OgTso6vn3/vghSQr3Mb5dWqXJ+lhYCjaNo3ustd80azWmssX3nYvg01vVXpf0HCIj/lyg3ODcR5c0pw96D0jS80hTxueV4hwB24OIkMUAD70MFUOhoGe4irACBCsVbuc22Wb0/QaYIYpsW2TqtIQw2lRzuKh2WV0CvG7uEaDYfHpHRyeJTH1sDTR8Bq1J2AOoSTeeMdFuAkK4lvGKyJIf967Ui1nmTHny3beQJlA8yyu4JN2FT286jZOkDQAAF8Xnd1c/YQTCTEwS/s5+1KpG60Ex9H6e+jxnRVUJPRih5fJlsNGe7oD97YMuBDF6FJiwv+ftSq1D32r+mkNnXjf0Pz++a8N7573FPZOXLWw+pwPViO80oq5lyf0YLTCJs MFhZwgzHKpd3p/w/WuFemvxf0Z8o6zJD1xVMZafiYenyu/2OEqTyiqguE8P7ZmksrrMvpOf/ZZ6g8i3v27LXLB0wNonRAW86RV X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 855b028d-53ba-4b0f-98e9-08da8542f416 X-MS-Exchange-CrossTenant-AuthSource: DM5PR03MB3163.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2022 20:06:25.0177 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB6469 Received-SPF: pass client-ip=40.92.40.63; envelope-from=Morgan.J.Smith@outlook.com; helo=NAM10-BN7-obe.outbound.protection.outlook.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_PASS=-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:240571 Archived-At: --=-=-= Content-Type: text/plain Hello, em-smart is very slow. This patch makes it much faster. idk why there was all this redisplay stuff in the module as everything seems to work great when I remove it all. Thanks John Wiegley for writing this module! It's a pretty cool concept and I'm having fun playing with it Thanks, Morgan --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Speed-up-em-smart.patch >From f015d6ac42d18bf4dbc2223dc6c96d964e4dd994 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Tue, 23 Aug 2022 15:47:17 -0400 Subject: [PATCH] Speed up em-smart em-smart was forcibly re-displaying the screen upwards of 500 times per screen of output. This caused the eshell to feel quite slow when the module was in use. Everything seems to work just fine without any redisplay stuff so I just tore it all out. list/eshell/em-smart.el: (eshell-mart-unload-hook): Remove eshell-refresh-windows (eshell-smart-displayed, eshell-currently-handling-window, eshell-refresh-windows, eshell-smart-redisplay): Delete (eshell-smart-scroll-window): Add a bunch of logic originally from eshell-smart-redisplay (eshell-smart-initialize): Don't add hooks for deleted functions. Use eshell-output-filter-functions to run eshell-smart-scroll-window (eshell-smart-display-setup): Don't refresh windows --- lisp/eshell/em-smart.el | 79 +++++++++++------------------------------ 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el index 6768cee4c3..708f950d48 100644 --- a/lisp/eshell/em-smart.el +++ b/lisp/eshell/em-smart.el @@ -92,11 +92,7 @@ it to get a real sense of how it works." :type 'hook :group 'eshell-smart) -(defcustom eshell-smart-unload-hook - (list - (lambda () - (remove-hook 'window-configuration-change-hook - 'eshell-refresh-windows))) +(defcustom eshell-smart-unload-hook nil "A hook that gets run when `eshell-smart' is unloaded." :type 'hook :group 'eshell-smart) @@ -159,9 +155,7 @@ The options are `begin', `after' or `end'." ;;; Internal Variables: -(defvar eshell-smart-displayed nil) (defvar eshell-smart-command-done nil) -(defvar eshell-currently-handling-window nil) ;;; Functions: @@ -174,10 +168,7 @@ The options are `begin', `after' or `end'." (setq-local eshell-scroll-to-bottom-on-input nil) (setq-local eshell-scroll-show-maximum-output t) - (add-hook 'window-scroll-functions 'eshell-smart-scroll-window nil t) - (add-hook 'window-configuration-change-hook 'eshell-refresh-windows) - - (add-hook 'eshell-output-filter-functions 'eshell-refresh-windows t t) + (add-hook 'eshell-output-filter-functions 'eshell-smart-scroll-window nil t) (add-hook 'after-change-functions 'eshell-disable-after-change nil t) @@ -193,29 +184,23 @@ The options are `begin', `after' or `end'." (add-hook 'eshell-post-command-hook 'eshell-smart-maybe-jump-to-end nil t)))) -;; This is called by window-scroll-functions with two arguments. -(defun eshell-smart-scroll-window (wind _start) - "Scroll the given Eshell window WIND accordingly." - (unless eshell-currently-handling-window - (let ((inhibit-point-motion-hooks t) - (eshell-currently-handling-window t)) - (with-selected-window wind - (eshell-smart-redisplay))))) - -(defun eshell-refresh-windows (&optional frame) - "Refresh all visible Eshell buffers." - (let (affected) - (walk-windows - (lambda (wind) - (with-current-buffer (window-buffer wind) - (if eshell-mode - (let (window-scroll-functions) ;;FIXME: Why? - (eshell-smart-scroll-window wind (window-start)) - (setq affected t))))) - 0 frame) - (if affected - (let (window-scroll-functions) ;;FIXME: Why? - (eshell-redisplay))))) +(defun eshell-smart-scroll-window () + "Scroll the selected window to display as much output as possible, smartly." + (when (eq (window-buffer (selected-window)) (current-buffer)) + (let ((top-point (point))) + (and (memq 'eshell-smart-display-move pre-command-hook) + (>= (point) eshell-last-input-start) + (< (point) eshell-last-input-end) + (set-window-start (selected-window) + (line-beginning-position) t)) + (if (pos-visible-in-window-p (point-max)) + (save-excursion + (goto-char (point-max)) + (recenter -1) + (unless (pos-visible-in-window-p top-point) + (goto-char top-point) + (set-window-start (selected-window) + (line-beginning-position) t))))))) (defun eshell-smart-display-setup () "Set the point to somewhere in the beginning of the last command." @@ -232,8 +217,7 @@ The options are `begin', `after' or `end'." (t (error "Invalid value for `eshell-where-to-jump'"))) (setq eshell-smart-command-done nil) - (add-hook 'pre-command-hook 'eshell-smart-display-move nil t) - (eshell-refresh-windows)) + (add-hook 'pre-command-hook 'eshell-smart-display-move nil t)) ;; Called from after-change-functions with 3 arguments. (defun eshell-disable-after-change (_b _e _l) @@ -255,29 +239,6 @@ and the end of the buffer are still visible." (goto-char (point-max)) (remove-hook 'pre-command-hook 'eshell-smart-display-move t))) -(defun eshell-smart-redisplay () - "Display as much output as possible, smartly." - (if (eobp) - (save-excursion - (recenter -1) - ;; trigger the redisplay now, so that we catch any attempted - ;; point motion; this is to cover for a redisplay bug - (eshell-redisplay)) - (let ((top-point (point))) - (and (memq 'eshell-smart-display-move pre-command-hook) - (>= (point) eshell-last-input-start) - (< (point) eshell-last-input-end) - (set-window-start (selected-window) - (line-beginning-position) t)) - (if (pos-visible-in-window-p (point-max)) - (save-excursion - (goto-char (point-max)) - (recenter -1) - (unless (pos-visible-in-window-p top-point) - (goto-char top-point) - (set-window-start (selected-window) - (line-beginning-position) t))))))) - (defun eshell-smart-goto-end () "Like `end-of-buffer', but do not push a mark." (interactive) -- 2.37.2 --=-=-=--