From: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel@gnu.org, "Kim F. Storm" <storm@cua.dk>
Subject: Re: Tiny change to find-tag-default.
Date: Sat, 22 Jul 2006 14:17:55 +0200 [thread overview]
Message-ID: <44C21773.20709@gmx.at> (raw)
In-Reply-To: <E1G49Gq-0005H1-UK@fencepost.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
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.
[-- Attachment #2: subr.patch --]
[-- Type: text/plain, Size: 1924 bytes --]
*** 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...)'.
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2006-07-22 12:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-21 9:53 Tiny change to find-tag-default Kim F. Storm
2006-07-21 14:18 ` Drew Adams
2006-07-21 22:21 ` Kim F. Storm
2006-07-21 23:15 ` Drew Adams
2006-07-22 4:39 ` Richard Stallman
2006-07-22 12:17 ` martin rudalics [this message]
2006-07-23 17:34 ` Richard Stallman
2006-07-28 23:06 ` Kim F. Storm
2006-07-28 0:09 ` Kim F. Storm
2006-07-28 9:12 ` martin rudalics
2006-07-28 23:04 ` Kim F. Storm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44C21773.20709@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=storm@cua.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).