mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
try-emacs-mua: Trim `require' advice for Emacs 25
- Since Emacs 25 comes with `load-prefer-newer' we can remove the complicated variant of the advice, which implemented a poorman's version of that. - Since Emacs 25 comes with the new advice mechanism, we can use that now for the simple variant of the advice, which just informs about the library that is being required.
This commit is contained in:
parent
6336c26d23
commit
1c80020e70
1 changed files with 4 additions and 22 deletions
|
@ -44,28 +44,10 @@ while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")
|
||||||
try-notmuch-emacs-directory (concat pdir "emacs/")
|
try-notmuch-emacs-directory (concat pdir "emacs/")
|
||||||
load-path (cons try-notmuch-emacs-directory load-path)))
|
load-path (cons try-notmuch-emacs-directory load-path)))
|
||||||
|
|
||||||
;; they say advice doesn't work for primitives (functions from c source)
|
(define-advice require
|
||||||
;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)
|
(:before (feature &optional _filename _noerror) notmuch)
|
||||||
;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)
|
|
||||||
;; note also that the old, "obsolete" defadvice mechanism was used, but that
|
|
||||||
;; is the only one available for emacs 23 and 24 up to 24.3.
|
|
||||||
|
|
||||||
(if (boundp 'load-prefer-newer)
|
|
||||||
(defadvice require (before before-require activate)
|
|
||||||
(unless (featurep feature)
|
(unless (featurep feature)
|
||||||
(message "require: %s" feature)))
|
(message "require: %s" feature)))
|
||||||
;; else: special require "short-circuit"; after load feature is provided...
|
|
||||||
;; ... in notmuch sources we always use require and there are no loops
|
|
||||||
(defadvice require (before before-require activate)
|
|
||||||
(unless (featurep feature)
|
|
||||||
(message "require: %s" feature)
|
|
||||||
(let ((name (symbol-name feature)))
|
|
||||||
(if (and (string-match "^notmuch" name)
|
|
||||||
(file-newer-than-file-p
|
|
||||||
(concat try-notmuch-emacs-directory name ".el")
|
|
||||||
(concat try-notmuch-emacs-directory name ".elc")))
|
|
||||||
(load (concat try-notmuch-emacs-directory name ".el") nil nil t t)
|
|
||||||
)))))
|
|
||||||
|
|
||||||
(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")
|
(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue