GNU/Emacs

这本是我个人主页上用Emacs-wiki写的一篇关于Emacs的笔记,因为个人主页站点不能用了,现在转移到这里。不过 ,虽然我会做一些改变,但是还是没有Emacs-wiki发布的那么好!

什么是Emacs ? Emacs is the extensible, customizable, self-documenting real-time display editor. 简单的说, EMACS是一个以编辑器为主体的系统.它支持解析语言LISP,这就奠定了它的无限扩展的特性.你可以将任何希望做的事情以LISP写的插件方式,来扩展EMACS ,使其支持这一功能.由于它这种 与时代俱进 的设计思想和结构体系,让它在漫长的30 年中一直广为流行.它的作者Richard Stallman 还获得麦克阿瑟基金会24万美金的 天才奖 .

我总认为 一个好的软件不是以它的外在形式,而是以它的内在逻辑紧密的联系在一起. 当你不曾领会它的内在逻辑时,它那看似杂乱无章苦涩难懂的外表足以让你望而却步.但是,当你真正领会到它的精髓之际,你会幡然醒悟,突然发现什么才是真正的 方便, 智能自动化 ! 这是一个天才的天才发明.

GNU/Emacs能干什么?

在知道GNU/Emacs能做什么之前,先看看我用Emacs都做了些什么吧!我想没有人敢很明确的告诉你GNU/Emacs究竟能做什么,不能做什么.没有界限就是它的界限!

  • 看看这张图片,这是我用Emacs收发电子邮件.看到没有, 非常的方便.自动给你列出信件头(包括附件),选中你要查看的邮件,Emacs会自动给你另外分隔一个显示邮件主体的区域,并且标记了对方的发信端类型和附件类型.默认是以文本格式把附件显示在邮件主体后面,如果你看到的是一堆整齐的乱码,那么请按'.',你可以很轻易的保存,执行附件.当然,如果是发邮件,添加附件也是非常简单的.你可以把添加的命令绑定成你喜欢的快捷键.更详细的使用方法看Emacs Mew.
  • 再看看这张图片这是我用Emacs浏览网站. 你几乎不需要离开Emacs就能得到你想要的.当然,你或许会用其它的图形浏览器, 但是,如果你是用浏览器去找有用的资讯东西而不是去看一些华俏的东西打发时间的话,这玩意还是很不错的,快捷,简单!更多关于用Emacs浏览网页的请看这里 Emacs_W3m .
  • 这张图是Emacs做其本来职业的图片,你看它做的多好! 自动的分析函数,列出项目结构,记录最近编辑过的文档,自动在各函数间跳转......
  • 其实你无需去远方,一切都在你身旁......的确如此! If you want to Edit, Compile and Debug the files in the remote hoste, What did you do ? tall me please !其实,你无需登录到远方的服务器,在那个并不灵活的Terminal 中很机械的弄那些代码.你只需要稍微设置一下Emacs就足够了,一切就像在本地一样:一样的操作灵活,一样的反应快速,一样的赏心悦目......
  • 知道我这个文档是如何写成的吗?不是一条一条HTML语句凑成的.也不是用What see What get tools 一点一点修理出来的.我写这个网站上的任何文档的时候, 只需要关心我的内容就可以了,像写文章一样,其它的事情Emacs-wiki做好了,它自动生成了如此精美的网页.羡慕吧!看看这张图 .

如何使用GNU/Emacs ?

知道了GNU/Emacs能干个啥了,就让我们开始干点啥子吧.如果你的系统上还没有安装Emacs的话(这几乎不可能,如果我没有记错的话,Emacs是Linux系统默认安装的.)如果你用的是该死的Windows系统的话,请到这里看看Windows上的Emacs如何设置和使用.或者下载这个手册自己Have a look 一下!

基本操作

我是凭自己的使用习惯来写这个文档的.可能很多地方不太 标准 .不过,也无大碍,本来写给自己看的,我就是这么开始我的Emacs之旅的.呵呵!首先声明一下:C 是Ctrl健;M是Atl健(终端和MAC机上是Esc健.(声明完毕)  

按健作用
C-x C-f查找文件
C-x C-w文件另存
C-x C-s保存文件
C-x C-c退出Emacs
C-x C-h查看在线帮助
C-x u取消上一步操作

以上是最基本的操作,如果需要在Emacs中编辑文档,那么需要知道一下操作:

按健作用按键作用
C-v下滚一页M-v上滚一页
C-l本行居中C-k删除本行
C-f前移一字C-b后移一字
M-f前移一词M-b后移一词
C-n下移一行C-p上移一行
C-a跳到行首C-e跳到行尾
M-a跳到句首M-e跳到句尾
M-<光标到顶M->光标到底
M-w复制所选区域C-w剪切所选区域
C-s文中向后查找C-y粘贴缓冲区
C-@设置MarkM-g跳至指定行

其中,复制,剪切之前要用C-@设定Mark,然后用C-n,C-p或方向键选中要复制或剪切的区域,然后用C-w或M-w进行复制或剪切操作.至此,就完全可以用Emacs编辑文档了.

Emacs的配置

 ;; Red Hat Linux default .emacs initialization file  ; -*- mode: emacs-lisp -*-

;; Set up the keyboard so the delete key on both the regular keyboard
;; and the keypad delete the character under the cursor and to the right
;; under X, instead of the default, backspace behavior.
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)

