首页 > 代码库 > Emacs第二话:更舒服的编辑

Emacs第二话:更舒服的编辑

<?xml version="1.0" encoding="utf-8"?> Emacs第二话:更舒服的编辑 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="generator" content="Org-mode" /> <meta name="author" content="sunznx" /> <meta name="keywords" content="emacs" /> <style type="text/css"> </style> <body>

Emacs第二话:更舒服的编辑

1 热身

用emacs,不用鼠标。额,不知道是谁说的,我浏览网页偶尔还是要用下鼠标的。
不过有 firemacs, mouseless, tab mix plus 的组合还是可以做到mouseless的。

首先,是光标移动速度要快,在linux上有xset,其次是要改 Esc为ctrl。如果你想舒服点就这么
做吧。

emacs启动太慢?

emacs --daemon

我的shrc中的alias

export EDITOR=‘emacsclient -c‘
alias e=‘emacsclient -c‘
alias emacs=‘emacs‘

emacs不能输入中文?

export LC_CTYPE=‘zh_CN.UTF-8‘

下面是我一个开机启动的脚本:

xset r rate 250 50              # Sane repeat rate
xset -b                         # No bell
xset -dpms                      # Keep screen on at all times
xset s off                      #
setxkbmap -option ctrl:nocaps
export LC_CTYPE=‘zh_CN.UTF-8‘   # 解决在emacs中输入中文
emacs --daemon

2 快速的编辑

首先需要学会安装package,怎么样require。应该会了吧。

(defun kill-region-or-backward-word ()
  (interactive)
  (if (region-active-p)
      (kill-region (region-beginning) (region-end))
    (backward-kill-word 1)))
(global-set-key (kdb "C-w") ‘kill-rectangle-or-backward-word)
(global-set-key (kbd "M-h") ‘kill-region-or-backward-word)


(defun smarter-move-beginning-of-line (arg)
  (interactive "^p")
  (setq arg (or arg 1))
  ;; Move lines first
  (when (/= arg 1)
    (let ((line-move-visual nil))
      (forward-line (1- arg))))
  (let ((orig-point (point)))
    (back-to-indentation)
    (when (= orig-point (point))
      (move-beginning-of-line 1))))
(global-set-key (kbd "C-a") ‘smarter-move-beginning-of-line)


;; Use shell-like backspace C-h, rebind help to F1
(define-key key-translation-map [?\C-h] [?\C-?])
(global-set-key (kbd "<f1>") ‘help-command)


(defun save-region-or-current-line (arg)
  (interactive "P")
  (if (region-active-p)
      (kill-ring-save (region-beginning) (region-end))
    (copy-line arg)))
(global-set-key (kbd "M-w") ‘save-region-or-current-line)

你还需要这个
windows-nubering

;;; window-numbering, use M-1 M-2 ... to quick switch window
(requirewindow-numbering)
(custom-set-faces ‘(window-numbering-face ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold)))))
(window-numbering-mode 1)

这个

(requirehungry-delete)
(global-hungry-delete-mode)

(requirepangu-spacing)
(global-pangu-spacing-mode 1)

还有这个

(requiremultiple-cursors)
(requireexpand-region)

具体的配置在他们的github上都有说。emacs就是这么容易配置。

3 org-mode 和coblogs 的插件

本文就是emacs下的org-mode写成。关于org-mode 來这里

在emacs下写完然后直接发布到博客园。具体的介绍 來这里 到这里下载 这里


Date: 2015-01-11 11:10:57

Author: sunznx

Created: 2015-01-11 Sun 12:04

Emacs 24.4.1 (Org mode 8.2.10)

Validate

Emacs第二话:更舒服的编辑