From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#57673: [PATCH] Parse --help messages for pcomplete Date: Wed, 14 Sep 2022 16:40:43 -0400 Message-ID: References: <87zgfagqfs.fsf@gmail.com> <87sfl1leip.fsf@gmail.com> <87pmg3ef6j.fsf@gmail.com> <877d25day5.fsf@gmail.com> <87edwd3gpv.fsf@gnus.org> <8735ctd9qe.fsf@gmail.com> <87a6713ffm.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33750"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 57673@debbugs.gnu.org, Augusto Stoffel To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 14 22:42:50 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oYZDd-0008e9-Fq for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Sep 2022 22:42:49 +0200 Original-Received: from localhost ([::1]:48108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYZDc-0004KH-Fc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Sep 2022 16:42:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYZCs-0004K0-HZ for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2022 16:42:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYZCs-0000zf-9K for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2022 16:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oYZCs-00081w-0e for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2022 16:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Sep 2022 20:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57673 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57673-submit@debbugs.gnu.org id=B57673.166318806130741 (code B ref 57673); Wed, 14 Sep 2022 20:42:01 +0000 Original-Received: (at 57673) by debbugs.gnu.org; 14 Sep 2022 20:41:01 +0000 Original-Received: from localhost ([127.0.0.1]:56354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYZBt-0007zY-1q for submit@debbugs.gnu.org; Wed, 14 Sep 2022 16:41:01 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYZBn-0007z9-8G for 57673@debbugs.gnu.org; Wed, 14 Sep 2022 16:40:59 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A1C7D804BD; Wed, 14 Sep 2022 16:40:48 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 63AF580172; Wed, 14 Sep 2022 16:40:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663188046; bh=Cdx/sfe+HsKJ6V3vtQJfVz8bqsom5QtdOTO9UTsf9Yw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=K235YV9DmiDO+QCjdIiAlpnDf0cKFLneiXqgVQTHgmr6irYwut9ikHkk6iA09tgP+ dFRPzIJqCn4NxABtK8tz9O/vZbBMWDLE9q2TEsiu2Y+H1fMgPMZeDhwulTeVK6dpn6 3uomu0FVs2hx3COtLsQMIccQyPnsEB0qQ8XnRwdK0e+yrlgbzbR2/6d2cCgeRApJ/A PUcl6tRZiW+i4Wt3NeRduNURqspEI6BUvxKuCOvhiXNFsw8eOCwPwt8gnm7iTLemzx +TZhkki83RhHgBJRLvB7DdMvZvrd/2y1vZgwR1l6icwFzaTBxKvA7YDJ49w5Pn+792 CpAi6we1NZswA== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 105FD120388; Wed, 14 Sep 2022 16:40:46 -0400 (EDT) In-Reply-To: <87a6713ffm.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 14 Sep 2022 21:48:45 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242535 Archived-At: >> (pcomplete-from-help COMMAND &rest ARGS &key (MARGIN (rx bol (+ " "))) >> (ARGUMENT (rx "-" (+ (any "-" alnum)) (32 "="))) (METAVAR (rx (32 " ") >> (or (+ (any alnum "_-")) (seq "[" (+? nonl) "]") (seq "<" (+? nonl) >> ">") (seq "{" (+? nonl) "}")))) (SEPARATOR (rx ", " symbol-start)) >> (DESCRIPTION (rx (* nonl) (* "\n" (>= 9 " ") (* nonl)))) NARROW-START >> NARROW-END) >> >> But the information is good to have, because you need to know what these >> regexps are in order to use the function. > > Oh, yeah, that's pretty bad... we should probably fix that in the > cl-defun macro, I guess, so this doesn't have to be fixed in this patch. Side note: as a programmer, I don't really want to see this whole mess in `C-h o` either. Instead, I'd want the docstring to tell me what is the intended default value of those keywords (rather than what is the code used to build that default value). Tho to be perfectly honest, I think any keyword argument whose default value is not the same as nil is a problem (I know, sometimes there can be good reasons for that, but we should try to avoid them as much as possible). So rather than (cl-defun pcomplete-from-help (command &rest args &key (margin (rx bol (+ " "))) (argument (rx "-" (+ (any "-" alnum)) (? "="))) (metavar (rx (? " ") (or (+ (any alnum "_-")) (seq "[" (+? nonl) "]") (seq "<" (+? nonl) ">") (seq "{" (+? nonl) "}")))) (separator (rx ", " symbol-start)) (description (rx (* nonl) (* "\n" (>= 9 " ") (* nonl)))) narrow-start narrow-end) I'd rather see something like: (cl-defun pcomplete-from-help (command &rest args &key margin argument metavar separator description narrow-start narrow-end) (unless margin (setq margin (rx bol (+ " ")))) (unless argument (setq argument (rx "-" (+ (any "-" alnum)) (? "="))) (unless metavar (setq metavar (rx (? " ") (or (+ (any alnum "_-")) (seq "[" (+? nonl) "]") (seq "<" (+? nonl) ">") (seq "{" (+? nonl) "}")))) (unless separator (setq separator (rx ", " symbol-start)) (unless description (setq description (rx (* nonl) (* "\n" (>= 9 " ") (* nonl)))) [ which will probably not fix the overlong line problem, of course. ] Stefan