From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#25243: 26.0.50; ffap-guesser very slow w/ region active in large diff files Date: Wed, 21 Dec 2016 08:22:19 -0800 (PST) Message-ID: <36cb0896-f437-41f6-92d1-1f8897ff141d@default> References: <87k2at2t28.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1482337399 6187 195.159.176.226 (21 Dec 2016 16:23:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Dec 2016 16:23:19 +0000 (UTC) To: Tino Calancha , 25243@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 21 17:23:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJjfb-0000WK-0x for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Dec 2016 17:23:11 +0100 Original-Received: from localhost ([::1]:57794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJjff-0004Eg-IC for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Dec 2016 11:23:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJjfW-0004DF-Dk for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 11:23:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJjfS-0008EC-FL for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 11:23:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35019) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cJjfS-0008E8-Bb for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 11:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cJjfS-0006du-5W for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 11:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Dec 2016 16:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25243 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25243-submit@debbugs.gnu.org id=B25243.148233735125479 (code B ref 25243); Wed, 21 Dec 2016 16:23:02 +0000 Original-Received: (at 25243) by debbugs.gnu.org; 21 Dec 2016 16:22:31 +0000 Original-Received: from localhost ([127.0.0.1]:50418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJjex-0006ct-6P for submit@debbugs.gnu.org; Wed, 21 Dec 2016 11:22:31 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:25587) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJjev-0006cg-6A for 25243@debbugs.gnu.org; Wed, 21 Dec 2016 11:22:29 -0500 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uBLGMLmO023621 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2016 16:22:22 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uBLGMLtN008233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2016 16:22:21 GMT Original-Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uBLGMKFL014169; Wed, 21 Dec 2016 16:22:20 GMT In-Reply-To: <87k2at2t28.fsf@gmail.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127292 Archived-At: Amusing backstory: In some of my code I use `ffap-guesser' to pick up file-name defaults for own my version of `read-file-name'. I added that pretty much naively, without digging into the `ffap-guesser' code to check what it does. It seemed to work pretty well. Tino sent me a diff file of about 14 KB, which showed the problem. Other files, even 10 times as large (!), didn't necessarily show the problem. The test case was to use `write-region' in that diff-file buffer, after `C-x h'. (In context, `write-region' invoked my version of `read-file-name'.) Looking closer, I saw that `ffap-guesser' tries to use the text in the active region to guess a file name, and that it passes this text around to multiple functions that examine it, search through it, and massage it (e.g., remove text properties). Needless to say, this is problematic for a large active region. Had the doc string of `ffap-guesser' (and other functions that call it and that it calls) mentioned that it uses the active region, I likely would never have used it as I did. Stefan did add a comment, in Emacs 23, for one call to `ffap-guesser', which is helpful: ;; Don't use the region here, since it can be something ;; completely unwieldy. If the user wants that, she could ;; use M-w before and then C-y. --Stef But it's not just for that occurrence that the problem can exist. And putting that info in a doc string would be more helpful than just in a comment. It's not just a message to Emacs implementers; it's something that users of the ffap functions should know about. Preventing the problem in the first place, as Tino's patch tries to do, is even better than just documenting the gotcha. The ffap.el code does prevent the problem itself for some uses of `ffap-guesser' (e.g. `ffap-prompter'), but it is in `ffap-guesser' itself (or `ffap-file-at-point' or `ffap-string-at-point') that this should be done. Wrt the proposed patch: 1. It is `ffap-string-at-point' that picks up the active region text as a string and removes its properties. Since that is what is slow, I think it is in that function that preventing this from happening should occur. The patch tries to control this only in `ffap-file-at-point', and it does so _after_ calling `ffap-string-at-point', which is too late (AFAICS). I think that `ffap-string-at-point' should control this. It should not try to pick up a file name from a 14 KB diff buffer. 2. I'm not sure that a user option is really what's called for here. I'd suggest a defvar, but only because Emacs Dev does not really like programs to bind option values (I have little problem with that, myself), and that is the main place where I expect the value to be changed: programmatically. Thanks, Tino, for finding this bug and reporting it.