免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: flw
打印 上一主题 下一主题

有关 Emacs 使用技巧的内容请在这个帖子讨论。 [复制链接]

论坛徽章:
0
271 [报告]
发表于 2006-01-23 14:25 |只看该作者

我的.emacs和贴图


  1. ;; .emacs initialization file
  2. ; -*- mode: emacs-lisp -*-

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

  8. ;; turn on font-lock mode
  9. (global-font-lock-mode t)
  10. ;; enable visual feedback on selections
  11. (setq-default transient-mark-mode t)

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

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

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



  21. (defun recentf-open-files-compl ()
  22.   (interactive)
  23.   (let* ((all-files recentf-list)
  24.          (tocpl (mapcar (function
  25.                          (lambda (x) (cons (file-name-nondirectory x) x))) all-files))
  26.          (prompt (append '("File name: ") tocpl))
  27.          (fname (completing-read (car prompt) (cdr prompt) nil nil)))
  28.     (find-file (cdr (assoc-ignore-representation fname tocpl)))))

  29. (global-set-key [(control x)(control r)] 'recentf-open-files-compl)


  30. ;; 让sentence-end可以识别全角的标点符号
  31. (setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
  32. (setq sentence-end-double-space nil)

  33. (load "desktop")
  34. (desktop-load-default)
  35. (desktop-read)

  36. ;;打开文件和转换 buffer 的方便模式。
  37. ;;在Win下这个东西不爽,不能切换盘符
  38. (require 'ido)
  39. (ido-mode t)

  40. (require 'color-theme)
  41. (color-theme-gnome2)

  42. (autoload 'table-insert "table" "WYGIWYS table editor")

  43. (require 'tabbar)
  44. (tabbar-mode)
  45. (global-set-key (kbd "") 'tabbar-backward-group)
  46. (global-set-key (kbd "") 'tabbar-forward-group)
  47. (global-set-key (kbd "") 'tabbar-backward)
  48. (global-set-key (kbd "") 'tabbar-forward)


  49. (require 'swbuff)
  50. (global-set-key (kbd "") 'swbuff-switch-to-previous-buffer)
  51. (global-set-key (kbd "") 'swbuff-switch-to-next-buffer)
  52. (setq swbuff-exclude-buffer-regexps
  53.      '("^ " "\\*.*\\*"))

  54. (setq swbuff-status-window-layout 'scroll)
  55. (setq swbuff-clear-delay 1)
  56. (setq swbuff-separator "|")
  57. (setq swbuff-window-min-text-height 1)


  58. (require 'browse-kill-ring)
  59. (global-set-key [(control c)(k)] 'browse-kill-ring)
  60. (browse-kill-ring-default-keybindings)


  61. (require 'ibuffer)
  62. (global-set-key (kbd "C-x C-b") 'ibuffer)

  63. ;; copy lines
  64. (defun copy-lines(&optional arg)
  65.   (interactive "p")
  66.   (save-excursion
  67.     (beginning-of-line)
  68.     (set-mark (point))
  69.     (if arg
  70.         (next-line (- arg 1)))
  71.     (end-of-line)
  72.     (kill-ring-save (mark) (point))))
  73. ;; set key
  74. (global-set-key (kbd "C-c w") 'copy-lines)



  75. ;; Load CEDET
  76. (load-file "C:/emacs/cedet-1.0pre3/common/cedet.el")

  77. (add-to-list 'load-path "C:/emacs/ecb-2.32/")
  78. (require 'ecb-autoloads)

  79. ;; Enabling various SEMANTIC minor modes.  See semantic/INSTALL for more ideas.
  80. ;; Select one of the following
  81. (semantic-load-enable-code-helpers)
  82. ;; (semantic-load-enable-guady-code-helpers)
  83. ;; (semantic-load-enable-excessive-code-helpers)

  84. ;; Enable this if you develop in semantic, or develop grammars
  85. ;; (semantic-load-enable-semantic-debugging-helpers)
  86. (custom-set-variables
  87.   ;; custom-set-variables was added by Custom.
  88.   ;; If you edit it by hand, you could mess it up, so be careful.
  89.   ;; Your init file should contain only one such instance.
  90.   ;; If there is more than one, they won't work right.
  91. '(column-number-mode t)
  92. '(cua-mode nil)
  93. '(ecb-auto-activate t)
  94. '(ecb-gzip-setup (quote ("c:\\emacs\\bin\\gzip.exe" . windows)))
  95. '(ecb-options-version "2.32")
  96. '(ecb-other-window-behavior (quote all))
  97. '(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
  98. '(ecb-source-path (quote ("D:/")))
  99. '(ecb-tar-setup (quote ("c:\\emacs\\bin\\tar.exe" . windows)))
  100. '(ecb-wget-setup (quote ("c:\\emacs\\bin\\wget.exe" . windows)))
  101. '(ecb-windows-width 0.2)
  102. '(global-font-lock-mode t nil (font-core))
  103. '(hscroll-margin 0)
  104. '(show-paren-mode t nil (paren))
  105. '(transient-mark-mode t))
  106. (custom-set-faces
  107.   ;; custom-set-faces was added by Custom.
  108.   ;; If you edit it by hand, you could mess it up, so be careful.
  109.   ;; Your init file should contain only one such instance.
  110.   ;; If there is more than one, they won't work right.
  111. )

  112. (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
  113. ;(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
  114. ;(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
  115. ;;禁用启动信息
  116. (setq inhibit-startup-message t)

  117. ;;关闭烦人的出错时的提示声
  118. (setq visible-bell t)

  119. ;;把title设置为“文件名@LC's Emacs"
  120. (setq frame-title-format
  121.         '("GNU Emacs[ " (buffer-file-name "%f \]"
  122.                 (dired-directory dired-directory "%b \]"))))

  123. ;;光标靠近鼠标的时候,让鼠标自动让开,别挡住视线
  124. (mouse-avoidance-mode 'animate)

  125. ;;下面的这个设置可以让光标指到某个括号的时候显示与它匹配的括号
  126. (show-paren-mode t)
  127. (setq show-paren-style 'parentheses)

  128. ;;设置缺省模式是text,而不是基本模式
  129. ;(setq default-major-mode 'text-mode)
  130. ;(add-hook 'text-mode-hook 'turn-on-auto-fill)

  131. ;;打开文本的默认格式为gb2312-dos
  132. ;(setq inhibit-eol-conversion 'gb2312-dos)

  133. ;;设置tab为4个空格的宽度,而不是原来的2
  134. ;(setq default-tab-width 4)

  135. ;;防止页面滚动时跳动
  136. (setq scroll-margin 3
  137.       scroll-conservatively 10000)

  138. ;; 所有的备份文件转移到~/backups目录下
  139. (setq backup-directory-alist (quote (("." . "~/backups"))))
  140. (setq version-control t)
  141. (setq kept-old-versions 2)
  142. (setq kept-new-versions 5)
  143. (setq delete-old-versions t)
  144. (setq backup-directory-alist '(("." . "~/backups")))
  145. (setq backup-by-copying t)
  146. ;; Emacs 中,改变文件时,默认都会产生备份文件(以 ~ 结尾的文件)。可以完全去掉
  147. ;; (并不可取),也可以制定备份的方式。这里采用的是,把所有的文件备份都放在一
  148. ;; 个固定的地方("~/var/tmp")。对于每个备份文件,保留最原始的两个版本和最新的
  149. ;; 五个版本。并且备份的时候,备份文件是复本,而不是原件。

  150. ;;不产生备份文件
  151. ;(setq make-backup-files nil)

  152. ;;设置kill-ring-max(我不知道怎么翻译这个词:)为200,以防不测:)
  153. (setq kill-ring-max 200)

  154. ;; 当有两个文件名相同的缓冲时,使用前缀的目录名做 buffer 名字,不用原来的
  155. ;; foobar<?> 形式。
  156. (setq uniquify-buffer-name-style 'forward)

  157. ;;显示日期
  158. (setq display-time-day-and-date t)
  159. (display-time)

  160. ;;显示时间
  161. (setq display-time-24hr-format t)
  162. (setq display-time-day-and-date t)
  163. (setq display-time-use-mail-icon t)
  164. (setq display-time-interval 10)

  165. ;; 设置时间戳,标识出最后一次保存文件的时间。
  166. (setq time-stamp-active t)
  167. (setq time-stamp-warn-inactive t)
  168. (setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S K.T")

  169. ;; 默认的日记文件
  170. ;(setq diary-file "~/diary/rj")

  171. ;; 设置所在地的经纬度和地名,calendar 可以根据这些信息告知你每天的日出和日落
  172. ;; 的时间。
  173. (setq calendar-latitude +45.75)
  174. (setq calendar-longitude +126.63)
  175. (setq calendar-location-name "Harbin")

  176. ;;保存上次的操作记录到SESSION
  177. (add-to-list 'load-path "~/tmp")
  178. (require 'session)
  179. (add-hook 'after-init-hook 'session-initialize)

  180. (load "desktop")
  181. (desktop-load-default)
  182. (desktop-read)

  183. ;;设置默认工作目录
  184. (setq default-directory "D:/")

  185. ;;显示列号
  186. (setq column-number-mode t)

  187. ;设置默认的列数是110
  188. (setq default-fill-column 168)

  189. ;;设置行号,开启命令:M-x setnu-mode
  190. ;(require 'setnu)

  191. ;;'y' for 'yes', 'n' for 'no'
  192. (fset 'yes-or-no-p 'y-or-n-p)

  193. ;; 代码折叠
  194. (load-library "hideshow")
  195. (add-hook 'java-mode-hook 'hs-minor-mode)
  196. (add-hook 'perl-mode-hook 'hs-minor-mode)
  197. (add-hook 'php-mode-hook 'hs-minor-mode)
  198. (add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)

  199. ;;开启图片浏览
  200. (require 'thumbs)
  201. (auto-image-file-mode t)

  202. ;; 如果设置为 t,光标在 TAB 字符上会显示为一个大方块 :)。
  203. (setq x-stretch-cursor nil)

  204. ;;语法高亮,除 shell-mode 和 text-mode 之外的模式中使用语法高亮
  205. ;;可是打开后PHP不高亮了,-_-!
  206. ;(setq font-lock-maximum-decoration t)
  207. ;(setq font-lock-global-modes '(not shell-mode text-mode))
  208. ;(setq font-lock-verbose t)
  209. ;(setq font-lock-maximum-size
  210. ;       '((t . 1048576) (vm-mode . 5250000)))

  211. ;;打开压缩文件时自动解压缩。
  212. ;(auto-compression-mode 1)                             

  213. ;;光标不要闪烁。
  214. ;(blink-cursor-mode -1)

  215. ;;高亮显示匹配的括号。
  216. (show-paren-mode 1)

  217. ;;给出用 M-x foo-bar-COMMAND 输入命令的提示。
  218. ;(icomplete-mode 1)


  219. ;;SET KEY
  220. (global-set-key "\C-xk" 'kill-this-buffer)
  221. (global-set-key "\C-xr" 'replace-string)
  222. (global-set-key "\C-xt" 'insert-now-time);把插入当前时间绑定到 C-x t

  223. ;; 打开文件的时候过滤掉[^M] 键盘上输入为[C-q-m] 或者
  224. ;; C-x <RET> r gb2312-dos 或者
  225. ;; C-x <RET> r gb2312-unix 或者
  226. ;; 运行下面的函数
  227. (defun remove-trailing-ctrl-m ()
  228.         (interactive)
  229.         (goto-char (point-min))
  230.         (while (search-forward-regexp "
  231.         " nil t)
  232.         (replace-match "" nil t)))


  233. ;;导出成html高亮显示
  234. ;(require 'htmlize)

  235. (autoload 'php-mode "php-mode" "PHP editing mode" t)
  236. (add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
  237. (autoload 'css-mode "css-mode" "CSS editing mode" t)
  238. (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
复制代码

[ 本帖最后由 jerryfleming 于 2006-1-23 14:30 编辑 ]

snap001.jpg (68.87 KB, 下载次数: 67)

效果图

效果图

论坛徽章:
0
272 [报告]
发表于 2006-01-25 22:55 |只看该作者

My .emacs file



  1. (custom-set-variables
  2.   ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  3.   ;; Your init file should contain only one such instance.
  4. '(auto-insert-mode t nil (autoinsert))
  5. '(auto-show-mode t t)
  6. '(c++-mode-hook nil)
  7. '(c-indent-comments-syntactically-p t)
  8. '(c-tab-always-indent t)
  9. '(case-fold-search t)
  10. '(column-number-mode t)
  11. '(cpp-known-writable t)
  12. '(current-language-environment "Chinese-GB")
  13. '(default-input-method "chinese-wbx-gb")
  14. '(dired-recursive-copies t)
  15. '(facemenu-add-face-function nil)
  16. '(facemenu-keybindings (quote ((default . "d") (bold . "b") (italic . "i") (bold-italic . "l") (underline . "u") (Overline . "v") (Box . "x"))))
  17. '(facemenu-new-faces-at-end t)
  18. '(facemenu-unlisted-faces (quote (modeline region secondary-selection highlight scratch-face "^font-lock-" "^gnus-" "^message-" "^ediff-" "^term-" "^vc-" "^widget-" "^custom-" "^vm-")))
  19. '(global-font-lock-mode t nil (font-lock))
  20. '(global-hl-line-mode t nil (hl-line))
  21. '(hl-line-face (quote highlight))
  22. '(html-mode-hook (quote (html-autoview-mode)))
  23. '(java-mode-hook nil)
  24. '(mark-holidays-in-calendar t)
  25. '(nxml-attribute-indent 8)
  26. '(nxml-auto-insert-xml-declaration-flag t)
  27. '(nxml-child-indent 4)
  28. '(nxml-outline-child-indent 4)
  29. '(nxml-prefer-utf-16-to-utf-8-flag nil)
  30. '(nxml-sexp-element-flag t)
  31. '(nxml-slash-auto-complete-flag t)
  32. '(php-mode-force-pear t)
  33. '(php-mode-speedbar-open nil)
  34. '(php-speedbar-config nil)
  35. '(sgml-mode-hook nil)
  36. '(sgml-name-8bit-mode t)
  37. '(sgml-slash-distance 2000)
  38. '(show-paren-mode t nil (paren))
  39. '(standard-indent 8)
  40. '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
  41. '(transient-mark-mode t))
  42. (custom-set-faces
  43.   ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  44.   ;; Your init file should contain only one such instance.
  45. '(highlight ((((class color) (background light)) (:background "lightgreen" :foreground "black" :underline t))))
  46. '(nxml-heading-face ((t (:background "lightgreen" :foreground "blue" :weight bold :height unspecified))))
  47. '(rng-error-face ((t (:underline "red")))))
  48. ;;the setnu.el used in the source code viewing the lines
  49. (require 'setnu)
  50. (setnu-mode t)
  51. (setq appt-issue-message t)
  52. (setq display-time-24hr-format t)
  53. (setq display-time-day-and-date t)
  54. (display-time)

  55. ;;the xref tools can be use viewing and compile editing the java source code forlearning the source code
  56. (setq exec-path (cons "d:/apptools/xref" exec-path))
  57. (setq load-path (cons "d:/apptools/xref/emacs" load-path))
  58. (load "xrefactory")

  59. ;;erc-pcomlete mode
  60. (add-hook 'erc-mode-hook
  61.               '(lambda ()
  62.                (require 'erc-pcomplete)
  63.                   (pcomplete-erc-setup)
  64.                  (erc-completion-mode 1)))
  65. (put 'downcase-region 'disabled nil)

  66. ;;php-mode use
  67. (require 'php-mode)
  68. (add-hook 'php-mode-user-hook 'turn-on-font-lock)
  69. (add-hook 'php-mode-user-hook
  70.           '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends")))


  71. ;; emacs all.el use
  72. (autoload 'all "all" nil t)

  73. ;; emacs flyspell-1.7e.el use
  74. (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checking" t)
  75. (autoload 'global-flyspell-mode "flyspell" "On-the-fly spelling" t)

  76. ;; emacs template use
  77. (setq load-path (cons (expand-file-name "d:/apptools/emacs-21.3/site-lisp")
  78.                       load-path))
  79. (require 'template)
  80. (template-initialize)

  81. ;; emacs wb-line-number.el use:
  82. (set-scroll-bar-mode nil)   ; no scroll bar, even in x-window system
  83. (require 'wb-line-number)

  84. ;; emacs gnuserv.el usage:
  85. (require 'gnuserv)
  86. (gnuserv-start)

  87. ;; emacs psgml setup
  88. (setq load-path (append (list nil "d:/apptools/emacs-21.3/site-lisp/psgml-1.2.5") load-path))
  89. ;; use PSGML for sgml and xml major modes.
  90. (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
  91. (autoload 'xml-mode "psgml" "Major mode to edit XML files." t)

  92. ;; emacs nxml-mode use:
  93. (load "d:/apptools/emacs-21.3/site-lisp/nxml-mode-20041004/rng-auto.el") ;; get things automatically loaded each time when starting emacs
  94. ;; with an extension of xml, xsl, rng or xhtml in all nxml-mode files in automatically uses:
  95. (setq auto-mode-alist
  96.         (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
  97.               auto-mode-alist))

  98. ;; emacs html-helper-mode use:
  99. (setq load-path (cons "d:/apptools/emacs-21.3/site-lisp/html-helper-mode.el " load-path))
  100. (autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
  101. (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
  102. (setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))

  103. ;; emacs session use:
  104. (require 'session)
  105. (add-hook 'after-init-hook 'session-initialize)

  106. ;; emacs ispell use:
  107. (setq-default ispell-program-name "aspell")
  108.     (setq-default ispell-local-dictionary "american")
  109.     (global-set-key (kbd "") 'ispell-complete-word)

  110. ;; emacs python-mode use:
  111. (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
  112. (setq interpreter-mode-alist (cons '("python" . python-mode)
  113.                                    interpreter-mode-alist))
  114. (autoload 'python-mode "python-mode" "Python editing mode." t)

  115. ;; emads pymacs used in Win32:
  116. (autoload ' pymacs-load "pymacs" nil t)
  117. (autoload ' pymacs-eval "pymacs" nil t)
  118. (autoload ' pymacs-apply "pymacs")
  119. ;;(autoload ' pymacs-call "pymacs")
  120. (eval-after-load "pymacs"
  121. ' (add-to-list ' pymacs-load-path "d:/apptools/emacs-21.3/site-lisp/Pymacs-0.22"))

  122. ;; emacs generic mode use:
  123. (require ' generic)
  124. (require ' generic-x)

  125. ;; emacs dired-signle mode use:
  126. (require 'dired-single)
复制代码

论坛徽章:
0
273 [报告]
发表于 2006-02-05 10:43 |只看该作者

请问谁有tab-display.el共享一下,网上的下不了

如题,谢谢

论坛徽章:
0
274 [报告]
发表于 2006-02-08 18:13 |只看该作者
原帖由 jerryfleming 于 2006-2-5 10:43 发表
如题,谢谢


http://www.damtp.cam.ac.uk/user/sje30/emacs/ell.html#t

论坛徽章:
12
辰龙
日期:2013-10-23 11:06:312015年迎新春徽章
日期:2015-03-04 09:50:28拜羊年徽章
日期:2015-03-03 16:15:43戌狗
日期:2014-12-22 14:49:17申猴
日期:2014-05-14 17:25:17狮子座
日期:2014-04-26 18:50:20双子座
日期:2014-04-04 12:32:31巨蟹座
日期:2014-03-13 00:04:36技术图书徽章
日期:2014-03-12 17:50:42白羊座
日期:2014-02-28 23:46:54丑牛
日期:2013-11-15 05:36:11CU十四周年纪念徽章
日期:2016-01-18 04:54:01
275 [报告]
发表于 2006-02-10 12:27 |只看该作者
原帖由 dozec 于 2005-8-24 20:26 发表
问一个憋脚问题:Emacs英文怎么读,是读/i'meks/嘛?
呵呵,问这种问题有点丢人~~~


不丢人,大家都是有这个过程


  1. /'i:m ae  ks/
  2.        ---            
  3.         ^
  4.          |
  5.       元音   单词“胖的”-fat, 那个字母a的发音
复制代码

[ 本帖最后由 kunson 于 2006-2-10 12:30 编辑 ]

论坛徽章:
0
276 [报告]
发表于 2006-02-14 20:02 |只看该作者
我在xp下面下载了 Emacs for Windows 的版本

问:怎样在windows下编译hello world啊。

怎样gcc 怎样make啊

上火

论坛徽章:
0
277 [报告]
发表于 2006-02-14 20:52 |只看该作者
我想在XP下学emacs,一点emacs知识都没有,有哪位好心人给我点资料,
给最白痴的看的那种,还点是中文的,谢谢
一下午了,连个hello world的编译都没调出来。

上火啊!

论坛徽章:
0
278 [报告]
发表于 2006-02-17 08:08 |只看该作者
原帖由 satan212 于 2006-2-14 04:52 发表
我想在XP下学emacs,一点emacs知识都没有,有哪位好心人给我点资料,
给最白痴的看的那种,还点是中文的,谢谢
一下午了,连个hello world的编译都没调出来。

上火啊!


emacs是文本编辑器,不是编译器。我们能够在emacs里面方便的调用外部编译器,但是你装了吗?

论坛徽章:
0
279 [报告]
发表于 2006-02-17 10:35 |只看该作者
不如改学 Lisp

论坛徽章:
0
280 [报告]
发表于 2006-02-18 21:35 |只看该作者

有哪位在emacs中设置过emacs face呀?


RT。 我在我自己的NTEMACS中根据说明设置了一个emacs face,但在重新启动时,无法正常使用。有什么方法能让它正常使用呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP