unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Brubeck Unhammer <unhammer@fsfe.org>
To: 56113@debbugs.gnu.org
Subject: bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset
Date: Mon, 20 Jun 2022 22:04:24 +0200	[thread overview]
Message-ID: <87fsjzdruf.fsf@fastmail.com> (raw)


[-- 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 --]

             reply	other threads:[~2022-06-20 20:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 20:04 Kevin Brubeck Unhammer [this message]
2022-06-21 11:03 ` bug#56113: [PATCH] * lisp/mail/mail-extr.el: only set fundamental-mode if unset Lars Ingebrigtsen
2022-06-21 12:17   ` Kevin Brubeck Unhammer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsjzdruf.fsf@fastmail.com \
    --to=unhammer@fsfe.org \
    --cc=56113@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).