xrzs / 编辑器 / windows下的emacs23配置 - Emacs - 晋如,...

0 0

   

windows下的emacs23配置 - Emacs - 晋如,摧如

2010-03-26  xrzs
windows下的emacs23配置
很少用windows,所以就一直没在上面装emacs,昨天偶尔在brep的主页上面看到了emacs23 for windows的下载,就抽空弄了下,在此特地感谢brep。

具体配置不麻烦,解压,从ubuntu下把pager.el, sgml-mode.elc(原带的有问题,总提示Wrong type argument: symbolp)拷过来,再下载emacs-wiki-2.72解压在site-lisp下(wiki-2.71在此有问题,也提示Wrong type argument: symbolp错误)

然后设置一下注册表,将以下内容保存为emacs.reg并执行即可(注意改最后一行的地址)

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs]
"Emacs.Background"="Black"
"Emacs.Foreground"="Green"
"Emacs.ScrollBars"="ON"
"Emacs.ToolBar"="OFF"

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Emacs\command]
@="D:\\Emacs\\bin\\emacsclientw.exe -a \"D:/Emacs/bin/runemacs.exe\" \"%1\""

最后一段是在右键菜单中加入一个用emacs编辑的项,此时我们一般希望用已打开的emacs编辑,而不是另外启动一个emacs(毕竟这东西个头不小),这就要在_emacs中加入(server-start)

最后就是_emacs文件了,记得以前的~/目录就是C:,现在变成了c:/Documents and Settings/Wheer/Application Data,其中Wheer应该改成你的名字,将_emacs放在底下就好了

以下是我的_emacs文件