;; turn on font-lock mode
(global-font-lock-mode t)
;; enable visual feedback on selections
(setq-default transient-mark-mode t)

;; always end a file with a newline
(setq require-final-newline t)

;; stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)

(when window-system
  ;; enable wheelmouse support by default
  (mwheel-install)
  ;; use extended compound-text coding for X clipboard
  (set-selection-coding-system 'compound-text-with-extensions))

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "Chinese-GB")
 '(default-input-method "chinese-py-punct")
 '(ecb-options-version "2.32")
 '(global-font-lock-mode t nil (font-lock))
 '(show-paren-mode t nil (paren))
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(transient-mark-mode t)
 '(uniquify-buffer-name-style (quote forward) nil (uniquify)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;这下面的是我自己设置的工作环境!           萧皓天
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq inhibit-startup-message t)
  (set-selection-coding-system 'cn-gb-2312)
  (setq inhibit-default-init t)
  (set-scroll-bar-mode nil)
  (setq default-tab-width 4)
  (auto-image-file-mode)
  (tool-bar-mode nil)
  (menu-bar-mode nil)
 
  (setq column-number-mode t)
  (setq kill-ring-max 200)
  (setq default-major-mode 'text-mode)
  (define-key c-mode-map [return] 'newline-and-indent)
  (c-toggle-auto-state)
  (c-toggle-hungry-state)

  (add-hook 'c-mode-hook
     '(lambda ()
 (c-set-style "k&r"))
  ;;set c++ style as stroustrup style
  (add-hook 'c++-mode-hook
     '(lambda()
 (c-set-style "stroustrup"))

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;显示时间和邮件提示.
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (display-time-mode 1)
  (setq display-time-24hr-format t)
  (setq display-time-day-and-date t)
  (setq display-time-use-mail-icon t)
  (setq display-time-interval 10)
 
  (add-hook 'c-mode-hook '(lambda () (c-set-style "k&r")))
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;一些高级设置,方便工作.                                          ;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (require 'wb-line-number) ;;显示行号,看代码的时候用最好.
  ;;(wb-line-number-toggle)
 
  (require 'ibuffer)
  (global-set-key (kbd "C-x C-b") 'ibuffer)

  (add-to-list 'load-path "/usr/share/emacs/21.2/eieio")
  (add-to-list 'load-path "/usr/share/emacs/21.2/semantic")
  (setq semantic-load-turn-everything-on t)
  (require 'semantic-load)
  (add-to-list 'load-path "/usr/share/emacs/21.2/speedbar")

  (add-to-list 'load-path "/usr/share/emacs/21.2/ecb")
  (require 'ecb)
  (setq ecb-auto-activate t
  ecb-tip-of-the-day nil
  inhibit-startup-message t
  ecb-auto-compatibility-check nil
  ecb-version-check nil)

  ;(require 'tabbar)
  ;(tabbar-mode)
  ;(global-set-key (kbd "") 'tabbar-backward-group)
  ;(global-set-key (kbd "") 'tabbar-forward-group)
  ;(global-set-key (kbd "") 'tabbar-backward)
  ;(global-set-key (kbd "") 'tabbar-forward)

  (require 'color-theme)
  ;;(color-theme-blue-mood)
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;          绑定一些自己的快捷键 .
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (global-set-key (kbd "M-z") 'color-theme-blue-sea)
  (global-set-key (kbd "M-g")  'goto-line)
  (global-set-key (kbd "M-2") 'wb-line-number-enable)
  (global-set-key (kbd "C-2") 'set-mark-command)
 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;                  以下是其它插件的功能扩展                      ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;                     在Emacs中收发邮件.                         ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mew")
  (autoload 'mew "mew" nil t)
  (autoload 'mew-send "mew" nil t)
  (setq mew-icon-directory "/usr/local/share/emacs/site-lisp/mew/etc")
  (setq mew-use-cached-passwd t)
  (setq mew-pop-size 0) ;; 没有限止邮件大小
  (setq mew-pop-delete nil)
  (setq mew-config-alist
     '(("default"
       ("name"         .  "Dragon")
       ("user"         .  "xiao_crazy")
       ("mail-domain"  .  "163.com")
       ("pop-server"   .  "pop3.163.com")
       ("pop-port"     .  "110")
       ("pop-user"     .  "xiao_crazy")
       ("pop-auth"     .  pass)
       ("smtp-server"  .  "smtp.163.com")
       ("smtp-port"    .  "25")
       ("smtp-user"    .  "xiao_crazy")
       ("smtp-auth-list"  .  ("LOGIN"  "PLAIN"  "CRAM-MD5")))))
  (when (boundp 'utf-translate-cjk)
        (setq utf-translate-cjk t)
        (custom-set-variables
           '(utf-translate-cjk t)))
  (if (fboundp 'utf-translate-cjk-mode)
      (utf-translate-cjk-mode 1))
  (require 'flyspell)
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;                      End of MEW in Emacs                         ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;                  在EMACS中浏览WEB网页并支持中文                  ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
  (require 'w3m-load)
  (setq w3m-display-inline-image t)
  (setq w3m-use-mule-ucs t)
  (setq w3m-use-toolbar t)
  (setq w3m-use-cookies t)
  (setq w3m-bookmark-file-coding-system 'chinese-iso-8bit)
  (setq w3m-coding-system 'chinese-iso-8bit)
  (setq w3m-default-coding-system 'chinese-iso-8bit)
  (setq w3m-file-coding-system 'chinese-iso-8bit)
  (setq w3m-file-name-coding-system 'chinese-iso-8bit)
  (setq w3m-terminal-coding-system 'chinese-iso-8bit)
  (setq w3m-input-coding-system 'chinese-iso-8bit)
  (setq w3m-output-coding-system 'chinese-iso-8bit)
  (setq w3m-tab-width 8)
  (setq w3m-home-page "http://www.gun.org")
  (setq w3m-view-this-url-new-session-in-background t)

  (add-hook 'w3m-fontify-after-hook 'remove-w3m-output-garbages)
  (defun remove-w3m-output-garbages()
    (interactive)
    (let ((buffer-read-only))
   (setf (point) (point-min))
   (while (re-search-forward "[/200-/240]" nil t)
     (replace-match " "))
   (set-buffer-multibyte t))
    (set-buffer-modified-p nil))

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;                  End of configure W3M in Emacs                    ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;        用EMACS 打开,编辑远程的文件,设定TELNET,FTP在EMACS中.       ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (add-to-list 'load-path "/usr/share/emacs/21.2/tramp/lisp")
  (setq tramp-unified-filenames t)
  (setq tramp-default-method "scp")
  (setq tramp-auto-save-directory "/tmp")
  (setq auto-save-file-name-transtorms
    '(("//~/[~/]*://(.+///)" "/tmp///2")))
  (setq tramp-chunksize 448)
  (setq ange-ftp-default-user t)
  (require 'ange-ftp)
  (require 'tramp)

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(require 'emacs-wiki)

(add-hook 'emacs-wiki-mode-hook
   (lambda ()
     (define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html)
     (define-key emacs-wiki-mode-map (kbd "C-c C-c") 'emacs-wiki-preview-source)
     (define-key emacs-wiki-mode-map (kbd "C-c C-v") 'emacs-wiki-change-project)

  ))

;; (setq emacs-wiki-grep-command "glimpse -nyi /"%W/"")

(setq emacs-wiki-publishing-directory "publish")

(setq emacs-wiki-meta-content-coding "gbk")
(setq emacs-wiki-directories '("~/WiKi"))
(setq emacs-wiki-meta-charset "gbk")
(setq emacs-wiki-style-sheet "<link rel='stylesheet' type='text/css' href='../css/main.css'>")

(setq emacs-wiki-inline-relative-to 'emacs-wiki-publishing-directory)

(defun emacs-wiki-preview-source ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (find-file (emacs-wiki-published-file)))

(defun emacs-wiki-preview-html ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (browse-url (emacs-wiki-published-file)))

(setq emacs-wiki-projects
      `(("default" . ((emacs-wiki-directories . ("~/WiKi"))))
        ("work" . ((fill-column . 65)
                 (emacs-wiki-directories . ("~/workwiki/"))))))

(require 'emacs-wiki-menu)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun my-emacs-wiki-chmod-644-published-file (file)
  (let* ((page (emacs-wiki-page-name file))
         (published (emacs-wiki-published-file page)))
         (shell-command (concat "chmod 644 " published))))

(add-hook 'emacs-wiki-after-file-publish-hook
          'my-emacs-wiki-chmod-644-published-file)

GNU/Emacs资源列表

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值