From: Mauro Aranda <maurooaranda@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: master fd92023: Make checkdoc work with qualified methods
Date: Fri, 05 Mar 2021 08:28:41 -0300 [thread overview]
Message-ID: <604215ec.1c69fb81.44011.3522@mx.google.com> (raw)
In-Reply-To: <jwva6rijyja.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Thu, 04 Mar 2021 18:23:22 -0500)
Hi Stefan,
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Make checkdoc work with qualified methods
>>
>> * lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): Handle
>> cl-defmethod in a case of its own. Check for the presence of
>> qualifiers, and skip them accordingly until the docstring.
>
> Any chance we could use the `doc-string-elt` property (which I just
> fixed for `cl-defmethod`) for `checkdoc--next-docstring`?
>
>
> Stefan
Something along these lines?
(defun checkdoc--next-docstring ()
"When looking at a definition with a doc string, find it.
Move to the next doc string after point, and return t. When not
looking at a definition containing a doc string, return nil and
don't move point."
(pcase (save-excursion (condition-case nil
(read (current-buffer))
;; Conservatively skip syntax errors.
(invalid-read-syntax)
;; Don't bug out if the file is empty (or a
;; definition ends prematurely.
(end-of-file)))
(`(,(and
(or 'defun 'defvar 'defcustom 'defmacro 'defconst 'defsubst
'defadvice 'cl-defun 'cl-defgeneric 'cl-defmacro 'cl-defmethod)
def)
,(pred symbolp)
;; Require an initializer, i.e. ignore single-argument `defvar'
;; forms, which never have a doc string.
,_ . ,_)
(down-list)
;; Skip over function or macro name.
(forward-sexp 1)
;; And now skip until the docstring.
(forward-sexp (1- ; We already skipped the function or macro name.
(pcase (function-get def 'doc-string-elt)
((and (pred numberp) num) num)
((and (pred functionp) fn) (funcall fn)))))
(skip-chars-forward " \n\t")
t)))
Note that I need to do (forward-sexp 1) so the requirements of
cl--defmethod-doc-pos are fulfilled. It may get messy if other defining
forms declare a doc-string-elt function that assumes a different point
position.
BTW, I've noticed that I forgot to add the Bug tag to my commit, I'm
sorry. This commit was part of Bug#46918.
next prev parent reply other threads:[~2021-03-05 11:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210304203118.27982.28704@vcs0.savannah.gnu.org>
[not found] ` <20210304203120.17C8C20E1B@vcs0.savannah.gnu.org>
2021-03-04 23:23 ` master fd92023: Make checkdoc work with qualified methods Stefan Monnier
2021-03-05 11:28 ` Mauro Aranda [this message]
2021-03-05 15:21 ` Stefan Monnier
2021-03-05 20:55 ` Mauro Aranda
2021-03-06 1:03 ` Stefan Monnier
2021-03-08 11:15 ` Mauro Aranda
2021-03-08 15:29 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=604215ec.1c69fb81.44011.3522@mx.google.com \
--to=maurooaranda@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.