From: Stefan Monnier Date: Sat, 7 Oct 2006 15:57:36 +0000 (+0000) Subject: (add-completions-from-c-buffer): X-Git-Tag: emacs-pretest-22.0.90~202 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=612f91f027769219cc008abec1a8be3bb0c1b668;p=emacs.git (add-completions-from-c-buffer): Don't presume an error's second element is a string. Use looking-at rather than buffer-substring + member. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1360dc3617c..db715a29906 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2006-10-07 Stefan Monnier + + * completion.el (add-completions-from-c-buffer): + Don't presume an error's second element is a string. + Use looking-at rather than buffer-substring + member. + 2006-10-07 Eli Zaretskii * mail/rmail.el (rmail-redecode-body): If the old encoding is @@ -19,8 +25,8 @@ 2006-10-07 Johan Bockg,be(Brd - * mouse-sel.el (mouse-insert-selection-internal): Use - insert-for-yank, so that yank handlers are run. + * mouse-sel.el (mouse-insert-selection-internal): + Use insert-for-yank, so that yank handlers are run. 2006-10-07 Kim F. Storm diff --git a/lisp/completion.el b/lisp/completion.el index 64bf8026e9d..53dfd7521a5 100644 --- a/lisp/completion.el +++ b/lisp/completion.el @@ -1885,7 +1885,7 @@ Prefix args :: (save-excursion (goto-char (point-min)) (catch 'finish-add-completions - (with-syntax-table completion-c-def-syntax-table + (with-syntax-table completion-c-def-syntax-table (while t ;; we loop here only when scan-sexps fails ;; (i.e. unbalance exps.) @@ -1895,8 +1895,7 @@ Prefix args :: (cond ((= (preceding-char) ?#) ;; preprocessor macro, see if it's one we handle - (setq string (buffer-substring (point) (+ (point) 6))) - (cond ((member string '("define" "ifdef ")) + (cond ((looking-at "\\(define\\|ifdef\\)\\>") ;; skip forward over definition symbol ;; and add it to database (and (forward-word 2) @@ -1944,9 +1943,9 @@ Prefix args :: (throw 'finish-add-completions t)) (error ;; Check for failure in scan-sexps - (if (or (string-equal (nth 1 e) - "Containing expression ends prematurely") - (string-equal (nth 1 e) "Unbalanced parentheses")) + (if (member (nth 1 e) + '("Containing expression ends prematurely" + "Unbalanced parentheses")) ;; unbalanced paren., keep going ;;(ding) (forward-line 1)