在emacs的配置文件(~./.emacs.d/init.el)文件裏添加以下內容:python
(add-to-list 'load-path "/usr/share/emacs/site-lisp")
(require 'linum)
(global-linum-mode t)linux
首先應該先檢查字體配置, 而後檢查是否開啓eamcs的xft的USE標示符.c++
安裝 font-cursor-misc 或 font-adobe-75dpi ,重啓計算機測試(好像大部分是由於缺乏這個語言包的問題)正則表達式
安裝:markdown
1). [ebuild N ] media-fonts/font-adobe-75dpi-1.0.0 USE="X nls" 0 kB 2). [ebuild N ] x11-apps/bdftopcf-1.0.2 USE="-debug" 0 kB 3). [ebuild N ] media-fonts/font-alias-1.0.1 USE="-debug" 0 kB 4). [ebuild N ] media-fonts/font-util-1.1.1 USE="-debug" 0 kB
(setq frame-title-format ("%S" (buffer-file-name "%f" (dired-directory dired-directory "%b"))))
app
(setq frame-title-format "XX@%b"),其中XX爲本身的電腦名,或本身可任意取名,甚至能夠不須要。ide
從 Emacs 24 開始,Emacs 對擴展包進行統一管理,極大程度上簡化了擴展包的搜索與安裝過程。打開 Emacs,而後執行 M-x list-packages ,若是網速足夠快,應該很快就能看到 Emacs 官方提供的擴展包列表。工具
待軟件包列表出現後,執行 C-s M-r ^ +company ,回車便可讓光標跳到 company 擴展包信息所在的文本行,繼而敲擊 i 鍵(表示要安裝該擴展包),再敲擊 x 鍵(表示執行安裝過程),稍等片刻,Emacs 會自動從下載 company 擴展包並安裝至 $HOME/.emacs.d 目錄。測試
提示:C-s 是開啓 Emacs 查找模式, M-r 是將查找模式切換爲正則表達式查找模式,而 C-s(ctrl +s) M-r(Alt + r) ^ + company 是用於匹配『位於行首且由多個空格與 company 字符串構成的字符串』的正則表達式。字體
若是之後要刪除 company 擴展,步驟與安裝步驟相似,只是將 i 鍵替換爲 d 鍵(表示刪除)。company 安裝完畢後,在 Emacs 配置文件中作如下配置:
;; 代碼補全
(add-hook 'c-mode-hook 'company-mode)
(add-hook 'c++-mode-hook 'company-mode)。
對於pcl的代碼提示功能,只須要安裝 company的關於C/C++的頭文件便可.(目前是這樣的)
在linux下,若emacs啓動較慢,可經過hostname查看本身主機的名字,而後打開/etc/hosts文件,將其中localhost改成本身主機名
;; 關閉啓動時的 「開機畫面」,將缺省主模式設爲 text-mode (setq inhibit-startup-message t) ;; 語法高亮 (global-font-lock-mode t) ;; 以y/n表明yes/no (fset 'yes-or-no-p 'y-or-n-p) ;; 顯示括號匹配 (show-paren-mode t) (setq show-paren-style 'parentheses) (transient-mark-mode t) ;; 在標題欄提示你目前在什麼位置 (setq frame-title-format "yxg@%b") ;;(setq frame-title-format '("%S" (buffer-file-name "%f" (dired-directory dired-directory "%b")))) ;; 默認顯示100列就換行 (setq default-fill-column 100) ;; 去掉工具欄 ;;(tool-bar-mode 0) ;; 去掉菜單欄 ;;(menu-bar-mode 0) (scroll-bar-mode 0) (tooltip-mode 0) ;; 顯示列號、行號 (setq column-number-mode t) (setq line-number-mode t) ;; 回車縮進 (global-set-key "\C-m" 'newline-and-indent) (global-set-key (kbd "C-<return>") 'newline) ;;(global-unset-key (kbd "C-SPC")) ;;(global-set-key (kbd "M-SPC") 'set-mark-command) ;;;; c mode ;;;; (defvar xgp-cfsi-left-PAREN-old nil "Command used to input \"(\"") (make-variable-buffer-local 'xgp-cfsi-left-PAREN-old) (defun xgp-cfsi-modify-alist (alist term new) (let ((tl (assq term (symbol-value alist)))) (if tl (setcdr tl new) (add-to-list alist (cons term new))))) (defun xgp-cfsi (style) "Deciding whether using CFSI." (interactive "Style: ") (c-set-style style) (setq indent-tabs-mode nil c-hanging-semi&comma-criteria (quote (c-semi&comma-inside-parenlist))) (xgp-cfsi-modify-alist 'c-hanging-braces-alist 'class-open nil) (xgp-cfsi-modify-alist 'c-hanging-braces-alist 'class-close nil) (local-set-key " " 'self-insert-command)) (defun xgp-cfsi-erase-blanks () "Erase all trivial blanks for CFSI." (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "[ \t]+$" nil t) (replace-match "" nil nil)))) (defun linux-c-mode() (define-key c-mode-map [return] 'newline-and-indent) (setq imenu-sort-function 'imenu--sort-by-name) (interactive) (imenu-add-menubar-index) (which-function-mode) (c-toggle-auto-state) (c-toggle-hungry-state) (setq indent-tabs-mode nil) (xgp-cfsi "linux")) (add-hook 'c-mode-common-hook 'linux-c-mode) ;; MELPA 擴展包倉庫 (when (>= emacs-major-version 24) (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) (package-initialize)) ;; 代碼補全 (add-hook 'c-mode-hook 'company-mode) (add-hook 'c++-mode-hook 'company-mode) ;;(eval-after-load 'company ;; '(add-to-list 'company-backends 'company-irony)) ;; 左側行號顯示 (add-to-list 'load-path "/usr/share/emacs/site-lisp") (require 'linum) (global-linum-mode t) (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. '(column-number-mode t) '(show-paren-mode t)) (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 (:family "Liberation Mono" :foundry "1ASC" :slant normal :weight normal :height 98 :width normal))))) ;;;;;;;;;;;;;;;;;;;;; for zero ;;;;;;;;;;;;;;;;;;;;;;;;;; (add-hook 'c-mode-hook (lambda () (font-lock-add-keywords nil '(("\\(@ *[^@# ]+ *#\\) *[;]*[ ]+" 1 font-lock-function-name-face t) ("^ *\\(@\\) *$" 1 font-lock-function-name-face t))))) (defun zero-quantum () (interactive) (insert "@ ") (insert " #\n\n@") (backward-char 5)) (define-prefix-command 'ctl-z-map) (global-set-key (kbd "C-z") 'ctl-z-map) (global-set-key (kbd "C-z c") 'c-mode) (global-set-key (kbd "C-z t") 'tex-mode) (global-set-key (kbd "C-z m") 'markdown-mode) (global-set-key (kbd "C-z q") 'zero-quantum)