
7

如何修改Elisp函数中的docstring
source link: https://www.lujun9972.win/blog/2017/03/02/%E5%A6%82%E4%BD%95%E4%BF%AE%E6%94%B9elisp%E5%87%BD%E6%95%B0%E4%B8%AD%E7%9A%84docstring/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何修改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"
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK