From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: feature/package-vc has been merged Date: Wed, 09 Nov 2022 08:15:52 +0000 Message-ID: <87bkpgfsqv.fsf@posteo.net> References: <164484721900.31751.1453162457552427931@vcs2.savannah.gnu.org> <87fsew8g18.fsf@posteo.net> <83mt941cyd.fsf@gnu.org> <87fsewp0ec.fsf@posteo.net> <837d0814c9.fsf@gnu.org> <878rkooz1o.fsf@posteo.net> <831qqg1306.fsf@gnu.org> <874jvcowzm.fsf@posteo.net> <83y1soypvx.fsf@gnu.org> <87y1song5x.fsf@posteo.net> <83v8nsyof7.fsf@gnu.org> <87leoond7l.fsf@posteo.net> <83r0yfzz01.fsf@gnu.org> <87bkpjyx3p.fsf@posteo.net> <83bkpjynmj.fsf@gnu.org> <87iljqya44.fsf@posteo.net> <8335auzo9s.fsf@gnu.org> <87zgd2ws8z.fsf@posteo.net> <831qqezkxj.fsf@gnu.org> <87y1slgq3m.fsf@posteo.net> 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="12140"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , rms@gnu.org, emacs-devel@gnu.org, Lars Ingebrigtsen To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 09 09:17:30 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 1osgH3-0002vk-QG for ged-emacs-devel@m.gmane-mx.org; Wed, 09 Nov 2022 09:17:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osgG9-0001c7-Kq; Wed, 09 Nov 2022 03:16:33 -0500 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 1osgFc-0001ZB-Gv for emacs-devel@gnu.org; Wed, 09 Nov 2022 03:16:00 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osgFa-0002mg-5l for emacs-devel@gnu.org; Wed, 09 Nov 2022 03:16:00 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D990C240101 for ; Wed, 9 Nov 2022 09:15:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667981755; bh=sgpq4MxOb1FPWMUsuEuYYMx+oP9sX68Qltb5NfiopYQ=; h=From:To:Cc:Subject:Date:From; b=gEx2qyR9+kc96PBi+KtdbPC2zixk7N595edrHIn4njdOlD6myZWU9J8l2Qao6KIFw pvrBM+DOJ10649nOzjc/egiqXVbQFgp0dlFr/f//VE3V8Qa6IgmDRntTpvKqnzjMgz s9o2dHLQ4xB251mKeW4zVpOjd9TzR+W8YyyuCPfTTSDdmNKJju398j28Sql7WSKfqE iMLkJu+IBSdj5V0lsnZUAGHgezF6vW/lataOUZdU4ZXpxZhLRzAd8QtV9OC5+wQRg2 XTeM+G055mYUqsYNPCaGb0AJ/dg2o6WWdLRRkpmcqlm7ogRVWrJtCDcc3rV7aAAMkQ 7b4Zz1g9paAVw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N6d882lM6z6tmq; Wed, 9 Nov 2022 09:15:52 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Tue, 08 Nov 2022 16:35:15 -0500") Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299389 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> (loaddefs-generate >> - pkg-dir output-file >> - nil >> - "(add-to-list 'load-path (directory-file-name >> - (or (file-name-directory #$) (car load-path))))") >> + (file-name-concat pkg-dir lisp-dir) >> + output-file nil >> + (prin1-to-string >> + `(add-to-list 'load-path >> + (directory-file-name >> + ,(file-name-concat pkg-dir lisp-dir))))) >> (let ((buf (find-buffer-visiting output-file))) >> (when buf (kill-buffer buf))) >> auto-name)) >> --8<---------------cut here---------------end--------------->8--- >> >> Git tells me that Lars was wrote the "(or (file-name-directory #$) (car >> load-path))" bit, so I've added him to the CC's: Can you explain what >> the intention was here, and if my suggested replacement would break >> anything? > > I suspect he just copy/pasted the code from elsewhere. > The point is to make the file work regardless of where it is whereas > your replacement makes it work only in the location we used to > generate it. I see, that makes sense. > You can/should replace #$ with `load-file-name`, which will make it > behave better w.r.t byte-compilation. I suspected so much from lread.c, but wanted to make sure. So in that case the following should suffice: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 0881626e92..67ce30a93c 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1103,8 +1103,17 @@ package-generate-autoloads (package-lisp-dir pkg-desc) output-file nil (prin1-to-string - `(add-to-list 'load-path - ,(package-lisp-dir pkg-desc)))) + `(add-to-list + 'load-path + (file-name-concat + ;; Add the directory that will contain the autoload file to + ;; the load path. We don't hard-code `pkg-dir', to avoid + ;; issues if the package directory is moved around. + (or (and load-file-name (file-name-directory load-file-name)) + (car load-path)) + ;; In case the package specification indicates that the lisp + ;; files are found in a subdirectory, append that path. + ,(alist-get :lisp-dir (package-desc-extras pkg-desc)))))) (let ((buf (find-buffer-visiting output-file))) (when buf (kill-buffer buf))) auto-name)) --=-=-= Content-Type: text/plain > > Stefan --=-=-=--