From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#20629: 25.0.50; Regression: TAGS broken, can't find anything in C++ files. Date: Thu, 28 May 2015 15:59:20 +0300 Message-ID: <55671128.3080607@yandex.ru> References: <555EC552.5010600@swipnet.se> <55606A8F.1020109@swipnet.se> <55606CC7.3010401@yandex.ru> <55606F70.10605@swipnet.se> <83twv31jzg.fsf@gnu.org> <83pp5r1hdx.fsf@gnu.org> <83mw0v1e5n.fsf@gnu.org> <83lhgczo16.fsf@gnu.org> <55639175.9090005@yandex.ru> <83fv6kysjf.fsf@gnu.org> <556447EF.3050103@yandex.ru> <83bnh7z8c5.fsf@gnu.org> <5564C2C7.5050909@yandex.ru> <837frvywfn.fsf@gnu.org> <55670209.9080608@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1432818038 30623 80.91.229.3 (28 May 2015 13:00:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 May 2015 13:00:38 +0000 (UTC) Cc: 20629@debbugs.gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 28 15:00:28 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YxxQ9-0002g6-Aj for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 May 2015 15:00:25 +0200 Original-Received: from localhost ([::1]:58862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxxQ8-0000g7-It for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 May 2015 09:00:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxxPy-0000X2-NF for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 09:00:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxxPq-0002i1-S3 for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 09:00:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxxPq-0002hP-PU for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 09:00:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YxxPp-0004Dj-J0 for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 09:00:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 May 2015 13:00:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20629 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20629-submit@debbugs.gnu.org id=B20629.143281797116155 (code B ref 20629); Thu, 28 May 2015 13:00:04 +0000 Original-Received: (at 20629) by debbugs.gnu.org; 28 May 2015 12:59:31 +0000 Original-Received: from localhost ([127.0.0.1]:59083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YxxPH-0004CV-2X for submit@debbugs.gnu.org; Thu, 28 May 2015 08:59:31 -0400 Original-Received: from mail-wi0-f169.google.com ([209.85.212.169]:33762) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YxxPD-0004CH-UY for 20629@debbugs.gnu.org; Thu, 28 May 2015 08:59:28 -0400 Original-Received: by wicmx19 with SMTP id mx19so122771939wic.0 for <20629@debbugs.gnu.org>; Thu, 28 May 2015 05:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=oC9VE5TYQ3tVChQ094KYXAV2vNAMKDroaYTgDbJKJtM=; b=TQOOihqlpoTKod7kzTpOpTDpyLVKM0D+vp/1It5osgNjn4tQAJKRMX73jvci4AHK+1 aQuSDGJZiQE4Vvikzg3c/KZ5OUz/sQePk0uQscpSxKMjrlParEAZ921dbXY6GSLKXXEZ VPJ681FiLKSLQCrulx2renlnc7b+v0hocucdF34hDvib/lG1cJMUA9L0aZRDDTBjHRMB ELZmGQ6hWDliDjSpUWOJwYLzkpgONXJmIoJcr4W6KsMiXfsnuD4IrJrxLFKzvgUc4W6E 8mmhiWv5PIwItct7PdF//unkF4W8Vl20TGdlmYHvEh+/QAPnRLqi8QbY9JVjZIsIX9IE Iutw== X-Received: by 10.180.82.6 with SMTP id e6mr61649784wiy.84.1432817962203; Thu, 28 May 2015 05:59:22 -0700 (PDT) Original-Received: from [192.168.0.185] (static-nbl2-118.cytanet.com.cy. [212.31.107.118]) by mx.google.com with ESMTPSA id bh7sm3275055wjb.8.2015.05.28.05.59.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 05:59:22 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0 In-Reply-To: <55670209.9080608@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103258 Archived-At: And here's an attempt to simplify the regexp and use the input string. It brings us down to 200ms in the best case (completions for "get_"), and that can be improved further, but the worst case (completions for "") gets considerably worse: 3 seconds. diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 9ff164e..230fffa 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -753,31 +753,18 @@ Assumes the tags table is the current buffer." (setq tags-included-tables (funcall tags-included-tables-function)))) (defun tags-completion-table () - "Build `tags-completion-table' on demand. + "Return tags completion table. The tags included in the completion table are those in the current tags table and its (recursively) included tags tables." - (or tags-completion-table - ;; No cached value for this buffer. - (condition-case () - (let (current-table combined-table) - (message "Making tags completion table for %s..." buffer-file-name) - (save-excursion - ;; Iterate over the current list of tags tables. - (while (visit-tags-table-buffer (and combined-table t)) - ;; Find possible completions in this table. - (setq current-table (funcall tags-completion-table-function)) - ;; Merge this buffer's completions into the combined table. - (if combined-table - (mapatoms - (lambda (sym) (intern (symbol-name sym) combined-table)) - current-table) - (setq combined-table current-table)))) - (message "Making tags completion table for %s...done" - buffer-file-name) - ;; Cache the result in a buffer-local variable. - (setq tags-completion-table combined-table)) - (quit (message "Tags completion table construction aborted.") - (setq tags-completion-table nil))))) + (completion-table-with-cache + (lambda (string) + (let (cont tables) + (save-excursion + ;; Iterate over the current list of tags tables. + (while (visit-tags-table-buffer (or cont (progn (setq cont t) nil))) + ;; Find possible completions in this table. + (push (funcall tags-completion-table-function string) tables))) + (nreverse (apply #'nconc tables)))))) ;;;###autoload (defun tags-lazy-completion-table () @@ -1218,7 +1205,7 @@ buffer-local values of tags table format variables." (mapc (lambda (elt) (set (make-local-variable (car elt)) (cdr elt))) '((file-of-tag-function . etags-file-of-tag) (tags-table-files-function . etags-tags-table-files) - (tags-completion-table-function . etags-tags-completion-table) + (tags-completion-table-function . etags-tags-completions) (snarf-tag-function . etags-snarf-tag) (goto-tag-location-function . etags-goto-tag-location) (find-tag-regexp-search-function . re-search-forward) @@ -1255,12 +1242,9 @@ buffer-local values of tags table format variables." (expand-file-name str (file-truename default-directory)))))) -(defun etags-tags-completion-table () ; Doc string? - (let ((table (make-vector 511 0)) - (progress-reporter - (make-progress-reporter - (format "Making tags completion table for %s..." buffer-file-name) - (point-min) (point-max)))) +(defun etags-tags-completions (string) ; Doc string? + (let ((table nil) + (re (format "[\n \t()=,;\177]%s" (regexp-quote string)))) (save-excursion (goto-char (point-min)) ;; This monster regexp matches an etags tag line. @@ -1271,18 +1255,16 @@ buffer-local values of tags table format variables." ;; \5 is the explicitly-specified tag name. ;; \6 is the line to start searching at; ;; \7 is the char to start searching at. - (while (re-search-forward - "^\\(\\([^\177]+[^-a-zA-Z0-9_+*$:\177]+\\)?\ -\\([-a-zA-Z0-9_+*$?:]+\\)[^-a-zA-Z0-9_+*$?:\177]*\\)\177\ -\\(\\([^\n\001]+\\)\001\\)?\\([0-9]+\\)?,\\([0-9]+\\)?\n" - nil t) - (intern (prog1 (if (match-beginning 5) - ;; There is an explicit tag name. - (buffer-substring (match-beginning 5) (match-end 5)) - ;; No explicit tag name. Best guess. - (buffer-substring (match-beginning 3) (match-end 3))) - (progress-reporter-update progress-reporter (point))) - table))) + (while (re-search-forward re nil t) + (save-excursion + (goto-char (match-beginning 0)) + (let ((match-re (if (eq (char-after) ?\177) + ;; Explicit tag name. + "\177\\([^\001]+\\)\001" + ;; Implicit tag name. + "[\n \t()=,;]\\([^\177 \t()=,;]+\\)\177"))) + (when (looking-at match-re) + (push (match-string 1) table)))))) table)) (defun etags-snarf-tag (&optional use-explicit) ; Doc string?