From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Francesco Potorti` Newsgroups: gmane.emacs.devel Subject: Re: etags.el tags-search use global syntax table Date: Tue, 17 Jul 2007 13:49:22 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1184673041 11047 80.91.229.12 (17 Jul 2007 11:50:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 17 Jul 2007 11:50:41 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 17 13:50:40 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IAlZZ-0004EQ-Tf for ged-emacs-devel@m.gmane.org; Tue, 17 Jul 2007 13:50:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IAlZZ-0003fP-E1 for ged-emacs-devel@m.gmane.org; Tue, 17 Jul 2007 07:50:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IAlZU-0003f3-QD for emacs-devel@gnu.org; Tue, 17 Jul 2007 07:50:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IAlZU-0003eL-5l for emacs-devel@gnu.org; Tue, 17 Jul 2007 07:50:28 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IAlZU-0003e3-1I for emacs-devel@gnu.org; Tue, 17 Jul 2007 07:50:28 -0400 Original-Received: from mx1.isti.cnr.it ([194.119.192.3]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IAlZT-0006vm-HT for emacs-devel@gnu.org; Tue, 17 Jul 2007 07:50:27 -0400 Original-Received: from conversionlocal.isti.cnr.it by mx.isti.cnr.it (PMDF V6.3 #31408) id <01MJ28FGUTC0A8D5IT@mx.isti.cnr.it> for emacs-devel@gnu.org; Tue, 17 Jul 2007 13:49:21 +0200 Original-Received: from tucano.isti.cnr.it (tucano.isti.cnr.it [146.48.81.102]) by mx.isti.cnr.it (PMDF V6.3 #31251) with ESMTPSA id <01MJ28FHCZ6GAAUSN9@mx.isti.cnr.it> for emacs-devel@gnu.org; Tue, 17 Jul 2007 13:49:22 +0200 Original-Received: from pot by tucano.isti.cnr.it with local (Exim 4.67) (envelope-from ) id 1IAlYQ-00069j-8f for emacs-devel@gnu.org; Tue, 17 Jul 2007 13:49:22 +0200 In-reply-to: "isaac.to@gmail.com"'s message of Wed, 27 Jun 2007 12:15:28 -0000 X-INSM-ip-source: 146.48.81.102 Auth Done X-fingerprint: 4B02 6187 5C03 D6B1 2E31 7666 09DF 2DC9 BE21 6115 Original-References: X-detected-kernel: OpenVMS 7.2 (Multinet 4.3-4.4 stack) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:74979 Archived-At: isaac.to@gmail.com: >When using AucTeX to edit some LaTeX files, I want to search for some >word globally. My version is not new enough to support inter-file >searching directly, so I've used tags-search. I'm searching for >something like "\bx\b". It turned out that some of the matches are >missed, because $ is considered as a word (as in the fundamental >mode). This is out of my expectation, since it is a LaTeX file and in >the LaTeX mode of AucTeX, $ is considered not a word. Perhaps when >Emacs performs a tags-search it do it in a temp buffer which does not >have the correct mode loaded? I consider this a bug in etags. This is indeed a bug in etags.el that was present in Emacs 21 and is still there in Emacs 22. It has nothing to do with Auctex, but pops up whenever: - you start a tags-search - the file where you should see a match is not currently visited - the search in Fundamental mode gives different results from the search in the proper mode of the buffer The reason is that the next-file function in etags.el loads non-visited files in a temporary buffer with insert-file-contents, rather than using find-file, so the mode remains Fundamental. I am not sure why it is so. These are the relevant lines at the end of next-file: ;; Like find-file, but avoids random warning messages. (set-buffer (get-buffer-create " *next-file*")) (kill-all-local-variables) (erase-buffer) (setq new next) (insert-file-contents new nil)) Generally speaking, tags-search looks for all files in the TAGS file: if they are visited, they are searched and when no match is found point is restored. If they are not visited, they are loaded into a temporary buffer which is overwritten when no matches are found. However, search in this buffer is performed in Fundamental mode. The cure is to use the syntax table relative to the natural mode of the file when doing the search. Is it really necessary to avoid using find-file? If yes, how can one guess the right syntax table and apply it to the temporary buffer?