我正在尝试编写一个函数,在给定文件路径的情况下,该函数将加载该文件的内容并将其附加到列表中。最终目标是为每个 org-capture 模板提供一个文件,并从文件列表或 org-table 加载它们。
我的问题是加载和加载文件函数仅在加载成功时返回 t。
我可以使用什么函数将文件的内容作为表达式返回?
例如,给定文件 test.el:
'("foo" "bar" "baz" "fnord")
如何实现以下目标:
(mysterious-function "~/test.el")
=> '("foo" "bar" "baz" "fnord")
提前致谢
最佳答案
(defun mysterious-function (filename)
(setq filename (expand-file-name filename))
(with-temp-buffer
(insert-file-contents filename)
(read (current-buffer))))
关于emacs - Elisp - 从文件中加载表达式作为数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21312143/