;;快捷键
(global-set-key [?\S- ] 'set-mark-command)
(global-set-key [f1] 'bookmark-jump)
(global-set-key [f2] 'calendar)
(global-unset-key (quote [f3]))
(global-set-key [f3] 'undo)
(global-set-key [f4] 'todo-show)
(global-set-key [C-f4] 'kill-this-buffer)
(global-set-key [M-f4] 'save-buffers-kill-emacs)
(global-set-key [f5] 'emacs-wiki-find-file)
(global-set-key [f6] 'query-replace-regexp)
(global-set-key [f8] 'outline-minor-mode)
(global-set-key [C-f8] 'outline-mode)
(global-set-key [M-f8] 'emacs-wiki-mode)
(global-set-key [f11] 'appt-add)
(global-set-key [f12] 'bookmark-set)
(global-unset-key "")
(setq outline-minor-mode-prefix [(control o)])
(fset 'latex-par [?\\ ?p ?a ?r return])
(global-set-key [C-return] 'latex-par)
(defun mp-ins-l (str str2)
  (interactive "sThe label is: \nsThe insert point is:")
   (insert "(btex ") (insert str) (insert " etex,") (insert str2) (insert ");"))
(global-set-key "\C-cm" 'mp-ins-l)
(fset 'html-br [?\< ?b ?r ?\> return])
(global-set-key [S-enter] 'html-br)
(global-set-key "\ep" 'text-mode)
(global-set-key "\es" 'lisp-mode)
(global-set-key "\M-0" 'delete-window)
(global-set-key "\M-1" 'delete-other-windows) ; Alt-1
(global-set-key "\M-2" 'split-window-vertically) ; Alt-2
(global-set-key "\M-3" 'split-window-horizontally)
(global-set-key [(control ?/)] 'dabbrev-expand)

;;misc
(fset 'yes-or-no-p 'y-or-n-p)
(setq frame-title-format "%b")
(auto-image-file-mode)
(setq adaptive-fill-regexp "[ \t]+\\|[ \t]*\\([0-9]+\\.\\|\\*+\\)[ \t]*")
(global-font-lock-mode t)
(setq initial-frame-alist
   '((cursor-type . (bar . 3))))
(pc-selection-mode)
(setq line-number-mode t)
(setq column-number-mode t)
(setq-default auto-fill-function 'do-auto-fill)
(setq next-line-add-newlines nil)
(setq inhibit-startup-message t)
(setq visible-bell t)
(setq scroll-step 1)
(show-paren-mode t)
(setq show-paren-style 'parentheses)
(setq default-tab-width 4)
(setq todo-file-do "~/.lisp/do")
(setq todo-file-done "~/.lisp/done")
(setq todo-file-top "~/.lisp/top")
(setq diary-file "~/.lisp/diary")
(put 'narrow-to-region 'disabled nil)
(setq c-tab-always-indent nil) ; Tab
(tool-bar-mode -1)
(setq x-select-enable-clipboard t)
(transient-mark-mode 1)

;;备份文件放在_backup目录下
(defun make-backup-file-name (file-name)
  (if (not (file-exists-p "./_backup"))
      (make-directory "./_backup"))
  (concat (expand-file-name "./_backup/")
    (file-name-nondirectory file-name)
    ".bak"))

;;wiki相关
(load "emacs-wiki")
(setq emacs-wiki-projects
        `(("eng" . ((emacs-wiki-directories . ("e:/wikis/eng"))
                    (emacs-wiki-publishing-directory . "e:/wikis/publish/eng")
                    (emacs-wiki-default-page . "nc3")))
         ("linux" . ((emacs-wiki-directories . ("e:/wikis/linux"))
                    (emacs-wiki-publishing-directory . "e:/wikis/publish/linux")
                    (emacs-wiki-default-page . "WelcomePage")))
        ("default" . ((emacs-wiki-directories . ("e:/wikis/default"))
                      (emacs-wiki-publishing-directory . "e:/wikis/publish/default")
                      (emacs-wiki-default-page . "WelcomePage")))))
(setq emacs-wiki-menu-factory 'emacs-wiki-menu-make-from-projects)

;;让上下键翻页(默认只是移动光标)
(require 'pager)
(global-set-key "\C-v"     'pager-page-down)
(global-set-key [next]      'pager-page-down)
(global-set-key "\ev"     'pager-page-up)
(global-set-key [prior]     'pager-page-up)
(global-set-key '[up] 'pager-row-up)
(global-set-key '[M-kp-8] 'pager-row-up)
(global-set-key '[down] 'pager-row-down)
(global-set-key '[M-kp-2] 'pager-row-down)

;;C-.记录当前位置,稍后可用C-,跳回来
(global-set-key [(control ?\.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register.
Use ska-jump-to-register to jump back to the stored
position."

  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))
(defun ska-jump-to-register()
  "Switches between current cursorposition and position
that was stored with ska-point-to-register."

  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
        (jump-to-register 8)
        (set-register 8 tmp)))

;;M-g跳到指定行
(global-set-key [(meta g)] 'goto-line)
(defun wy-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."

  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
       char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)

;;系统自动保存的参数
(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.
 '(browse-url-browser-function (quote browse-url-firefox))
 '(browse-url-firefox-new-window-is-tab t)
 '(browse-url-firefox-program "c:/Program Files/Mozilla Firefox/firefox.exe")
 '(browse-url-galeon-program "c:/Program Files/Mozilla Firefox/firefox.exe")
 '(browse-url-mozilla-program "c:/Program Files/Mozilla Firefox/firefox.exe")
 '(browse-url-netscape-program "c:/Program Files/Mozilla Firefox/firefox.exe")
 '(case-fold-search t)
 '(comment-padding "")
 '(default-input-method "chinese-py-punct")
 '(dictem-server "127.0.0.1")
 '(dictem-user-databases-alist (quote (("((\"en-cn\" . (\"xdict\" \"cdict\")))" . "nil"))))
 '(fill-column 85)
 '(global-font-lock-mode t nil (font-lock))
 '(org-agenda-files (quote ("~/.org/work.org" "~/.org/self.org" "~/.org/job.org")))
 '(show-paren-mode t nil (paren))
 '(transient-mark-mode t)
 '(truncate-partial-width-windows nil))

(autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
(autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
(setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode)
                             ("\\.htm$" . html-mode)
                             ("\\.html$" . html-mode)
                            ("\\.php$" . html-helper-mode))
             auto-mode-alist))
(setq scheme-program-name "mzscheme")

;;hideshow
(require 'hideshow)
(easy-menu-define hs-minor-mode-menu
    hs-minor-mode-map
    "Menu used when hideshow minor mode is active."
    (cons "Hide/Show"
          (mapcar
           ;; Interpret each table entry as follows: first, populate keymap
           ;; with elements 2 and 1; then, for easymenu, use entry directly
           ;; unless element 0 is nil, in which case the entry is "omitted".
           (lambda (ent)
             (define-key hs-minor-mode-map (aref ent 2) (aref ent 1))
             (if (aref ent 0) ent "-----"))
           ;; These bindings roughly imitate those used by Outline mode.
           ;; menu entry command key
           '(["Hide Block" hs-hide-block "\C-o\C-c"]
             ["Show Block" hs-show-block "\C-o\C-e"]
             ["Hide All" hs-hide-all "\C-o\C-t"]
             ["Show All" hs-show-all "\C-o\C-a"]
             ["Hide Level" hs-hide-level "\C-o\C-l"]
             ["Toggle Hiding" hs-toggle-hiding "\C-o\C-h"]
             [nil hs-mouse-toggle-hiding [(shift mouse-2)]]
             ))))

(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'latex-mode-hook 'outline-minor-mode)
(add-hook 'perl-mode-hook 'cperl-mode)
(put 'downcase-region 'disabled nil)

;;在html和css模式下将#XXXXXX按所代表的颜色着色
(defvar hexcolour-keywords
   '(("#[abcdef[:digit:]]\\{6\\}"
      (0 (put-text-property (match-beginning 0)
                            (match-end 0)
                            'face (list :background
                                        (match-string-no-properties 0)))))))
 (defun hexcolour-add-to-font-lock ()
   (font-lock-add-keywords nil hexcolour-keywords))
 (add-hook 'html-mode-hook 'hexcolour-add-to-font-lock)
 (add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)

;;字体
(setq ascii-font "-outline-Courier New-normal-r-normal-normal-16-97-96-96-c-*-iso8859-1")
(setq chinese-font "-outline-新宋体-normal-r-normal-normal-16-*-96-96-c-*-iso10646-1")
(defun wheer-set-font (en-font cn-font)
  (create-fontset-from-fontset-spec
   (replace-regexp-in-string "iso8859-1" "fontset-wheer" en-font))
  (set-fontset-font "fontset-wheer" 'gb18030 cn-font)
  (set-fontset-font "fontset-wheer" 'latin en-font)
  (set-fontset-font "fontset-default" 'gb18030 cn-font)
  (set-fontset-font "fontset-default" 'latin en-font)
  (set-default-font "fontset-wheer")
  (setq default-frame-alist
    (append '((font . "fontset-wheer")) default-frame-alist)))
(wheer-set-font ascii-font chinese-font)

(set-language-environment "Chinese-GB18030")
(setq file-name-coding-system 'gb18030)

;;org-mode
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-agenda-custom-commands
           '(("u" tags "+URGENT")
             ("U" tags-tree "+URGENT")))
(defcustom org-export-html-style
"<link rel=\"stylesheet\" type=\"text/css\" href=\"org.css\">" ""
  :group 'org-export-html
  :type 'string)

;;启动emacsclient服务,然后用emacsclientw.exe打开文件就不用新开一个emacs了
(server-start)

;;窗口最大化
(defun w32-maximize-frame ()
    "Maximize the current frame"
     (interactive)
     (w32-send-sys-command 61488))
(w32-maximize-frame)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。如发现有害或侵权内容,请点击这里 或 拨打24小时举报电话:4000070609 与我们联系。

    猜你喜欢

    0条评论

    发表

    请遵守用户 评论公约

    类似文章
    喜欢该文的人也喜欢 更多