如何在GNU Emacs中打开文件后自动执行命令

时间:2016-03-29 12:01:08

标签: emacs elisp

如何执行以下操作:打开文件后自动执行命令(split-window-right) (follow-mode) (visual-line-mode)

1 个答案:

答案 0 :(得分:2)

一种方法是编写自己的"打开文件"命令:

class DLL WebPage
{
    private:
        char *ip_;
        char *port_;
        char *page_;

    public:
        WebPage();
        ~WebPage();
        get(char *ip,char *port,char *page); //<---This is the trouble maker
        char *ip(void);
        char *port(void);
        char *page(void);
};

您可以将其绑定到(defun my-find-file () "Like `find-file', but splits screen and enables Follow Mode." (interactive) (call-interactively #'find-file) (follow-delete-other-windows-and-split) (visual-line-mode 1))

C-x C-f

我使用了(global-set-key (kbd "C-x C-f") #'my-find-file) 而不是follow-delete-other-windows-and-splitsplit-window-right,当框架已包含多个窗口时,后者无法正常工作。

此外,您可以考虑使用其他机制启用follow-mode,例如特定于模式的挂钩或visual-line-mode