From 6aab5f13cdb9305efb3290b9abe02fe89276d48d Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Fri, 7 May 2004 22:41:22 +0000 Subject: [PATCH] (help-do-arg-highlight): Temporarily set ?\- to be a word constituent so FOO-ARG is not recognized as an arg. (help-highlight-arguments): Don't skip lists in mandatory arguments. --- lisp/help-fns.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index a94c0ed9dea..f19bdbf1c35 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -241,28 +241,32 @@ KIND should be `var' for a variable or `subr' for a subroutine." "Face to highlight function arguments in docstrings.") (defun help-do-arg-highlight (doc args) - (while args - (let ((arg (prog1 (car args) (setq args (cdr args))))) - (setq doc (replace-regexp-in-string - (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>") - (propertize arg 'face 'help-argument-name) - doc t t 1)))) - doc) + (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table) + (modify-syntax-entry ?\- "w") + (while args + (let ((arg (prog1 (car args) (setq args (cdr args))))) + (setq doc (replace-regexp-in-string + (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>") + (propertize arg 'face 'help-argument-name) + doc t t 1)))) + doc)) (defun help-highlight-arguments (usage doc &rest args) (when usage (let ((case-fold-search nil) - (next (not args))) + (next (not args)) + (opt nil)) ;; Make a list of all arguments (with-temp-buffer (insert usage) (goto-char (point-min)) ;; Make a list of all arguments (while next + (or opt (not (looking-at " &")) (setq opt t)) (if (not (re-search-forward " \\([\\[(]?\\)\\([^] &)\.]+\\)" nil t)) (setq next nil) (setq args (cons (match-string 2) args)) - (when (string= (match-string 1) "(") + (when (and opt (string= (match-string 1) "(")) ;; A pesky CL-style optional argument with default value, ;; so let's skip over it (search-backward "(") -- 2.39.2