I am using windows emacs with specifications below.
我使用的Windows emacs规格如下。
GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600) of 2009-02-26
2009-02-26的GNU Emacs 23.0.91.1(i386-mingw-nt5.1.2600)
I want to be able to run astyle so it can reformat the code by using a key command or menu. What is some other equivalent in emacs?
我希望能够运行astyle,以便可以使用键盘命令或菜单重新格式化代码。在emacs中还有什么其他的等价物?
1 个解决方案
#1
Something like this might do:
这样的事情可能会:
(defun astyle-this-buffer (pmin pmax)
(interactive "r")
(shell-command-on-region pmin pmax
"astyle" ;; add options here...
(current-buffer) t
(get-buffer-create "*Astyle Errors*") t))
This will run the "astyle" command on the selected region.
这将在所选区域上运行“astyle”命令。
Or, you could simply use emacs' built-in code formatting by typing something like
或者,您可以通过键入类似的内容来简单地使用emacs的内置代码格式
C-x h C-M-\
(I.e. select the whole buffer and run indent-region
)
(即选择整个缓冲区并运行缩进区域)
#1
Something like this might do:
这样的事情可能会:
(defun astyle-this-buffer (pmin pmax)
(interactive "r")
(shell-command-on-region pmin pmax
"astyle" ;; add options here...
(current-buffer) t
(get-buffer-create "*Astyle Errors*") t))
This will run the "astyle" command on the selected region.
这将在所选区域上运行“astyle”命令。
Or, you could simply use emacs' built-in code formatting by typing something like
或者,您可以通过键入类似的内容来简单地使用emacs的内置代码格式
C-x h C-M-\
(I.e. select the whole buffer and run indent-region
)
(即选择整个缓冲区并运行缩进区域)