如何修改 Elisp 函数中的 docstring
Elisp 提供了 documentation
函数可以用来获取另一个函数的 docstring,然而可惜它是不能通过 setf
修改的:
(defun foo () "Old Docstring") (documentation 'foo) ;; =>"Old Docstring" (fset (documentation 'foo) "New Docstring") ;; Debugger entered--Lisp error: (wrong-type-argument symbolp "Old Docstring")
不过有一个比较 hack 的方法,就是修改 symbol 的 function-documentation
属性,它的优先级要高于函数本身存储的 docstring
(put 'foo 'function-documentation "New Docstring") (documentation 'foo) ;; =>"New Docstring"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论