Sunday, November 25, 2007

Emacs (Auctex) Window XP installation instruction

Installation instruction:
This article describes the installation of emacs including Auctex for Window XP. Since most of these files have be precompiled, what you need just download the precompiled file and configurate them.

1) Download Emacs(including Auctex) for Window XP. The download page as follow:

http://www.gnu.org/software/auctex/download-for-windows.html

And here we use the version emacs+auctex-w32-2007-07-07.zip, you can download from
ftp://alpha.gnu.org/gnu/auctex/emacs+auctex-w32-2007-07-07.zip

Please read the README file before downloading, and in this manual, which included all lisp code and documentation. We put the unzipped file Emacs to the directory C:\Program Files\Emacs. Then we need to setup environmental variable:

HOME=C:\Program Files\Emacs

Afterwards, .emacs.d and .emacs are under the directory $HOME(C:\Program Files\Emacs)

Note: the configuration of the $HOME is very important, please set if first before the following configuration.

2) Configuration

Generally speaking, the main purpose of configuration to Emacs is to set up .emacs file, which was located in the $HOME directory. Here we take into account an example of how to set Aspell that could check spelling.

**********************************************************************************************************************
Configuration for Aspell:

(1) First, download full installer from
http://aspell.net/win32/
and then worldlist setup. Be aware of they are two separately installations.

(2) In my configuration, I installed them into the C:\Program Files\Emacs\Aspell. Then add the path C:\Program Files\Emacs\Aspell\bin to the environmental variable PATH.

(3) Download the ispell.el from
http://kdstevens.com/~stevens/ispell-page.html
and then put ispell.el to directory $HOME/site-lisp

(4) add to the .emacs as
(setq-default ispell-program-name "aspell")
(setq-default ispell-local-dictionary "american")
(global-set-key (kbd "") 'ispell-complete-word)
*********************************************************************************************************************
Configuration for Latex

Thought this emacs version includes Auctex, but we need to download latex for windown XP, you can find more information here:

http://www.hi.is/~tpr/latex/index.html

Here we use Miktex, a latex compiler. Generally set up and the installation will set latex command to the environmental variable PATH.

There is problem for preview functionality, what is resolution here is enter the Miktex installed directory, in my case is
C:\Program Files\MiKTeX 2.6\miktex\bin
change the yap to xdvi.
The reason for this operation is preview functionaliy here is "xdvi file.dvi", however, can not find xdvi in miktex, we just change the command name as xdvi here.
To produce PDF file:
dvipdft file.dvi
To produce PS file:
dvips file.dvi
***********************************************************************************
;my .emacs file
;------------------------------------------------------------------------------
; Basic set up
;------------------------------------------------------------------------------

(setq default-major-mode 'text-mode); set defalut mode as text-mode
(setq inhibit-startup-message t) ; Don't want any startup message
(setq auto-save-default nil) ; Don't want any auto saving
(setq auto-save-list-file-name nil) ; Don't want any .saves files
(show-paren-mode t) ;parathesis mathcing
;; the following setups are for color style, since here I used color.el, not necessary to set anything
;(setq make-backup-files nil) ; Don't want any backup files
;(set-cursor-color "blue") ; Set cursor and mouse-pointer colours
;(set-background-color "white") ; Set emacs bg color


(mouse-avoidance-mode 'jump) ;when cursor close to mouse, mouse avoid automatically, funny ^_^
(tool-bar-mode nil) ; disappear tool-bar
;(menu-bar-mode nil) ; disappear menu-bar
(global-set-key [f9] 'tool-bar-mode) ;keybindings for tool-bar
;(global-set-key [f10] 'menu-bar-mode) ;keybindings for menu-bar
(setq default-line-spacing 10)


;---------------------------------------------------------------------------
;Some (keybindings)keyboard shortcuts for instance copy f5, cut f6, paste f7
;---------------------------------------------------------------------------

;(global-set-key [f5] 'copy-region-as-kill) ; Copy
(global-set-key [f6] 'kill-region) ; Cut
(global-set-key [f7] 'yank) ; Paste


;-------------------------
;color package
;-------------------------
;(load-file "/home/wason/myemacs/color-theme-6.5.0.el")
;(load-file "C:\Program Files\emacs-22.1\site-lisp/color-theme.el")
;(load-file "/home/wason/myemacs/color-theme-6.6.0.el")
;(load-file "/home/wason/myemacs/color-theme-6.6.0/color-theme.el")
(require 'color-theme)
(color-theme-arjen)
;(color-theme-dark-blue2)

;-------------------------
;setup for aspell
;----------------------------
(setq-default ispell-program-name "Aspell")
(setq-default ispell-local-dictionary "american")
(global-set-key (kbd "") 'ispell-complete-word)


;(load "auctex.el" nil t t)
;(load "preview-latex.el" nil t t)

;(setq TeX-parse-self t)
;(setq-default TeX-master nil)
;(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
;(setq reftex-plug-into-AUCTeX t)

***********************************************************************************

Similar, we can configurate any other features in emacs. Enjoy it.

Sunday, November 04, 2007

MBR恢复

今天电脑出现一个非常奇怪的事情,我的本本上装了双系统,XP和Ubuntu, 我的移动硬盘也是双系统,XP和Ubuntu, 然后我在我的本本上用magic对移动硬盘格式化等操作。等操作弄完,重新启动电脑, grub 居然出错, 显示error 17。在网上查了查,17的错误是不能认识引导区。 后来在网上查了查,原来是MBR在格式化硬盘的时候损坏了,真是想不通,对不同的硬盘操作,为什么会相互影响。废话少说,现在来恢复。

恢复MBR的办法,直接用XP安装盘启动,进入控制台,然后执行fixmbr。 XP可以恢复了。 Ubuntu仍然进不了。现在的情形几乎是原来双系统,重装xp后linux恢复不了,原因是MBR重写了,这里介绍两个方法来恢复:

1)一种方法是下载grldr, 放在C盘,然后修改boot.int, 在最后一行加上 C:\GRLDR="GRUB"。 虽然恢复以后的系统不是100%的完美,主要要两次引导,一次是grldr, 然后才是linux下的grub。

2) 第二种恢复是完全恢复,在恢复以前首先必须从floopy 或者恢复盘进入到GRUB。 比如从floopy恢复,先要把GRUB安装到floopy上面,安装的方法是

cd /usr/lib/grub/i386-pc

dd if=stage1 of=/dev/fd0 bs=512 count=1

dd if=stage2 of=/dev/fd0 bs=512 seek=1

然后从floopy启动, 进入到GRUB控制台。 

找可以用的stage1文件 

find /boot/grub/stage1

如果系统安装了多个操作系统,比如

  • SUSE on (hd0,1)
  • Kubuntu on (hd0,2) 
  • Mandriva on (hd0,4)

如果用SUSE的stage1文件

root (hd0,1)

如果用Kubuntu的stage1文件

root (hd0,2)

同理Mandriva

root (hd0,4)

最后setup(hd0)

然后退出。 

总结一下

find /boot/grub/stage1 (optional)
root (hdX,Y)
setup (hd0)
quit

重新启动机器 ok