From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Akib Azmain Turja Newsgroups: gmane.emacs.help Subject: Re: How to develop a local fork of a package? Date: Mon, 05 Sep 2022 17:38:29 +0600 Message-ID: <87zgfet5je.fsf@disroot.org> References: <87k06kk8od.fsf@gmail.com> <87r10s8u79.fsf@dataswamp.org> <87tu5nkgf3.fsf@disroot.org> <87bkruhit7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Alessandro Bertulli Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 05 14:10:51 2022 Return-path: Envelope-to: geh-help-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 1oVAwE-0007Ky-M1 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 05 Sep 2022 14:10:50 +0200 Original-Received: from localhost ([::1]:39892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVAwD-00011M-G3 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 05 Sep 2022 08:10:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVAex-0007Nc-Uh for help-gnu-emacs@gnu.org; Mon, 05 Sep 2022 07:52:59 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]:34350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVAev-0005Pv-Vr for help-gnu-emacs@gnu.org; Mon, 05 Sep 2022 07:52:59 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id AAA9440105; Mon, 5 Sep 2022 13:52:56 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AFlZZR70IHEm; Mon, 5 Sep 2022 13:52:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1662378775; bh=3yqn1GY5rUikC8TQZlmgFctrGr7Hbhwv2EyZVxMR68Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=G0cGiQZjkLhiw2O8d+8cd+D2PE4kvPCt75VKqLHjhHbIMMpq99d7Vczz/ZJLBtvCK /t+D59eEPgd/4upgf6l5ySh8g59QxhpBxrum4WKSflLS+jvoLd6A7e4AUWKrkI2/XB 5EO1kIKR51C/ypGbu7rPSxD2pPtpG3VP7loUuP1iGE49rxuc8TuPGtGSB78ESlp/Iw 99t/meYyamCEDNWpPIrp+IhVJAYwwCi4m7I4D9q1lAq7tuvNAn29/uqpusr1peaLwK xYChvLtV2DSHPQ0mPNnUK35dimRvW8fcoKVg0B12FLQNTtyNlZuM+tWo9/XdWJVpOY WY9zFuQjzkrsA== In-Reply-To: <87bkruhit7.fsf@gmail.com> (Alessandro Bertulli's message of "Mon, 05 Sep 2022 00:20:01 +0200") Received-SPF: pass client-ip=178.21.23.139; envelope-from=akib@disroot.org; helo=knopi.disroot.org 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139252 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Alessandro Bertulli writes: > Akib Azmain Turja writes: > >>> Alessandro Bertulli wrote: >>> >>>> (add-to-list 'load-path (expand-file-name "git_packages/org-ref/")) >> >> (expand-file-name "git_packages/org-ref/")? Relative to what? If the >> directory is in your ".emacs.d", then it should be (add-to-list >> 'load-path (expand-file-name "git_packages/org-ref/" >> user-emacs-directory)). > > Yes, but if not specified the user-emacs-directory is the default, so I > don't think that's a problem (will try tho, just in case). No, the default value is the value of default-directory variable. However I don't know what the value of default-directory variable during initialization. There is a function "locate-user-emacs-file", which will always expand the name relative to your .emacs.d. > >>>> (delete "/home/alessandro/.emacs.d/elpa/org-ref-20220830.1210" load-pa= th) >>>> (package-initialize) >> >> Why? This would break whenever package.el updates org-ref. > > Yes, it was just an hack to try with the current package. > >> And this won't ever work because that directory is not in load-path >> before (package-initialize), and after (package-initialize) org-ref >> will be on load-path. > > You're right, I didn't know the functioning of package-initialize. I'll > try and let you know. > >> Your best option is to delete the package with M-x package-delete. > > Aren't there any other methods? Like, if you want to make a PR, do you > uninstall the package every time? Actually I don't do PRs much, so much uninstalling packages is not a big problem for me. However, you may try to customize or set the variable package-load-path like this: =2D-8<---------------cut here---------------start------------->8--- (setq package-load-path '((org-ref nil) all)) =2D-8<---------------cut here---------------end--------------->8--- I think the above should work, but I haven't tested it. > >> And the "delete" call may not work. You set load-path to the return >> value of "delete", for example: >> >> (setq load-path >> (delete "/home/alessandro/.emacs.d/elpa/org-ref-20220830.1210" >> load-path)) > > Well, it works for me actually. Also, delete uses side effects, if I > wanted to use setq, I should use remove, right? No, you should use setq with delete because delete uses side-effects. For example, if not don't use setq the following works as you expect: =2D-8<---------------cut here---------------start------------->8--- (let ((foo '(1 2 3))) (delete 2 foo) foo) ;; =3D> '(1 3) =2D-8<---------------cut here---------------end--------------->8--- But the following doesn't: =2D-8<---------------cut here---------------start------------->8--- (let ((foo '(1 2 3))) (delete 1 foo) foo) ;; =3D> '(1 2 3) =2D-8<---------------cut here---------------end--------------->8--- To understand why the above doesn't work, you need to understand how lists work. In Lisp, a list is a linked list made using cons cells. For example, for the list '(1 2 3), it is actually '(1 . (2 . (3 . nil))), or: foo | | | +---+ | | --- 1 +---+ | | --- +---+ +---+ | | --- 2 +---+ | | --- +---+ +---+ | | --- 3 +---+ | | --- nil +---+ When you "delete" 2 from it: foo return value | | +--------+ | +---+ | | --- 1 +---+ | | ------+=20 +---+ | | +------ +---+ | | --- 3 +---+ | | --- nil +---+ But when you "delete" 1: foo | | | return value +---+ | | | --- 1 | +---+ | | | --- +---+ +---+ | | --- 2 +---+ | | --- +---+ +---+ | | --- 3 +---+ | | --- nil +---+ The variable foo still points to the old cons cell and therefore isn't changed. So to ensure the value is changed, you should use setq with delete. "remove" doesn't use side-effects, so it never modifies any variable. And that's why you should use the following: =2D-8<---------------cut here---------------start------------->8--- (setq load-path (delete "/home/alessandro/.emacs.d/elpa/org-ref-20220830.1210" load-path)) =2D-8<---------------cut here---------------end--------------->8--- ... because you can't be sure that load-path is really modified without the setq. > >>>> >>>> But then, no matter which one of these I use >>>> >>>> (require 'org-ref) >> >> Unless org-ref is in load-path, this will always error. > > I suspect this is given by my wrong usage of package-initialize. > >>>> (load "~/.emacs.d/git_packages/org-ref/org-ref") >> >> Where is the ".el" suffix? Did you mean (load >> "~/.emacs.d/git_packages/org-ref/org-ref.el")? > > Wait, shouldn't I omit the suffix on purpose? Looking at the docstring > of load: "First try FILE with .elc appended, then try with .el". Ah, I forgot that. Sorry. You're right. > >> Loading directly will probably work for single file packages, but you >> should always add the package directory to load-path. > > Aside from the directory part, that file is the one containing the > (provide 'org-ref) call. Shouldn't loading that achieve the same result > of the (require 'org-ref) I normally use? Since the other code files are > loaded inside it. Unless there is any other file in the directory, it should work. But if there are other Emacs Lisp files, most likely the main file (that you're trying to load) depends on them. > >>>> (use-package org-ref >>>> :ensure nil >>>> :load-path "~/.emacs.d/git_packages/org-ref/org-ref.el") >> >> I think the error is because you specify a file as load-path instead of >> a directory. I think the load-path should be probably >> "~/.emacs.d/git_packages/org-ref/". However, I have never used >> :load-path keyword of use-package, so my assumptions may be wrong. > > If the above doesn't work, I'll try and I'll let you know. Thanks! > > Alessandro =2D-=20 Akib Azmain Turja Find me on Mastodon at @akib@hostux.social. This message is signed by me with my GnuPG key. Its fingerprint is: 7001 8CE5 819F 17A3 BBA6 66AF E74F 0EFA 922A E7F5 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEyVTKmrtL6kNBe3FRVTX89U2IYWsFAmMV37YACgkQVTX89U2I YWvp7A/8CpdcZIPEKWPR2GwW4iSkPD9fbEKvdywHLfmG97hOJSvvnIAMB1amfQY8 tj8DXu7MxVxXKsYsGAHuuJ8ow/Ju8lCv38SM76psTu/0uyzEW08SxjVJThz1XDaw hRlDuN1ynLXW01JVqlJq9eYHLH+tmlOCch22zgnDLeNZROtsXqCzrMvfRtbXP8X3 83bYij9nJmhx5P7thvffZmcHIme6T5BlGozSXA+3osfIsc0VjH3Yk3XWBSp+dMtl uwQMCerMBJBsNBilSLr7c3obhPagVrMGuRQ/64VMETpZl5edPh6Xg1V1cxpGQ8vE WAemkSD5CSkFgyT6ewUSoUfbH3ogALa3FACCDxgVqcr9LNKeTDkPuJPrBxXAwxsN K+QdF3As0b3KpSM5ZXpobFazUrhRTUIT9KOlRn03MQzfvrnD/xmqpfdZ1riSTn3K L+HKUluE7PERBapStzTWjK3IzE8SWQWZvyReFWyvyknX9ZqH9EHDP3APH5d3HRNQ S5gf+OPB0zOGzwiOupDNx9qveH1eaqgVm0rQIjyFYXB21h+BjeGIpZtFZIDJh6OZ FwyiufFe5vkAGih9fmlav23jgBf0M+9RTBe5K9V5+qaex3k0FFpFb3W2E4qZETSV u791c/tDMsuqu84fqQHEUgZuQOzlj2R0ofi2Db5KHkRuSxym+Lk= =q2XX -----END PGP SIGNATURE----- --=-=-=--