From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Tiny change to find-tag-default. Date: Fri, 28 Jul 2006 02:09:31 +0200 Message-ID: References: <44C21773.20709@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1154045496 11844 80.91.229.2 (28 Jul 2006 00:11:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 Jul 2006 00:11:36 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 28 02:11:33 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G6Fwr-0005gs-En for ged-emacs-devel@m.gmane.org; Fri, 28 Jul 2006 02:11:26 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6Fwq-0000zU-Jr for ged-emacs-devel@m.gmane.org; Thu, 27 Jul 2006 20:11:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G6Fwe-0000zH-De for emacs-devel@gnu.org; Thu, 27 Jul 2006 20:11:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G6Fwd-0000yx-I3 for emacs-devel@gnu.org; Thu, 27 Jul 2006 20:11:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6Fwd-0000yu-DM for emacs-devel@gnu.org; Thu, 27 Jul 2006 20:11:11 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G6FyT-0006kz-Dt; Thu, 27 Jul 2006 20:13:05 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id 9411F8A001F; Fri, 28 Jul 2006 02:11:07 +0200 (CEST) Original-To: martin rudalics In-Reply-To: <44C21773.20709@gmx.at> (martin rudalics's message of "Sat, 22 Jul 2006 14:17:55 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:57706 Archived-At: martin rudalics writes: > Wouldn't it make sense to rewrite the rest of `find-tag-default' too? > In its current version it unnecessarily clobbers `match-data', requires > a `condition-case' to handle errors in `forward-sexp', and has other > tedious things like repeated forward-charing and re-searching. > > I'm using the attached version for approximately half a year and didn't > encounter any problems so far. Your code works fine for me too. But I'm puzzled by the use of (forward-sexp -1) in the old code. What subtle effect did the author intend by using that? Maybe to get to the function name in a function call? ... if that was the intention, it doesn't seem to work. > > *** subr.el Tue Jun 6 19:20:26 2006 > --- subr.el Mon Jul 10 11:42:40 2006 > *************** > *** 1949,1973 **** > "Determine default tag to search for, based on text at point. > If there is no plausible default, return nil." > (save-excursion > ! (while (looking-at "\\sw\\|\\s_") > ! (forward-char 1)) > ! (if (or (re-search-backward "\\sw\\|\\s_" > ! (save-excursion (beginning-of-line) (point)) > ! t) > ! (re-search-forward "\\(\\sw\\|\\s_\\)+" > ! (save-excursion (end-of-line) (point)) > ! t)) > ! (progn > ! (goto-char (match-end 0)) > ! (condition-case nil > ! (buffer-substring-no-properties > ! (point) > ! (progn (forward-sexp -1) > ! (while (looking-at "\\s'") > ! (forward-char 1)) > ! (point))) > ! (error nil))) > ! nil))) > > (defun play-sound (sound) > "SOUND is a list of the form `(sound KEYWORD VALUE...)'. > --- 1949,1973 ---- > "Determine default tag to search for, based on text at point. > If there is no plausible default, return nil." > (save-excursion > ! (let (from to bound) > ! (when (or (and (save-excursion > ! (skip-syntax-backward "w_") (setq from (point))) > ! (save-excursion > ! (skip-syntax-forward "w_") (setq to (point))) > ! (> to from)) > ! ;; Look between `line-beginning-position' and `point'. > ! (and (setq bound (line-beginning-position)) > ! (skip-syntax-backward "^w_" bound) > ! (> (setq to (point)) bound) > ! (skip-syntax-backward "w_") > ! (setq from (point))) > ! ;; Look between `point' and `line-end-position'. > ! (and (setq bound (line-end-position)) > ! (skip-syntax-forward "^w_" bound) > ! (< (setq from (point)) bound) > ! (skip-syntax-forward "w_") > ! (setq to (point)))) > ! (buffer-substring-no-properties from to))))) > > (defun play-sound (sound) > "SOUND is a list of the form `(sound KEYWORD VALUE...)'. -- Kim F. Storm http://www.cua.dk