From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.devel Subject: Re: master fd92023: Make checkdoc work with qualified methods Date: Fri, 05 Mar 2021 08:28:41 -0300 Message-ID: <604215ec.1c69fb81.44011.3522@mx.google.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 05 12:30:11 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lI8ep-0006qc-Mg for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Mar 2021 12:30:11 +0100 Original-Received: from localhost ([::1]:39640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lI8eo-0001Lb-NG for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Mar 2021 06:30:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lI8dV-0000Tv-9O for emacs-devel@gnu.org; Fri, 05 Mar 2021 06:28:49 -0500 Original-Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:35257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lI8dT-0007Sa-8l for emacs-devel@gnu.org; Fri, 05 Mar 2021 06:28:49 -0500 Original-Received: by mail-qk1-x736.google.com with SMTP id d20so1580134qkc.2 for ; Fri, 05 Mar 2021 03:28:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=3Jy2PG8O/2AcBK8Jo0ZyTwqJH3496WfbeieVVY7ll3w=; b=rusbBjBXODvm8gqyLiwRNsevJFm1Fu+VRkDOGleoN0drPEDxvaCCHkVZWE+OqRgp8L f8v/RKQWyYjfdxeB4opBaXYRF7B+iizKNKd+PA3ZhN+1KVgsPr86aHITSGSQsQjjBzS5 frcBn8iYJRLPYkYUEUt3D5bt8IlTbWN2f7Dm3QtzjeRNFqCDd7TfPeZ0Fcaj4PMwol7T I/gqDEq8r/PneDLNC7vU3rB7ZaJ0hoc92GnMSN8Syd0XVJur9Qt0LLJZzT929FosncY6 g3wOje2RC4ZmFCdmi5Y6g51PxdVFI/eVUeCzR1U6IFYVVtCYgmqsn9LQl378xAaIpYtd yWMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=3Jy2PG8O/2AcBK8Jo0ZyTwqJH3496WfbeieVVY7ll3w=; b=BvEnuiErAD6bvmMQW3JJ2d4CwXM/Oi5WqNtr5XtlZBfPjeSitFECjvR9i4AMVRa37I RbspjfxH4hhEC8c0zIol5GuRLsEqHfziG762VcCgYN1dkfOLE7MBdVYCf+p+Tz1nI6Pk MybaVUGPBN1E6D/vF58+a+eWrKa2kG4MmxLUN6P1hP1/hlrsTeGnO+L8BT1rnlAYm12q sFPJMhReNACqzeLiXBH98+/3mGY6v5GhxsOZER+ntBQNLMrbAFvF6CJiWntfoqZbEhRM 3xSWrBZNL/I0FcTuy1fhfqlDGfREO8NDkYnHVIIYz4wlBEtCXOab22phumRfD3i4zR0C Axrg== X-Gm-Message-State: AOAM531gdSIlU8AQ3Tb5rm7ZCeZSwKtlXrtI4hAn9MEYdrmXJykQwdzR FNAmG7EqtPT15iKdzdfIZusKsVAM6EY0YREQ X-Google-Smtp-Source: ABdhPJzRXA451mNEPnZoqDwDVBDQYkFiqYihHgKB6xh+bvMeGDbdSX7KuIzXtM6XKqy3+D3nrQmvjg== X-Received: by 2002:a37:58c5:: with SMTP id m188mr627548qkb.327.1614943725454; Fri, 05 Mar 2021 03:28:45 -0800 (PST) Original-Received: from tbb-desktop ([201.213.132.172]) by smtp.gmail.com with ESMTPSA id m6sm651286qtx.3.2021.03.05.03.28.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Mar 2021 03:28:44 -0800 (PST) X-Google-Original-Message-ID: <87pn0dj0uu.fsf@maurooaranda@gmail.com> In-Reply-To: (message from Stefan Monnier on Thu, 04 Mar 2021 18:23:22 -0500) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=maurooaranda@gmail.com; helo=mail-qk1-x736.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266016 Archived-At: Hi Stefan, Stefan Monnier 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.