Emacs安装配置

本文介绍如何在 Emacs 中高效编程,包括快捷键、安装软件包、配置文件及常见问题解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

快捷键

切换缓冲区: C-X B
关闭窗口/缓冲区: C-X K
打开shell/eshell: M-X shell/eshell
新建表格:M-X table-insert
查看当前字体: M-X describe-font
放大字体:C-X C-+
使配置文件立即生效(打开.emacs的情况下): M-X eval-buffer
重新从硬盘上载入文件:M-X revert-buffer
GDB: M-X gdb
命令
安装软件包:M-X el-get-install

el-get的安装

切换至scratch缓冲区,输入以下代码,按C-J,

(url-retrieve
https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el
(lambda (s)
(end-of-buffer)
(eval-print-last-sexp)))

详细参见:https://github.com/dimitri/el-get

常用包的安装

sudo apt-get install:
- bzr
M-X el-get-install:
- color-theme
- color-theme-almost-monokai
- tabbar
- cedet
- ecb (http://www.cnblogs.com/wangkangluo1/archive/2011/07/25/2116306.html)
- bazaar
- emacs-for-python:https://github.com/gabrielelanaro/emacs-for-python

常见问题

配置过程

安装el-get
配置el-get, 具体见https://github.com/dimitri/el-get
通过el-get下载需要用到的软件包

配置文件


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;el-get
;;(add-to-list 'load-path "~/.emacs.d/el-get/el-get")


;;(unless (require 'el-get nil 'noerror)
 ;; (with-current-buffer
   ;;   (url-retrieve-synchronously
     ;;  "https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
    ;;(goto-char (point-max))
    ;;(eval-print-last-sexp)))

;;(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes")
;;(el-get 'sync)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/el-get/bazaar")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;color theme

(add-to-list 'load-path "~/.emacs.d/el-get/color-theme")
(require 'color-theme)

(add-to-list 'load-path "~/.emacs.d/el-get/color-theme-solarized")
(require 'color-theme-solarized)
(color-theme-solarized)

(add-to-list 'load-path "~/.emacs.d/el-get/color-theme-almost-monokai")
(require 'color-theme-almost-monokai)
;;(color-theme-calm-forest)
;;(color-theme-almost-monokai)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;set font and make table a good look
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :pixelsize 13 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))

(if (and (fboundp 'daemonp) (daemonp))
    (add-hook 'after-make-frame-functions
              (lambda (frame)
                (with-selected-frame frame
                  (set-fontset-font "fontset-default" 'chinese-gbk "WenQuanYi Micro Hei Mono 12"))))
  (set-fontset-font "fontset-default" 'chinese-gbk "WenQuanYi Micro Hei Mono 12"))

(defun wl-org-column-view-uses-fixed-width-face ()
  ;; copy from org-faces.el
  (when (fboundp 'set-face-attribute)
    ;; Make sure that a fixed-width face is used when we have a column table.
    (set-face-attribute 'org-column nil
                        :height (face-attribute 'default :height)
                        :family (face-attribute 'default :family))))

(when (and (fboundp 'daemonp) (daemonp))
  (add-hook 'org-mode-hook 'wl-org-column-view-uses-fixed-width-face))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;cedet
;;cedet if you use 1.1 the version check will turn out to be error
(load-file "~/.emacs.d/cedet-1.1/common/cedet.el")   
(global-ede-mode 1)

;;(semantic-load-enable-gaudy-code-helpers)
;;这一行打开会使得tabbar在某些buffer不可见,原因未知

(global-srecode-minor-mode 1)

;;ecb
;;;;ecb
(add-to-list 'load-path "~/.emacs.d/ecb-2.40")    ;你的ecb解压目录
(require 'ecb)
(require 'ecb-autoloads)



(global-set-key (kbd "<f7>") 'ecb-minor-mode)   ; 打开ejb

;;;;ejb 快捷键
(global-set-key (kbd "C-M-<left>") 'windmove-left)   ;左边窗口
(global-set-key (kbd "C-M-<right>") 'windmove-right)  ;右边窗口
(global-set-key (kbd "C-M-<up>") 'windmove-up)     ; 上边窗口
(global-set-key (kbd "C-M-<down>") 'windmove-down)   ; 下边窗口

;;ecb error
(setq stack-trace-on-error t)

;; 自动启动ecb,关闭每日提示
;;(setq ecb-auto-activate t ecb-tip-of-the-day nil)

;; 设置窗口的宽度,15%
(setq ecb-windows-width 0.2)

;; 在目录窗口显示文件
(setq ecb-show-sources-in-directories-buffer 'always)

   ;;(setq ecb-compile-window-height 12)
   ;;(setq ecb-show-sources-in-directories-buffer 'always)

(setq ecb-layout-name 'left15)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;tabbar
(add-to-list 'load-path "~/.emacs.d/el-get/tabbar")
(require 'tabbar)
(tabbar-mode)

;;set tabbar <- -> keys    
(global-set-key [(meta j)] 'tabbar-backward)  
(global-set-key [(meta k)] 'tabbar-forward)  

;;set main&misc group

;;tabbar -- release that if you do not show *buffername*
;;(setq tabbar-buffer-list-function
;;    (lambda ()
;;       (remove-if
;;          (lambda(buffer)
;;             (find (aref (buffer-name buffer) 0) " *"))
;;          (buffer-list))))
(setq tabbar-buffer-groups-function
      (lambda()(list "All")))
(set-face-attribute 'tabbar-button nil)

;;color-theme-solarized的tabbar配色和其他的不太一样,似乎是反过来的,需要注意
;;set tabbar's backgroud color
(set-face-attribute 'tabbar-default nil
            :family "DejaVu Sans Mono"
                    :background "gray"
                    :foreground "gray")
(set-face-attribute 'tabbar-selected nil
            :family "DejaVu Sans Mono"
                    :inherit 'tabbar-default
            :foreground "#00CD66"
                    :background "black"
                    :box '(:line-width 2 :color "#00CD66") 
            )
(set-face-attribute 'tabbar-unselected nil
            :family "DejaVu Sans Mono"
                    :inherit 'tabbar-default
            :foreground "gray"
            :background "black"
                    :box '(:line-width 3 :color "gray")
            )

;; USEFUL: set tabbar's separator gap && no tool bar no tool tip
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ecb-layout-name "left15")
 '(ecb-options-version "2.40")
 '(scroll-bar-mode nil)
 '(tabbar-separator (quote (1.5)))
 '(tool-bar-mode nil)
 '(tooltip-mode nil))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;python-all
(load-file "~/.emacs.d/emacs-for-python-master/epy-init.el")
(require 'epy-setup)      ;; It will setup other loads, it is required!
(require 'epy-python)     ;; If you want the python facilities [optional]
(require 'epy-completion) ;; If you want the autocompletion settings [optional]
(require 'epy-editing)    ;; For configurations related to editing [optional]
(require 'epy-bindings)   ;; For my suggested keybindings [optional]
(require 'epy-nose)       ;; For nose integration

(epy-setup-checker "pyflakes %f")

;;(epy-django-snippets)

(epy-setup-ipython)

(require 'highlight-indentation)
(add-hook 'python-mode-hook 'highlight-indentation)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; tmp & backup file manage

;; all backups goto ~/.backups instead in the current directory
(setq backup-directory-alist (quote (("." . "~/.backups"))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;set full screen
;;(custom-set-variables
;; '(initial-frame-alist (quote ((fullscreen . maximized)))))
### Emacs 安装教程 对于Linux环境下的Emacs安装,可以采用源码编译的方式进行。例如,在命令行输入`sudo make install`能够完成从源码到系统的安装过程[^1]。 #### 下载并解压源文件 首先需要下载Emacs的源代码压缩包,并将其解压至指定位置。这一步骤通常通过wget或curl工具来实现网络资源获取,接着利用tar命令来进行解压缩操作。 #### 编译前准备 进入解压后的目录之后,执行配置脚本configure以设置编译参数。此阶段可能涉及到调整一些选项以便适应不同的操作系统特性或是个人偏好设定。 #### 执行编译与安装 当一切就绪后便可以通过make指令启动GNU Make程序开始构建工作;而最终借助于带有root权限的`sudo make install`命令把生成好的二进制文件复制到系统路径下从而结束整个流程。 ### 配置方法 Doom Emacs作为一个高度模块化的框架提供了便捷高效的初始化方式。其官方仓库位于特定网址上,这里包含了详细的文档说明以及社区维护的支持材料[^2]。 #### 获取预设布局 访问doomemacs项目的页面链接,按照指引克隆远程Git库到本地机器中形成基础的工作空间。该动作会自动建立必要的子模块并且同步最新的变更记录。 #### 自定义扩展功能 为了增加额外的功能组件,比如微博插件,可以在`.emacs.d/init.el`或者其他适当的位置加入如下Elisp语句片段: ```elisp (add-to-list 'load-path "~/.emacs.d/lisp/austin------weibo.emacs-751a8e2") (require 'weibo) ``` 上述代码的作用在于向加载列表添加自定义Lisp表达式的存储地点,并尝试引入名为weibo的外部库[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值