2011-11-22 36 views
1

我想配置Emacs的,以便它具有:改变Emacs的默认字体大小和新的缓冲区文本

  1. 增加默认字体大小。目前我使用Shift + 点击每次打开一个文件就改变它,但我希望我的配置保存到emacs配置文件中。

  2. 我希望在打开要更改的新缓冲区时出现默认文本。我假设它会像默认打开的一些模板。这里是我希望看到的作为默认文本的代码,当我启动emacs时,我可以直接处理它。

    #include <stdio.h> 
    #include <unistd.h> 
    #include <stdlib.h> 
    #include <string.h> 
    #include <sys/types.h> 
    #include <errno.h> 
    #include <pthread.h> 
    
    int main(int argc, char *argv[]) 
    { 
        return 0; 
    } 
    
+0

对不起,我无法很好地格式化代码。我在这里还是新手。请格式化,并告诉我正确的方法来完成它。 – uyetch

+0

在emacs中设置字体:http://stackoverflow.com/questions/6026713/how-do-i-change-emacs-default-font-size-and-font-type – Patrick

+0

并初始化临时消息:http:// stackoverflow .com/questions/1498258/how-do-i-change-the-scratch-message-in-emacs – Patrick

回答

1

有更好的方法来插入模板,但是这应该为你做的伎俩。显然,自定义字体到你想要的。

将下面的代码在你的.emacs,它可以在你的home目录中找到,或通过做C-X C-F〜/的.emacs RET(和一堆其他位置是可能的,看到这些SO questions)。

(setq inhibit-startup-message t) 
(switch-to-buffer "temp") 
(set-frame-font "courier-16") 
(insert "#include <stdio.h> 
#include <unistd.h> 
#include <stdlib.h> 
#include <string.h> 
#include <sys/types.h> 
#include <errno.h> 
#include <pthread.h> 

int main(int argc, char *argv[]) 
{ 
    return 0; 
}") 
+0

感谢您的回答,但您能否告诉我在哪里(以及如何)保存此内容。 – uyetch

+0

有一个名为''.emacs''的文件,它位于$ HOME文件夹中。这个文件在你启动emacs时被评估。如果您在шiпdoшs上,请尝试查找像HOME或PATH这样的系统变量,并在该文件夹中创建文件。 – desudesudesu

+0

谢谢它帮助我! – uyetch

0

要更改默认字体(大小),不只是第一个,但每个Emacs框架(即更常见的术语窗口),在您的.emacs使用:

(setq default-frame-alist 
     '((font . "Terminus 10"))) 

(当然与所需的字体和大小替换Terminus 10

0

使用挂钩,只要你创建一个新的文件,以指定所需的文本:

(defun cpp-file-not-found()` 
    (if (or (equal (file-name-extension (buffer-file-name)) "cpp") 
     (equal (file-name-extension (buffer-file-name)) "cxx") 
     (equal (file-name-extension (buffer-file-name)) "cc") 
     (equal (file-name-extension (buffer-file-name)) "C") 
     (equal (file-name-extension (buffer-file-name)) "c") 
    ) 
     (progn 
     (goto-char 1) 
     (insert "#include <stdio.h>\n") 
     (insert "int main (int argc, char *argv[]) {\n") 
     (insert " return 0;\n") 
     (insert "}\n") 
     ) 
    ) 
) 
(add-hook 'find-file-not-found-functions 'cpp-file-not-found) 
相关问题