Skip to content

Commit

Permalink
* lisp/emacs-lisp/cl-generic.el: Make doc-string prop work with qua…
Browse files Browse the repository at this point in the history
…lifiers

(cl--defmethod-doc-pos): New function.
(cl-defmethod): Use it.
  • Loading branch information
monnier committed Mar 4, 2021
1 parent 0981712 commit 27428d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lisp/emacs-lisp/cl-generic.el
Expand Up @@ -425,6 +425,16 @@ the specializer used will be the one returned by BODY."
(defun cl-generic--method-qualifier-p (x)
(not (listp x)))

(defun cl--defmethod-doc-pos ()
"Return the index of the docstring for a `cl-defmethod'.
Presumes point is at the end of the `cl-defmethod' symbol."
(save-excursion
(let ((n 2))
(while (and (ignore-errors (forward-sexp 1) t)
(not (eq (char-before) ?\))))
(cl-incf n))
n)))

;;;###autoload
(defmacro cl-defmethod (name args &rest body)
"Define a new method for generic function NAME.
Expand Down Expand Up @@ -464,7 +474,7 @@ The set of acceptable TYPEs (also called \"specializers\") is defined
\(and can be extended) by the various methods of `cl-generic-generalizers'.
\(fn NAME [QUALIFIER] ARGS &rest [DOCSTRING] BODY)"
(declare (doc-string 3) (indent defun)
(declare (doc-string cl--defmethod-doc-pos) (indent defun)
(debug
(&define ; this means we are defining something
[&name [sexp ;Allow (setf ...) additionally to symbols.
Expand Down

0 comments on commit 27428d2

Please sign in to comment.