【Emacs】Emacs的初等配置

前言

这几天重点学习了Emacs的相关用法
并且配置了基本的Emacs自定义配置
已经基本将Emacs的c++-mode变成了Dev-cpp的样子
已经基本完成了所有关于Latex的相关配置

正文

今天基本完成了Emacs的配置
并且将配置模块化
其中init.el的文件内容如下:http://paste.ubuntu.com/23893755/
ps:因为准备继续使用Emacs自己的package manager,所以package initialization相关内容并没有模块化
其他配置模块均位于~/.emacs.d/lisp/下,参见:http://pan.baidu.com/s/1dE8WYfn

Reference

  1. Tutorial on Latex:http://cs2.swfc.edu.cn/~wx672/lecture_notes/linux/latex/latex_tutorial.html
  2. 配置文件模块化:http://book.emacs-china.org/#orgheadline13

【Emacs】Emacs的进阶设置

正文

今天继续折腾Emacs的相关设置
主要进行了一下更新

  1. c++-mode的代码缩进设为由\t填充
    (defun my-cpp-mode-common-hook ()
      (setq c-basic-offset 4)
      (setq default-tab-width 4)
      (setq indent-tabs-mode t)
    )
    (add-hook 'c-mode-common-hook 'my-cpp-mode-common-hook)
    
  2. 将’F9’绑定为编译,并将其功能设定为与Dev-cpp完全一样
    ps:其中的编译命令请按需修改

    (defun defineCompileCmd()
      (interactive)
      (setq compile_file_name (substring (buffer-name (current-buffer)) 0 (string-match "[.]"  (buffer-name (current-buffer)))))
      (setq compile-command 
    	(concat  "g++ -o " 
    	  compile_file_name
    	  " "
    	  compile_file_name
    	  ".cpp -lm -O2 -Wl,-stack=100000000"
    	))
      ;;g++ -o watchdog watchdog.cpp -lm -O2 -Wl,-stack=100000000 -static -static -static -static
      )
     
    (defun shrink-compile-window()
      "shrink compile window, avoid compile window occupy 1/2 hight of whole window"
      (interactive)
      ;;(select-window (get-buffer-window "*compilation*"))
      (setq compiled_buffer_name (buffer-name (current-buffer)))
      (switch-to-buffer-other-window "*compilation*")
      (if (< (/ (frame-height) 3) (window-height))
          (shrink-window (/ (window-height) 2)))
      (switch-to-buffer-other-window compiled_buffer_name)
      )
     
    (global-set-key [f9] '(lambda()
      "Save buffers and start compile"
      (interactive)
      (save-some-buffers t)
      (defineCompileCmd)
      (compile compile-command)
      (shrink-compile-window)
      )
    )
    
  3. 安装了一堆挺好用的插件以及进一步设置了Emacs

整个init.el在这里:http://paste.ubuntu.com/23881203/
大家按需配置吧!

Reference

  1. http://book.emacs-china.org/
  2. http://ppgunjack.iteye.com/blog/1190774
  3. http://tuhdo.github.io/c-ide.html

【Emacs】Emacs的安装

前言

最近下定决心要学习Emacs的使用
主要是用来代替Dev-cpp、使用Org-mode、以及编写Tex/Latex的文章

正文

首先是上GUN官方的FTP下载适合的版本:http://ftp.gnu.org/gnu/emacs/windows/
因为电脑是x64的系统,所以我下载的是emacs-25.1-2-i686-w64-mingw32.zip
下载好之后,直接解压到用来放置Emacs的文件夹里就好啦!
但因为Windows的原因所以我们需要多做以下两件事:

  1. 环境变量Path里添加~/bin文件夹的目录(使用cmd时需要)
  2. 环境变量Home里添加Emacs主文件夹的目录(这个想放在那里都行,就是用来放置Emacs的配置文件什么的)

然后运行~/bin里的addpm.exe来注册一些东西
然后就可以直接运行runemacs.exe或者在cmd里输入emacs -nw来运行Emacs辣!

之后我们安装两个必备的插件:Orgcompany
这个我们使用Emacs自己的package manager就可以啦!
具体来说:点击上方ToolBar里的Options
然后选择Manage Emacs packages
之后在这分别两个插件前面输入i、在下一行输入x,然后回车,再搞一波确认什么的就可以啦!
ps:如果要删除,就把i换成d就好

参考资料

  1. http://book.emacs-china.org/
  2. http://www.jianshu.com/p/b4cf683c25f3
  3. https://my.oschina.net/freeblues/blog/186079
  4. http://www.codelast.com/原创-emacs-on-windows初步实践/
  5. https://github.com/homeway/hotmoon_docs/blob/master/emacs.md
  6. https://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Location-of-init-file.html