branch: externals/load-relative commit d8757b3c54ac7753987c5474725ff817ef3b5600 Author: Daniel Pittman <dan...@rimspace.net> Commit: GitHub <nore...@github.com>
require-relative: allow symbols as well as strings This updates `require-relative' to allow a symbol to be passed; it is simply converted to a string and used exactly as before. Theoretically it could be optimised to avoid `intern' on a symbol, but loading code is expensive enough I can't imagine it matters. This allows for the more natural, to me: `(require-relative 'usbhid-data)` --- load-relative.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/load-relative.el b/load-relative.el index af9b711a3d..290166b0f3 100644 --- a/load-relative.el +++ b/load-relative.el @@ -278,9 +278,12 @@ symbol. WARNING: it is best to to run this function before any buffer-setting or buffer changing operations." - (let ((require-string-name - (concat opt-prefix (file-name-sans-extension - (file-name-nondirectory relative-file))))) + (let* ((relative-file (if (symbolp relative-file) + (symbol-name relative-file) + relative-file)) + (require-string-name + (concat opt-prefix (file-name-sans-extension + (file-name-nondirectory relative-file))))) (require (intern require-string-name) (relative-expand-file-name relative-file opt-file))))