I need to use a version of prolog.el
not older than 1.25, so I defined the function maybe-reload-prolog-el
:
(defun maybe-reload-prolog-el ()
(when (version< prolog-mode-version "1.25")
(add-to-list
'load-path
(file-name-as-directory (concat my-lib-path "prolog-el")))
(load-library "prolog"))))
...which adds the path to my personal copy of prolog.el
to load-path
(and then reloads prolog
) if it detects that prolog-mode-version
is too old 1.
Then I put a call to maybe-reload-prolog-el
in a hook I already had for prolog-mode
:
(add-hook 'prolog-mode-hook (lambda () ;; ;; some keyboard settings, like ;; (local-set-key [f10] ...) ;; (local-set-key [f9] ...) ;; ;; etc (maybe-reload-prolog-el)))
The main problem with this approach is that prolog.el
is responsible for more than prolog-mode
. For example, it has the code for the autoloaded function run-prolog
, which I use to run a Prolog sub-process in an Emacs buffer. AFAICT, prolog-mode-hook
does not get triggered when I run run-prolog
, so I end up running an outdated version of it.
Is there some way to trigger maybe-reload-prolog-el
right after prolog.el
is loaded, before any of its code gets executed?
BTW, as currently written, maybe-reload-prolog-el
can run only after prolog.el
is loaded, because it relies on the variable prolog-mode-version
, which is defined in prolog.el
, to decide whether to load my local copy of prolog.el
. IOW, if I simply put the following code in my init file
(if (version< prolog-mode-version "1.25")
(add-to-list
'load-path
(file-name-as-directory (concat my-lib-path "prolog-el"))))
...it fails with:
Symbol’s value as variable is void: prolog-mode-version
If there were some way to test the version of the default prolog.el
's version before loading it (let's call this method PROLOG-OLDER-THAN-1.25-p
, then I would just put this in my init file:
(if (PROLOG-OLDER-THAN-1.25-p)
(add-to-list
'load-path
(file-name-as-directory (concat my-lib-path "prolog-el"))))
Please let me know if there's a way to implement a PROLOG-OLDER-THAN-1.25-p
that does not require prolog.el
to be loaded.
Of course, I know that I can always use my copy of prolog.el
, unconditionally. IOW, I can just put this in my init file:
(add-to-list
'load-path
(file-name-as-directory (concat my-lib-path "prolog-el"))))
This approach works in the short-term, of course, but it requires more maintenance long-term.
1 Please let me know if what my maybe-reload-prolog-el
function does is the best way to conditionally reload prolog.el
. I'm not too confident that (load-library "prolog")
is the right thing to do here.
PROLOG-OLDER-THAN-1.25-p
that does not require prolog.el to be loaded" - the only way would be to search the source code text.