From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] New package: hcel Date: Wed, 21 Sep 2022 08:03:15 -0400 Message-ID: References: <87pmg346k0.fsf@ypei.org> <87leqds10z.fsf@ypei.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36148"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Emacs Devel mailing list To: Yuchen Pei Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 21 14:10:28 2022 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 1oayYe-0009J4-1u for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Sep 2022 14:10:28 +0200 Original-Received: from localhost ([::1]:43296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oayYc-0007QG-U1 for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Sep 2022 08:10:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oayRt-000353-KY for emacs-devel@gnu.org; Wed, 21 Sep 2022 08:03:30 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oayRo-0004rR-3V for emacs-devel@gnu.org; Wed, 21 Sep 2022 08:03:28 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8E386100169; Wed, 21 Sep 2022 08:03:22 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 9AE4C10000A; Wed, 21 Sep 2022 08:03:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663761796; bh=461BF1QtM/Pwj35bK7F2Y3lV0z8UhVou19T8FbiWyX4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YlWGPt7tb154gRe7jPtvrN6xa4gISADn43J1AA+B2TKHaI91ea7iElfxybmdUf77I SRhvkl3EZl6DrCu5McCXNO2FIjZe7TLqKE6rEWVsDvjvmRc3nTg3UOJdymt8cNNtCb LEjWNZ0Jyek7y+20XZ6IFhvm/K4gSs4QHAKD4/CGsMGtkPwojnUz1hRhEjy42OjroS ytT+WOSg0VJ6p3si8DHIunoIbVn63JIn3vCgRxeEBkN29kHXdYtPnZwxLd0ZrcyKES YcYrmZql4PoIbzg2DcLjl/UrPwdsHUI6FCf2PLqYkRadfLjOSLdSmnNzdEm86WRD6P s5sMcsORmHgwg== Original-Received: from pastel (unknown [157.52.9.190]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6A91212053B; Wed, 21 Sep 2022 08:03:16 -0400 (EDT) In-Reply-To: <87leqds10z.fsf@ypei.org> (Yuchen Pei's message of "Wed, 21 Sep 2022 16:18:52 +1000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 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:295899 Archived-At: >> Given the fact that this tool has a fairly narrow focus, I must admit >> that I'd prefer it doesn't eat up a two-letter file name like `hc`. >> Any chance you can rename that main file to `hcel.el`? > > I applied your patch that does so. Perfect, thanks. >> Also, I see that your package has: >> >> ;; Package-Requires: ((emacs "28") (haskell-mode)) >> >> but `haskell-mode` is currently neither in GNU ELPA nor in NonGNU ELPA >> so we can't include it in neither of them. Is the dependency >> unavoidable (so we should first include `haskell-mode` in (Non)GNU >> ELPA), or can it be removed (and replaced with a runtime test, possibly >> allowing the use of other haskell modes such as haskell-tng-mode, which >> *is* in NonGNU ELPA)? > > It seems to me haskell-mode is in NonGNU ELPA[3]? Oh, right, sorry. It's currently not being tracked (see https://github.com/haskell/haskell-mode/issues/1755), but it's still in NonGNU ELPA, yes. Sorry 'bout the noise, the dependency on `haskell-mode` is fine. >> (defun hcel-results-next-page () >> (interactive) >> + ;; FIXME: Using `major-mode' is a code smell. >> (unless (memq major-mode '(hcel-refs-mode hcel-ids-mode)) >> (error "Not in hcel-refs or hcel-ids mode: %S" major-mode)) > > What do you mean, should I avoid using the variable `major-mode'? Why? Experience over the years taught me that. It's a bit like explicit type tests in OO languages, I think. Stefan Kangas's suggestion to use `derived-mode-p` is a bit better, but it's still not great. It's often better to "do something else". Depending on the situation the "something else" can be quite varied, but one common option is to have the major mode set a buffer-local variable that gives the needed info. >> In end of data: >> packages/hcel/hcel-client.el:142:8: Warning: the function >> =E2=80=98delete-http-header=E2=80=99 is not known to be defined. >> packages/hcel/hcel-client.el:59:19: Warning: the function >> =E2=80=98hcel-location-tag=E2=80=99 is not known to be defined. >> packages/hcel/hcel-client.el:47:43: Warning: the function >> =E2=80=98hcel-format-package-id=E2=80=99 is not known to be defined. >> Byte compiling packages/hcel/hcel-results.el > > How do I get these "end of data" warnings? When I do M-x byte-compile > or byte-recompile-directory I don't get them. When you `M-x byte-compile`, the compilation is done in the running Emacs, which already has lot of packages loaded an thus won't be able to notice if your code relies on those packages without making sure they'll be loaded before using them. The above warnings come from a "clean compilation" where every file is compiled in a separate dedicated Emacs session. >> In hcel-module-selector: >> packages/hcel/hcel.el:55:43: Warning: reference to free variable >> =E2=80=98package-id=E2=80=99 > I thought this was OK because of lexical-binding? For reference, here's > the defun: As Micheal points out, this is Bug#51695 :-( And indeed there is no nice solution for it currently. In Emacs-29, there is a (cumbersome) solution which involves the use of an OClosure. I'm hoping to find the time before Emacs-29.1 to write the code so the bytecompiler can use the OClosure behind the scenes for you. Stefan