- (if (symbolp rule)
- (setq result (funcall rule))
- (if (consp rule)
- (setq regexp (car rule)
- subexp (cdr rule))
- (setq regexp rule
- subexp 0))
- (skip-chars-backward " \t\n") (setq end (point))
- (while (and (re-search-backward regexp nil t)
- (looking-at regexp)
- (>= (match-end 0) end))
- (setq result (match-string subexp)))
- (if (not result)
- (progn
- (goto-char start)
- (skip-chars-forward " \t\n")
- (and (looking-at regexp)
- (setq result (match-string subexp))))))
+ (save-excursion
+ (if (symbolp rule)
+ (setq result (funcall rule))
+ (if (consp rule)
+ (setq regexp (car rule)
+ subexp (cdr rule))
+ (setq regexp rule
+ subexp 0))
+ ;; If at start of symbol, don't go back to end of previous one.
+ (if (save-match-data
+ (looking-at "[ \t\n]"))
+ (skip-chars-backward " \t\n"))
+ (setq end (point))
+ (while (and (re-search-backward regexp nil t)
+ (looking-at regexp)
+ (>= (match-end 0) end))
+ (setq result (match-string subexp)))
+ (if (not result)
+ (progn
+ (goto-char start)
+ (skip-chars-forward " \t\n")
+ (and (looking-at regexp)
+ (setq result (match-string subexp)))))))