--- font-latex.el 18 Mar 2005 14:48:25 -0000 5.100 +++ font-latex.el 27 Mar 2005 10:10:58 -0000 @@ -1210,7 +1227,8 @@ (skip-chars-forward " \n\t" limit) (setq kend (point)) ;; Optional arguments [...] - (while (eq (following-char) ?\[) + (while (and (< (point) limit) + (eq (following-char) ?\[)) (setq sbeg kend) (save-restriction ;; Restrict to LIMIT. @@ -1221,18 +1239,27 @@ (setq send (point-max)) (goto-char send)))) ;; Mandatory arguments {...} - (dotimes (i arg-count) - (skip-chars-forward " \n\t" limit) - (when (eq (following-char) ?\{) - (when (= i 0) (setq cbeg (point))) - (save-restriction - ;; Restrict to LIMIT. - (narrow-to-region (point-min) limit) - (if (font-latex-find-matching-close ?\{ ?\}) - (setq cend (point)) - (setq cache-reset t) - (setq cend (point-max)) - (goto-char cend))))) + (condition-case nil + (dotimes (i arg-count) + (skip-chars-forward " \n\t" limit) + (if (and (< (point) limit) + (eq (following-char) ?\{)) + (progn + (when (= i 0) (setq cbeg (point))) + (save-restriction + ;; Restrict to LIMIT. + (narrow-to-region (point-min) limit) + (if (font-latex-find-matching-close ?\{ ?\}) + (setq cend (point)) + (setq cache-reset t) +;; (goto-char (point-max)) + (error "No mandatory argument found")))) + (error "No mandatory argument found"))) + ;; In case no mandatory argument could be found, set the match + ;; data to dummy values. We have to return t nevertheless in + ;; order to tell font lock that there might still be other + ;; macros to be found. + (error (setq kend kbeg sbeg kbeg send kbeg cbeg kbeg cend kbeg))) (store-match-data (list kbeg kend sbeg send cbeg cend)) ;; Handle cache