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#74040: `require-with-check` signals error for `project` Date: Sun, 27 Oct 2024 12:43:27 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9897"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 74040@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 27 17:44:57 2024 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 1t56Ns-0002Rj-JV for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Oct 2024 17:44:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t56NV-00028i-DM; Sun, 27 Oct 2024 12:44:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t56NQ-00028P-3s for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 12:44:28 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t56NP-0007qK-Rq for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 12:44:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=PoAAnA2xKZZ65Lpg8fJ3m6EnrfdPaGODSNPjNkhq3fs=; b=j9Q9/gKS5GkeJKGuckHGfcD7vu7cwA9nKFz1p4zqL+9nSIHWqQPQT0q0a9O15Dqx/3EGBOCNDVjb6/HCbELG6zRRIIWCtjV7zLehGOiHXll+sc14ukzQTzj5YFI+2yuye8HVgemihm33LCoM5bTlAFb/uFe7qMSGPNG1gzqdfzH6svkko11mcBagay/8aWjDTX2HVG5QQLQfKXC2fYfjorjqqhJwGJlAgv7SZKsxKYRoV/oDI2KX0lGKhu71S5uz3k0qqQGBeBawtf4D7IKfp2ncN+mGMTSP4ESzlxLRjYoLIcuAVtp4VTvj65RJQh+LvgEsuhjlswWRuWH4oSRxSw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t56Nx-0007Hr-No for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 12:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Oct 2024 16:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74040 X-GNU-PR-Package: emacs Original-Received: via spool by 74040-submit@debbugs.gnu.org id=B74040.173004745327934 (code B ref 74040); Sun, 27 Oct 2024 16:45:01 +0000 Original-Received: (at 74040) by debbugs.gnu.org; 27 Oct 2024 16:44:13 +0000 Original-Received: from localhost ([127.0.0.1]:46025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t56NB-0007GT-4A for submit@debbugs.gnu.org; Sun, 27 Oct 2024 12:44:13 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t56N8-0007GB-DR for 74040@debbugs.gnu.org; Sun, 27 Oct 2024 12:44:11 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4DB7C100180; Sun, 27 Oct 2024 12:43:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1730047408; bh=O7IjcLO0If/R6IVT2YqwarJfseGTOurf2nvs9rXxJXw=; h=From:To:Subject:In-Reply-To:References:Date:From; b=hexA5HFudh0mJdaQZGBOBp1yi7BIikYGhVJ1MPh3Y7tfD/pvYO6EHK5IcOxBlwERQ wYPG60e4j20sK05gVjP1AtLhwCF27dXXH0tvFKvaL4zZfEqbGXST7jo2Ojm0mPibVu w1OPEuoVP07I3eN/gqf4uumw+hDLWXhUz5ax5i8DEGGoRQDLIuXQnWoJJ+TIaL1/Bl Swd+fdXfNgatUcv8Khrfi93NrriczBQCd4bLkerAtD1iikt3TDIFqjeaiqMGDeoN7h 77SSCJn6t+Jy6WOyH7wF72fqBrA3KiatMArus0GFeBCT8K9pIHh4AywMxX8qu35/wh IujcxtnvI/8wA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7FCB810002E; Sun, 27 Oct 2024 12:43:28 -0400 (EDT) Original-Received: from pastel (69-196-161-60.dsl.teksavvy.com [69.196.161.60]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 606E712005D; Sun, 27 Oct 2024 12:43:28 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Sun, 27 Oct 2024 12:25:53 -0400") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294371 Archived-At: --=-=-= Content-Type: text/plain > One approach is to expose the `prefer` option of `openp` to > `locate-file` so we can use it in `require-with-check`, as in the > patch below. Another is to replace the `assoc` check with one that is more lenient, ignoring difference in file extensions. E.g. the patch below. This makes the change more localized, at the cost of making `require-with-check` slower and less strict. WDYT? Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=require-with-check.patch diff --git a/lisp/files.el b/lisp/files.el index a81f742bbb4..a5177250f45 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1277,10 +1280,19 @@ require-with-check ;; file, so we're done. (when (eq lh load-history) ;; If `require' did nothing, we need to make sure that was warranted. - (let ((fn (locate-file (or filename (symbol-name feature)) - load-path (get-load-suffixes)))) + (let* ((fn (locate-file (or filename (symbol-name feature)) + load-path (get-load-suffixes) nil + )) ;; load-prefer-newer + (fn (if (string-match + (concat (regexp-opt (get-load-suffixes)) "\\'") fn) + (concat (substring fn 0 (match-end 0)) ".") + fn)) + (lh load-history)) + (while (and lh (let ((file (car-safe (car lh)))) + (not (and file (string-prefix-p fn file))))) + (setq lh (cdr lh))) (cond - ((assoc fn load-history) nil) ;We loaded the right file. + (lh nil) ;We loaded the right file. ((eq noerror 'reload) (load fn nil 'nomessage)) ((and fn (memq feature features)) (funcall (if noerror #'warn #'error) --=-=-=--