From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tim Cross Newsgroups: gmane.emacs.devel Subject: Re: PACKAGE-FEATURES, and hot update of Emacs packages Date: Sun, 28 Nov 2021 12:04:53 +1100 Message-ID: <87a6hpkrj5.fsf@gmail.com> References: <5C502136-57BD-40D4-A1E8-A4313AD7CDFC@stanford.edu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26042"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.7.5; emacs 28.0.60 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 28 02:20:01 2021 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 1mr8rJ-0006XH-5d for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Nov 2021 02:20:01 +0100 Original-Received: from localhost ([::1]:52648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mr8rH-00059q-Sa for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Nov 2021 20:19:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mr8oo-0003G4-Ps for emacs-devel@gnu.org; Sat, 27 Nov 2021 20:17:26 -0500 Original-Received: from [2607:f8b0:4864:20::436] (port=40724 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mr8on-00057X-2G for emacs-devel@gnu.org; Sat, 27 Nov 2021 20:17:26 -0500 Original-Received: by mail-pf1-x436.google.com with SMTP id z6so12715876pfe.7 for ; Sat, 27 Nov 2021 17:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=ZUffAPRA6d5CtW5qZOHO8f3eYr2PCBVIhma71KR57ik=; b=j9ev1pHxgZahLT+0T4XjbL2siAPCpNUFUi7VK7zT9vgN0JxZnTbqbpfnNw0Yo9q6Zw ZyoDXc3xiJk6SvVETXWYHnWrTEFhqjHzqxQJzTxvYZ12fwckMy8N9I5SRGPLluwH5g0v QCHZwQkIR8kZRWfsUDcP9qjq/F/SFes1IDJmg94YUfO/tRY4VTizGlJ5IA625li/95Ar ZS+ol/8WLKaeWEkaOjFcnEVjJ5hycaysTtoF3irmGHArBWZsXqOmHTTEv5VIx71tEGx9 pClaz+8UYL0k9n4VnhCAmnC5aO4y4Jl+MPWVjIPXaIG6f/qP0KUKm5AJIiLqNRPalzub 1HeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version; bh=ZUffAPRA6d5CtW5qZOHO8f3eYr2PCBVIhma71KR57ik=; b=0kFJxd/KS7yzrC15Q59ox0/byiwKLDse7YhCSkOHlkd/eEgw/pkOoqP7wMRz/92dfW 72oMGcWA1bjLtpCmTQxIdoc0FWso0KSkWPpV23UcDzI5cgWjXDemk4lrVGrzn/gFqLMg CHdyTqXCCXefQWYPW1ufio6r54cWZHn3GKp/Ha4Gnt2P2QYpvcr4GAaqO5Wjv70U/pzQ tgVdHpf9Y5ZgWWnmljS6h0dF+CK2rPGrBvyj1+9w03FZ/4lKwMPADNFUmCfMXAFnb/OP XHc8tsVa2TcJ/BVJe0YNow6UL5zLf7UZuLxWhQ36R/4uhLFCXHNlcS1808JSH2QjTeT6 ujvw== X-Gm-Message-State: AOAM530PlAgtvGIRzkc4Y1gZguB+MXhA0EXAZabwHHIZcmyUEIxqubgz 64m3u7gxzzOw86RaePUt+4h495G4QXE= X-Google-Smtp-Source: ABdhPJwuJvH6E4IuNeY6orBwz2LFp3uQlzGCUk4mZk8ZIxis11I+YHuBsX0UDe1SMNfWxWOTJw1p9g== X-Received: by 2002:a05:6a00:1c56:b0:4a4:f8cb:2604 with SMTP id s22-20020a056a001c5600b004a4f8cb2604mr30343949pfw.34.1638062241850; Sat, 27 Nov 2021 17:17:21 -0800 (PST) Original-Received: from dingbat (2001-44b8-31f2-bb00-aa4e-0797-59fa-6557.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:aa4e:797:59fa:6557]) by smtp.gmail.com with ESMTPSA id t8sm11520496pfe.28.2021.11.27.17.17.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Nov 2021 17:17:21 -0800 (PST) In-reply-to: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::436 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=theophilusx@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:280362 Archived-At: Phil Sainty writes: > On 2021-11-27 22:31, Qiantan Hong wrote: >> Then to really update p, one just need to >> (mapc (lambda (feature) (unload-feature feature t)) (package-features p)) >> (package-reinstall p) >> (require p) > > Unloading a feature will trash the user's configuration, and so when > you load the updated library only the default config will be set -- > unless the user used `eval-after-load' (which certainly can't be > assumed). As such, I don't think that could work as a reliable "hot > update" process. > > My approach to this general issue (in libraries I've written) has been > to detect at load time if the user had an older version of the library > loaded, and to perform any appropriate in-place upgrades. E.g.: > https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/so-long.el?id=aebba085cba1#n2012 > > This does require that the code knows both the previously-loaded and > newly-loaded version numbers, which can be tricky if the previous > version of the code wasn't storing its version; so I think it would be > great if Emacs *automatically* tracked this information for packages > (or any library that supplies a version) so that authors could write > such update code without needing to have previously prepared for it. > > I don't think this currently happens. I can see the functions > `package-get-version' and `package-desc-version' (which can be used > with `package-alist'), but haven't spotted anything which is storing > the version of a package that is/was loaded (and I don't think this > information is as easily accessible when loading byte-compiled files, > as version comments don't appear in the .elc file). > > I suppose (package-desc-version (package-load-descriptor DIR)) can be > used for ELPA packages installed in the standard way, so maybe there's > scope for using that; but I suspect that'd be too brittle an approach, > as there are many non-standard ways of loading things. > > While I like the idea of being able to use package version to help manage this, the problem is there is no standardisation of package version formats. This makes calculation of which version is before/after another version unreliable. Personally, I wish the package systems used a consistent semantic versioning approach. In addition to determining which package version is later than another version, it would also provide the ability to have more fine grain control over applying updates i.e. could set the system to automatically apply minor patch updates, but not major version updates that may contain breaking changes.