unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset
@ 2022-06-20 20:04 Kevin Brubeck Unhammer
  2022-06-21 11:03 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Brubeck Unhammer @ 2022-06-20 20:04 UTC (permalink / raw)
  To: 56113


[-- Attachment #1.1: Type: text/plain, Size: 708 bytes --]

Hi,

I noticed that opening groups with lots of unread messages in Gnus was
quite slow; profile shows that because I (bbdb-insinuate-gnus), it runs
mail-extract-address-components on them all and that function does

(with-current-buffer (get-buffer-create …)
    (fundamental-mode)
    …)

for every mail. Apparently (fundamental-mode) is slow since I use
evil-mode – so evil-mode could be faster, but also it seems unnecessary
to call fundamental-mode on fresh buffers? In any case, the attached
patch makes opening summaries 10x faster for people like me on
gnus+bbdb+evil.


best regards,
Kevin Brubeck Unhammer

(I have signed the copyright papers, still in the same job.)



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-lisp-mail-mail-extr.el-only-set-fundamental-mode-if-.patch --]
[-- Type: text/x-diff, Size: 1344 bytes --]

From 21186344e31e469c9e64b1b89977a20ed9605914 Mon Sep 17 00:00:00 2001
From: Kevin Brubeck Unhammer <unhammer@fsfe.org>
Date: Mon, 20 Jun 2022 21:48:21 +0200
Subject: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset

  (mail-extract-address-components): Avoid unnecessarily
  running mode hooks meant for interactive use
---
 lisp/mail/mail-extr.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el
index 50ba04ccc1..8713075db0 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -716,7 +716,8 @@ mail-extract-address-components
 	value-list)
 
     (with-current-buffer (get-buffer-create extraction-buffer)
-      (fundamental-mode)
+      (unless (eq major-mode 'fundamental-mode)
+        (fundamental-mode))
       (buffer-disable-undo extraction-buffer)
       (set-syntax-table mail-extr-address-syntax-table)
       (widen)
@@ -738,7 +739,7 @@ mail-extract-address-components
       (set-text-properties (point-min) (point-max) nil)
 
       (with-current-buffer (get-buffer-create canonicalization-buffer)
-	(fundamental-mode)
+        (unless (eq major-mode 'fundamental-mode) (fundamental-mode))
 	(buffer-disable-undo canonicalization-buffer)
 	(setq case-fold-search nil))
 
-- 
2.25.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset
  2022-06-20 20:04 bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset Kevin Brubeck Unhammer
@ 2022-06-21 11:03 ` Lars Ingebrigtsen
  2022-06-21 12:17   ` Kevin Brubeck Unhammer
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-21 11:03 UTC (permalink / raw)
  To: Kevin Brubeck Unhammer; +Cc: 56113

Kevin Brubeck Unhammer <unhammer@fsfe.org> writes:

> for every mail. Apparently (fundamental-mode) is slow since I use
> evil-mode – so evil-mode could be faster, but also it seems unnecessary
> to call fundamental-mode on fresh buffers? In any case, the attached
> patch makes opening summaries 10x faster for people like me on
> gnus+bbdb+evil.

Thanks.  I think calling fundamental-mode here is wrong in any case --
the buffer is always going to be in that mode already, so I think that's
just an old bug.  So I've amended your patch to just remove those lines,
and pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset
  2022-06-21 11:03 ` Lars Ingebrigtsen
@ 2022-06-21 12:17   ` Kevin Brubeck Unhammer
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Brubeck Unhammer @ 2022-06-21 12:17 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 56113

> Thanks.  I think calling fundamental-mode here is wrong in any case --
> the buffer is always going to be in that mode already, so I think that's
> just an old bug.  So I've amended your patch to just remove those lines,
> and pushed to Emacs 29.

Great, thanks :-D





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-21 12:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 20:04 bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset Kevin Brubeck Unhammer
2022-06-21 11:03 ` Lars Ingebrigtsen
2022-06-21 12:17   ` Kevin Brubeck Unhammer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).