changeset 80721:569276db9359

(sync from trunk 2008-01-25) Martin Rudalics <rudalics at gmx.at> (find-library): Wrap search for library name in condition-case to avoid reporting a scan-error. (Bug#563)
author Glenn Morris <rgm@gnu.org>
date Wed, 13 Aug 2008 03:07:25 +0000
parents 9cdccb5e49a8
children 57cdd719e459
files lisp/emacs-lisp/find-func.el
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/find-func.el	Tue Aug 12 22:23:30 2008 +0000
+++ b/lisp/emacs-lisp/find-func.el	Wed Aug 13 03:07:25 2008 +0000
@@ -198,11 +198,17 @@
    (let* ((path (cons (or find-function-source-path load-path)
 		      (find-library-suffixes)))
 	  (def (if (eq (function-called-at-point) 'require)
-		   (save-excursion
-		     (backward-up-list)
-		     (forward-char)
-		     (backward-sexp -2)
-		     (thing-at-point 'symbol))
+		   ;; `function-called-at-point' may return 'require
+		   ;; with `point' anywhere on this line.  So wrap the
+		   ;; `save-excursion' below in a `condition-case' to
+		   ;; avoid reporting a scan-error here.
+		   (condition-case nil
+		       (save-excursion
+			 (backward-up-list)
+			 (forward-char)
+			 (forward-sexp 2)
+			 (thing-at-point 'symbol))
+		     (error nil))
 		 (thing-at-point 'symbol))))
      (when def
        (setq def (and (locate-file-completion def path 'test) def)))