From e298b5da3d0179d00e38d6baa8df515b160595ff Mon Sep 17 00:00:00 2001
From: Sam Steingold <sds@gnu.org>
Date: Wed, 21 Mar 2012 13:17:23 -0400
Subject: [PATCH] * lisp/progmodes/etags.el
 (tags-completion-at-point-function): Avoid the error when point is inside the
 pattern.

---
 lisp/ChangeLog          | 5 +++++
 lisp/progmodes/etags.el | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5a82dd4758d..801d0ac6a3c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-21  Sam Steingold  <sds@gnu.org>
+
+	* progmodes/etags.el (tags-completion-at-point-function):
+	Avoid the error when point is inside the pattern.
+
 2012-03-21  John Yates  <john@yates-sheets.org>  (tiny change)
 
 	* progmodes/hideshow.el (hs-inside-comment-p): Fix hiding of first
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index cc5f0fef934..3a36410884f 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -809,10 +809,10 @@ If no tags table is loaded, do nothing and return nil."
 	  beg)
       (when pattern
 	(save-excursion
-	  (search-backward pattern) ;FIXME: will fail if we're inside pattern.
-	  (setq beg (point))
-	  (forward-char (length pattern))
-	  (list beg (point) (tags-lazy-completion-table) :exclusive 'no))))))
+	  (when (search-backward pattern nil t) ; will fail inside pattern
+            (setq beg (point))
+            (forward-char (length pattern))
+            (list beg (point) (tags-lazy-completion-table) :exclusive 'no)))))))
 
 (defun find-tag-tag (string)
   "Read a tag name, with defaulting and completion."
-- 
2.39.5