branch: master
commit a820b199d37c8fca05695277befa7cda3edf514a
Author: rocky <[email protected]>
Commit: rocky <[email protected]>
Fixes #6 - this time for sure!?
Premature optimization is the root of evil/eval.
---
load-relative.el | 23 +++++------------------
test/test-load.el | 15 ---------------
2 files changed, 5 insertions(+), 33 deletions(-)
diff --git a/load-relative.el b/load-relative.el
index 8eb3578..3dfab22 100644
--- a/load-relative.el
+++ b/load-relative.el
@@ -102,7 +102,6 @@
;; This is easier if you care about the contents of the file, rather than
;; a buffer.
-
;;; Code:
;;;###autoload
@@ -134,17 +133,17 @@ methods work we will use the file-name value find via
;; persists after loading or evaluating a file. So it would be
;; suitable if __FILE__ were called from inside a function.
-
(cond
+
;; lread.c's readevalloop sets (car current-load-list)
;; via macro LOADHIST_ATTACH of lisp.h. At least in Emacs
;; 23.0.91 and this code goes back to '93.
- ((load-relative:file-from-load-history current-load-list))
+ ((stringp (car-safe current-load-list)) (car current-load-list))
;; load-like things. 'relative-file-expand' tests in
;; test/test-load.el indicates we should put this ahead of
;; $#.
- ;; (load-file-name)
+ (load-file-name)
;; Pick up "name of this file as a string" which is set on
;; reading and persists. In contrast, load-file-name is set only
@@ -160,8 +159,8 @@ methods work we will use the file-name value find via
;; bytecomp-filename comes from that routine?
((boundp 'bytecomp-filename) bytecomp-filename)
- (t (symbol-file symbol)) ;; last resort
- ))
+ (t (symbol-file symbol) ;; last resort
+ )))
(defun autoload-relative (function-or-list
file &optional docstring interactive type
@@ -276,10 +275,6 @@ buffer-setting or buffer changing operations."
"Run `require-relative' on each name in LIST which should be a list of
strings, each string being the relative name of file you want to run."
`(progn
- (eval-when-compile
- (require 'cl
- (dolist (rel-file ,list)
- (require-relative rel-file (__FILE__) ,opt-prefix))))
(dolist (rel-file ,list)
(require-relative rel-file (__FILE__) ,opt-prefix))))
@@ -297,14 +292,6 @@ same as writing (provide 'bar-foo)
`(provide (intern (concat ,prefix (file-name-sans-extension
(file-name-nondirectory (__FILE__)))))))
-(defun load-relative:file-from-load-history (history-list)
- "Pick out the first string in `history-list"
- (cond
- ((null history-list) nil)
- ((stringp (car history-list)) (car history-list))
- (t (load-relative:file-from-load-history (cdr history-list)))
- ))
-
(provide-me)
;;; load-relative.el ends here
diff --git a/test/test-load.el b/test/test-load.el
index 16715a2..1002996 100644
--- a/test/test-load.el
+++ b/test/test-load.el
@@ -94,19 +94,4 @@
(provide-me "my-")
(assert-t (featurep 'my-test-load) "provide-me - prefix")
-(assert-nil (load-relative:file-from-load-history nil)
- "null load-history")
-
-(assert-equal
- "/tmp/realgud/common/track-mode.el"
- (load-relative:file-from-load-history
- '((require . load-relative) (require . shell) (require . cl)
- "/tmp/realgud/common/track-mode.el"))
- "load-history list with require's")
-
-(assert-equal
- "/tmp/foo.bar"
- (load-relative:file-from-load-history '("/tmp/foo.bar"))
- "load-history with single filename")
-
(end-tests)