diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index f5c3dc3fbb2..1bc270f1cf0 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -2443,32 +2443,36 @@ ARGS is the argument list of function SYM." start (match-beginning 0) end (match-end 0))))))) ;; Handle now positional arguments. - (while (and index (>= index 1)) - (if (string-match "[^ ()]+" args end) - (progn - (setq start (match-beginning 0) - end (match-end 0)) - (let ((argument (match-string 0 args))) - (cond ((string= argument "&rest") - ;; All the rest arguments are the same. - (setq index 1)) - ((string= argument "&optional")) ; Skip. - ((string= argument "&allow-other-keys")) ; Skip. - ;; Back to index 0 in ARG1 ARG2 ARG2 ARG3 etc... - ;; like in `setq'. - ((or (and (string-match-p "\\.\\.\\.\\'" argument) - (string= argument (car (last args-lst)))) - (and (string-match-p "\\.\\.\\.\\'" - (substring args 1 (1- (length args)))) - (= (length (remove "..." args-lst)) 2) - (> index 1) (oddp index))) - (setq index 0)) - (t - (setq index (1- index)))))) - (setq end (length args) - start (1- end) - argument-face 'font-lock-warning-face - index 0))) + (with-temp-buffer + (insert args) + (goto-char (1+ (point-min))) + (while (and index (>= index 1)) + (let ((origin (point))) + (if (string-match "[^ ()]+" args end) + (progn + (setq start (match-beginning 0) + end (match-end 0)) + (let ((argument (match-string 0 args))) + (cond ((string= argument "&rest") + ;; All the rest arguments are the same. + (setq index 1)) + ((string= argument "&optional")) ; Skip. + ((string= argument "&allow-other-keys")) ; Skip. + ;; Back to index 0 in ARG1 ARG2 ARG2 ARG3 etc... + ;; like in `setq'. + ((or (and (string-match-p "\\.\\.\\.\\'" argument) + (string= argument (car (last args-lst)))) + (and (string-match-p "\\.\\.\\.\\'" + (substring args 1 (1- (length args)))) + (= (length (remove "..." args-lst)) 2) + (> index 1) (oddp index))) + (setq index 0)) + (t + (setq index (1- index)))))) + (setq end (length args) + start (1- end) + argument-face 'font-lock-warning-face + index 0))))) (let ((doc args)) (when start (setq doc (copy-sequence args))