From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53749: 29.0.50; [PATCH] Xref backend for TeX buffers Date: Mon, 13 May 2024 16:54:32 -0400 Message-ID: References: <2c5c8afa-b57e-3156-d21c-5523cacb4d87@yandex.ru> <831qf1mgjl.fsf@gnu.org> <87cyyj9rpp.fsf@gnu.org> <65793.1694843596@localhost> <83ba27b7-4d28-4a3f-b803-4bc49f62986c@yandex.ru> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12349"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 53749@debbugs.gnu.org, Ikumi Keita , David Fussner , Arash Esbati , stefankangas@gmail.com, Tassilo Horn , Eli Zaretskii To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 13 22:55:36 2024 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 1s6chq-0002uk-9r for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 May 2024 22:55:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6chL-0001hl-Ki; Mon, 13 May 2024 16:55:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6chK-0001hX-2v for bug-gnu-emacs@gnu.org; Mon, 13 May 2024 16:55:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6chJ-0000hO-Q7 for bug-gnu-emacs@gnu.org; Mon, 13 May 2024 16:55:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s6chK-0000nY-Di for bug-gnu-emacs@gnu.org; Mon, 13 May 2024 16:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 May 2024 20:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53749 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: pending patch Original-Received: via spool by 53749-submit@debbugs.gnu.org id=B53749.17156336843049 (code B ref 53749); Mon, 13 May 2024 20:55:02 +0000 Original-Received: (at 53749) by debbugs.gnu.org; 13 May 2024 20:54:44 +0000 Original-Received: from localhost ([127.0.0.1]:34920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6ch1-0000n7-Op for submit@debbugs.gnu.org; Mon, 13 May 2024 16:54:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6cgz-0000n1-OX for 53749@debbugs.gnu.org; Mon, 13 May 2024 16:54:42 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2B81B4406AB; Mon, 13 May 2024 16:54:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1715633673; bh=ZWMWsjI2JLV1tc9Thg3P51foBc998uoEt1i252E81oY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=N9sQ9ABi6Dn5le1CUh2GmBmSoTQbeSnxr82RFvGJ/rW5hmheYz6bnMbYNh1jupVIB bruZ1rit/VfyoICM6qpUCm61376lEeFNwF+uWOi8Mn7FEkZA9ikDWCU+eUgJX+SCqH MNkMaG6Xg1qiMER0+iTwPAVg/P7pdGv9wqpwnY5QZs9KdVLsw4IPHKXyKZHQ5HL8IM I8kNIJPD9YVfUnOC1e4To13fdpW0O80NeCt2lN+wV+YM6+Q1dXJ4FgVvaLRXWmfOil aJWZkF+TI7GyujiiwJOG+9K1RnD8i0JnWi2lgq8/1eUteE8jo4fKGgAHOyUNMo3rU/ y1jPETlML3gOw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8039C44444A; Mon, 13 May 2024 16:54:33 -0400 (EDT) Original-Received: from alfajor (bras-base-mtrlpq0776w-grc-16-65-93-169-175.dsl.bell.ca [65.93.169.175]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 598D212024C; Mon, 13 May 2024 16:54:33 -0400 (EDT) In-Reply-To: <83ba27b7-4d28-4a3f-b803-4bc49f62986c@yandex.ru> (Dmitry Gutov's message of "Thu, 9 May 2024 06:00:02 +0300") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284980 Archived-At: > For now, I've pushed a fix in 86187d43e2d which seems to handle David's > scenario and address your review comment as well. The let-binding is done outside of `with-current-buffer`, so it relies on the fact (itself problematic) that `inhibit-modification-hooks` is not buffer-local. Would it be OK to use a patch like the one below? IIUC, in the `syntax-needed` case, the let-binding of `inhibit-modification-hooks` is just not useful very (4-7% is not worth the trouble), so its purpose is to speed up the other case. Did I understand it right? Also, what about the other two bindings of `inhibit-modification-hooks`? Stefan diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index f9faec1b474..214e9cb6c09 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1282,7 +1282,7 @@ xref--show-common-initialize (erase-buffer) (setq overlay-arrow-position nil) (xref--insert-xrefs xref-alist) - (add-hook 'post-command-hook 'xref--apply-truncation nil t) + (add-hook 'post-command-hook #'xref--apply-truncation nil t) (goto-char (point-min)) (setq xref--original-window (assoc-default 'window alist) xref--original-window-intent (assoc-default 'display-action alist)) @@ -2112,10 +2112,7 @@ xref--convert-hits (defun xref--collect-matches (hit regexp tmp-buffer syntax-needed) (pcase-let* ((`(,line ,file ,text) hit) (file (and file (concat xref--hits-remote-id file))) - (buf (xref--find-file-buffer file)) - ;; This is fairly dangerouns, but improves performance - ;; for large lists, see https://debbugs.gnu.org/53749#227 - (inhibit-modification-hooks t)) + (buf (xref--find-file-buffer file))) (if buf (with-current-buffer buf (save-excursion @@ -2130,6 +2130,9 @@ ;; Using the temporary buffer is both a performance and a buffer ;; management optimization. (with-current-buffer tmp-buffer + ;; This let is fairly dangerouns, but improves performance + ;; for large lists, see https://debbugs.gnu.org/53749#227 + (let ((inhibit-modification-hooks t)) (erase-buffer) (when (and syntax-needed (not (equal file xref--temp-buffer-file-name))) @@ -2144,7 +2147,7 @@ (setq-local xref--temp-buffer-file-name file) (setq-local inhibit-read-only t) (erase-buffer)) - (insert text) + (insert text)) (goto-char (point-min)) (when syntax-needed (syntax-ppss-flush-cache (point)))