当我使用成员函数包进行更多 C++ 编码时,我使用了类似的东西:
(require 'member-function)
;;expand member functions automatically when entering a cpp file
(defun c-file-enter ()
"Expands all member functions in the corresponding .h file"
(let* ((c-file (buffer-file-name (current-buffer)))
(h-file-list (list (concat (substring c-file 0 -3 ) "h")
(concat (substring c-file 0 -3 ) "hpp")
(concat (substring c-file 0 -1 ) "h")
(concat (substring c-file 0 -1 ) "hpp"))))
(if (or (equal (substring c-file -2 ) ".c")
(equal (substring c-file -4 ) ".cpp"))
(mapcar (lambda (h-file)
(if (file-exists-p h-file)
(expand-member-functions h-file c-file)))
h-file-list))))
(add-hook 'c++-mode-hook c-file-enter)
Run Code Online (Sandbox Code Playgroud)
您可以在以下位置找到member-functions.el: http: //www.emacswiki.org/emacs/member-functions.el