all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Tom Gillespie <tgbugs@gmail.com>,
	 "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
	 Bastien <bzg@gnu.org>
Subject: Re: org-assert-version considered harmful
Date: Wed, 16 Aug 2023 08:30:44 -0400	[thread overview]
Message-ID: <jwvzg2rjht3.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87h6oznt28.fsf@localhost> (Ihor Radchenko's message of "Wed, 16 Aug 2023 11:08:15 +0000")

Ihor Radchenko [2023-08-16 11:08:15] wrote:
> Ihor Radchenko <yantar92@posteo.net> writes:
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> BTW, rather than unloading, `package.el` relies on forcibly "re"loading
>>> from the new version the already loaded files from the old version.
>>> It suffers from a different set of problem :-(
>>> [ I suspect `defvar` is the main problem for that solution.  ]
>>
>> Could it be possible to force require use certain package version and
>> automatically re-load a package when older version is being loaded?
>
> After trying several more approaches,

[ Side note: did you keep notes about the various approaches you tried
  and their respective downsides?  E.g. I'm curious what were the
  problems linked to my proposal of using a `require-with-check` like
  the one below my sig.  ]

> I now came up with yet another idea.  Instead of fiddling with load
> internals, compilation, or load-path, what about making sure that Org
> libraries include version info directly?

That should work.  It implies a fair bit more churn in the code, tho,
but I guess you plan to automate it via some scripts?


        Stefan


(defun require-with-check (feature &optional filename noerror)
  "If FEATURE is not already loaded, load it from FILENAME.
This is like `require' except if FEATURE is already a member of the list
‘features’, then we check if this was provided by a different file than the
one that we would load now (presumably because `load-path' has been
changed since the file was loaded)."
  (let ((lh load-history)
        (res (require feature filename noerror)))
    ;; If the `feature' was not yet provided, `require' just loaded the right
    ;; file, so we're done.
    (if (not (eq lh load-history)) res
      ;; 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))))
        ;; If the right file was indeed loaded already, we're done.
        (if (assoc fn load-history) res
          (funcall (if noerror #'warn #'error)
                   "Feature provided by other file: %S" feature)
          res)))))



  reply	other threads:[~2023-08-16 12:46 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 18:27 org-assert-version considered harmful Stefan Monnier
2022-09-13  1:52 ` Ihor Radchenko
2022-09-13  2:16   ` Timothy
2022-09-13  2:53   ` Stefan Monnier
2022-09-13  3:18     ` Ihor Radchenko
2022-09-13 13:26       ` Stefan Monnier
2022-09-13 14:42         ` Ihor Radchenko
2022-09-13 16:13           ` Stefan Monnier
2022-09-14  2:46             ` Ihor Radchenko
2022-09-14 14:08               ` Stefan Monnier
2022-09-14 19:13                 ` Tim Cross
2022-09-25  2:39               ` Bastien
2022-09-25  3:15                 ` Ihor Radchenko
2022-09-25  4:27                   ` Timothy
2022-09-25  9:37                   ` Bastien
2022-09-25  9:55                     ` Ihor Radchenko
2022-09-25 10:24                       ` Bastien
2022-09-25 11:10                         ` Ihor Radchenko
2022-09-25 11:26                           ` Bastien
2022-09-25 12:16                             ` Ihor Radchenko
2022-09-25 13:18                               ` Bastien
2022-09-26 11:15                                 ` Ihor Radchenko
2022-09-25 12:20                             ` Ihor Radchenko
2022-09-25 13:16                               ` Bastien
2022-09-26 11:29                 ` Ihor Radchenko
2022-09-27 21:35                   ` Bastien
2022-10-31 14:11                     ` Cook, Malcolm
2022-10-31 20:16                       ` [External] : " Daniel Ortmann
2022-10-31 20:40                         ` Cook, Malcolm
2022-10-31 23:16                       ` Tim Cross
2022-11-01  6:09                       ` Ihor Radchenko
2022-11-02 20:42                         ` Cook, Malcolm
2022-11-03  7:51                           ` Ihor Radchenko
2022-11-03 17:30                             ` Cook, Malcolm
2022-12-02  8:16                               ` Tom Gillespie
2022-12-02  6:45                                 ` Ihor Radchenko
2022-12-04  4:22                                   ` Tom Gillespie
2022-12-04  4:33                                     ` Stefan Monnier
2022-12-04 11:12                                       ` Ihor Radchenko
2023-08-16 11:08                                         ` Ihor Radchenko
2023-08-16 12:30                                           ` Stefan Monnier [this message]
2023-08-16 12:41                                             ` Ihor Radchenko
2023-08-16 13:41                                               ` Stefan Monnier
2023-08-18  9:37                                                 ` Ihor Radchenko
2023-08-18 13:19                                                   ` Stefan Monnier
2023-08-18 13:33                                                     ` Ihor Radchenko
2023-08-18 13:45                                                       ` Stefan Monnier
2023-08-18 14:26                                                         ` Ihor Radchenko
2023-08-18 14:29                                                           ` Ihor Radchenko
2023-08-17 16:43                                           ` Max Nikulin
2023-08-17 16:59                                             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzg2rjht3.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=tgbugs@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.