您可以将代码简化为:
(defun my-file-contents (filename)
"Return the contents of FILENAME."
(with-temp-buffer
(insert-file-contents filename)
(buffer-string)))
编辑:虽然在这个特定的例子中,我看到json-read-file
已经定义了,这削减了中间人.
Emacs 24.5定义如下:
(defun json-read-file (file)
"Read the first JSON object contained in FILE and return it."
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(json-read)))