From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#25243: 26.0.50; ffap-guesser very slow w/ region active in large diff files Date: Thu, 22 Dec 2016 00:35:59 +0900 Message-ID: <87k2at2t28.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1482334634 30834 195.159.176.226 (21 Dec 2016 15:37:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Dec 2016 15:37:14 +0000 (UTC) To: 25243@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 21 16:37:10 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 1cJix1-0007NB-8D for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Dec 2016 16:37:07 +0100 Original-Received: from localhost ([::1]:57627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJix5-00048G-Pq for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Dec 2016 10:37:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJiwz-000488-Mr for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:37:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJiww-0007Qw-J4 for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:37:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35001) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cJiww-0007Qs-FK for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cJiww-0005Xv-7N for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Dec 2016 15:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25243 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148233458121268 (code B ref -1); Wed, 21 Dec 2016 15:37:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Dec 2016 15:36:21 +0000 Original-Received: from localhost ([127.0.0.1]:50400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJiwH-0005Ww-41 for submit@debbugs.gnu.org; Wed, 21 Dec 2016 10:36:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJiwG-0005Wj-A3 for submit@debbugs.gnu.org; Wed, 21 Dec 2016 10:36:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJiwA-0007AK-1H for submit@debbugs.gnu.org; Wed, 21 Dec 2016 10:36:15 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cJiw9-0007AD-UI for submit@debbugs.gnu.org; Wed, 21 Dec 2016 10:36:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJiw8-0003xZ-LA for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:36:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJiw3-000792-PW for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:36:12 -0500 Original-Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:33862) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cJiw3-00078K-JR for bug-gnu-emacs@gnu.org; Wed, 21 Dec 2016 10:36:07 -0500 Original-Received: by mail-pf0-x241.google.com with SMTP id y68so11085023pfb.1 for ; Wed, 21 Dec 2016 07:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=JXNbdNkD3g5pcXAye1ueO4SlaHRzag71S56Qik0+9EQ=; b=qpfI9NiJEmZ8bagZbYKCsAxBcA1sXlX9oSSg/X/fm61nYS+zwqym+rj/NTwnpvD1Me 3eTDGZH9arRojaS7x3/jf2VuNZWIpL75gadZG4jsaKTnktTXA4tAy8GvQdzKcHj5WG20 22b33XQREDWX4bChRyF4sOzwHwgfLPMb7CP2Yty220DXFwHYpUubco4/cS+sCC4SpLDh s62Gu4FiX1sY599ljIt5MdFbolA5w6qXsJa6YVXrfxDZy5+BY97MyEWvkv+WC7Ds5MNy 4ocJf6mvFHVGQZH5Poyn+SWr8yGZGQDKAoWfCxeG4uoAZMpjJD4tA7FNs2ThUtcjv0DK 2BJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=JXNbdNkD3g5pcXAye1ueO4SlaHRzag71S56Qik0+9EQ=; b=AGNgkA4Lmd/RNkENT4X0w5C2ks5CzZ3vcdSVmzb1x9UZejzuxbj1YK+KGPu/wfrctB Zsf1EkepXZ6g1Y5ISWgOFln3XjWtmDEYVThYeG9mI38iHg/QdszhfUuXDMk6lcjV/c4K A1Dj11tDV7Zx/XEPm5jvdqFTLNyBRIBSnNHP2yG2loyhai6TELuulthlbd4WAeT/Uafk /RiED4lTEJidu9dvRjV1CYj2CzkdGhnE/QxkQ4ujCkm8BJq6myXO/ALkGZ10YY/LTfJU ZYENvRtnoLV2h+sO6SP8UP/jpQ274B+xWCgre1xad8nRELxMwjC10hgRFzfZyQhf55ZV D2Pg== X-Gm-Message-State: AIkVDXIvhlKEw+ax8Rc7J4hkTWPVSVor3tKF/q63clxyvFUBI80CCoA3Qlt+/WH5QMbatw== X-Received: by 10.98.74.142 with SMTP id c14mr4542467pfj.139.1482334564552; Wed, 21 Dec 2016 07:36:04 -0800 (PST) Original-Received: from calancha-pc (177.192.218.133.dy.bbexcite.jp. [133.218.192.177]) by smtp.gmail.com with ESMTPSA id 1sm48292885pgp.1.2016.12.21.07.36.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Dec 2016 07:36:04 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:127291 Archived-At: The slowness is apparent for diff files with > 2 klines. emacs -Q -l ffap ;; From emacs git rep. extract a diff w/ 10 klines. M-! git diff HEAD~200 | head -10000 > /tmp/test-Bug25243 M-: (find-file "/tmp/test-Bug25243") C-x h M-: (ffap-guesser) ;; It took > 2 min in my box. In this example `ffap-guesser' is spending long time testing the whole buffer content as a file name candidate. It might has sense to introduce a maximum limit in the length for file names in `ffap-file-at-point'. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 9e919ba3c86a912bc42cb8e439ad7b8b3660dc37 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Thu, 22 Dec 2016 00:27:50 +0900 Subject: [PATCH] ffap-file-at-point: Limit length of file names Do not spend time checking large strings which are likely not actual file names (Bug#25243). * lisp/ffap.el (ffap-file-name-max-length): New option. (ffap-file-at-point): Use it. ; etc/NEWS: Add entry for the new option. --- etc/NEWS | 4 ++++ lisp/ffap.el | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 7338c0c6a7..fd89568c6e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -312,6 +312,10 @@ the file's actual content before prompting the user. * Changes in Specialized Modes and Packages in Emacs 26.1 +** ffap + +*** A new user option 'ffap-file-name-max-length'. + ** Electric-Buffer-menu +++ diff --git a/lisp/ffap.el b/lisp/ffap.el index 3d7cebadcf..1df30e4516 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -292,6 +292,13 @@ dired-at-point-require-prefix :group 'ffap :version "20.3") +(defcustom ffap-file-name-max-length 1024 + "Maximum length allowed for file names in `ffap-file-at-point'." + :type '(choice (const :tag "Unlimited" nil) + (integer :tag "File Name Max Length" 1024)) + :group 'ffap + :version "26.1") + ;;; Compatibility: ;; @@ -1244,6 +1251,9 @@ ffap-file-at-point (abs (file-name-absolute-p name)) (default-directory default-directory) (oname name)) + ;; When oname is very large is likely not a file name. + (when (or (null ffap-file-name-max-length) + (< (length oname) ffap-file-name-max-length)) (unwind-protect (cond ;; Immediate rejects (/ and // and /* are too common in C/C++): @@ -1334,7 +1344,7 @@ ffap-file-at-point (and (not (string= dir "/")) (ffap-file-exists-string dir)))) ) - (set-match-data data)))) + (set-match-data data))))) ;;; Prompting (`ffap-read-file-or-url'): ;; -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.4) of 2016-12-21 Repository revision: 8661313efd5fd5b0a27fe82f276a1ff862646424