Vietnamen’s Weblog

Time, Chances, Diligence, Intelligence: which is the most important?

Text editor/IDE

with 4 comments

Với text editor, TeXmacs là một lựa chọn tốt giúp soạn văn bản một cách chính qui (presentation, book, report, article) và chuyên nghiệp với khả năng xuất ra PDF, PS, LaTeX, HTML…

Một lựa chọn khác, đa năng hơn rất nhiều, nhưng cũng phức tạp sử dụng hơn, đó là Emacs.

TeXmacs

Trong Ubuntu, chỉ mới có version 1.0.6.1 với nhiều lỗi. Sau đây là cách install bản 1.0.7.1 ổn định hơn

Bước 1: install texmacs 1.0.6.1 theo Ubuntu, kèm theo texmacs-extra-fonts

Bước 2: dùng thử texmacs, đọc và lưu một số file [có thể không cần thiết]

Bước 3: remove texmacs + texmacs-common, ngoài ra không remove cái gì khác (dùng sudo aptitude để remove, tránh dùng sudo apt-get remove texmacs sẽ kéo theo các thứ khác bị remove)

Bước 4: download Texmacs 1.0.7.1 từ internet về http://www.texmacs.org/tmweb/download/unix.en.html

Bước 5: extract vào 1 thư mục (e.g. ~/Texmacs-1.0.7.1)

Bước 6: add these links into ~/.profile

if [ -d “$HOME/Desktop/TeXmacs-1.0.7.1/bin” ] ; then
PATH=”$HOME/Desktop/TeXmacs-1.0.7.1/bin:$PATH:”
export TEXMACS_PATH=~/Desktop/TeXmacs-1.0.7.1/
fi

Bước 7: logout và login, hoặc chỉ đơn giản là

source ~/.profile

Bước 8: chạy texmacs từ terminal và yup.

Để tìm hiểu thêm cách sử dụng, đọc bài TexMacs.

Emacs

sudo aptitude

Choose texmacs22-gtk để install

Other needs to be installed:

  • texlive-science (typesetting for natural & computer sciences – journal publication)
  • Use tkbibtex: a portable editor and browser for BibTeX format file.
  • Hoán vị chức năng của phím Left-Contrl và Capslock (Vì chức năng của Ctrl được dùng rất nhiều, mà vị trí trên bàn phím của nó không thuận tiện cho khi nhấm một loạt phím kết hợp)

Tạo file ~/.xmodmaprc và đưa nội dung

! swap left control and caps lock

remove Lock = Caps_Lock
remove Control = Control_L

keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L

add Lock = Caps_Lock
add Control = Control_L

Tiếp đến, tạo file ~/xinitrc và đưa vào nội dung

xmodmap $HOME/.xmodmaprc

Thoát ra và vào lại (phím Ctrl giờ sẽ có chức năng của phím Capslock và ngược lại)

http://www.columbia.edu/~djv/docs/keyremap.html

  • Nếu chỉ muốn hoán vị có hiệu lực tạm thời (trong phiên làm việc) thì ta dùng program setxkbmap
setxkbmap -option ctrl:swapcaps
  • To set up key-binding (trong emacs, tất cả các lệnh có thể truy xuất qua M-x <tên lệnh>, ta có thể rút gọn bằng cách đặt phím tắc cho một số lệnh hay dùng)

Trong file ~/.emacs ta dùng hàm global-set-key ví dụ

(global-set-key (kbd "<f1>") 'emms-previous)
(global-set-key (kbd "<f2>") 'emms-start)
(global-set-key (kbd "<f3>") 'emms-stop)
(global-set-key (kbd "<f4>") 'emms-next)
  • maxima:

File cấu hình ~/.emacs

(add-to-list 'load-path "~/.emacs.d/share")
(add-to-list 'load-path "~/.emacs.d/share/icicles")

;; IDO - Iteractively Do Things (with buffes and files)
;;http://www.emacswiki.org/emacs-en/InteractivelyDoThings
(require 'ido)
(ido-mode t)

;; AUCTeX - install from the synaptic
;; http://www.gnu.org/software/auctex/manual/auctex.html
;;http://www.xemacs.org/Documentation/packages/html/auctex_4.html
;; activate AUCTeX
(require 'tex-site)
;syntax highlite
(global-font-lock-mode t)
;;http://www.gnu.org/software/auctex/manual/auctex.html#SEC11
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
;; enable document parsing - auto aware of filetypes
(setq TeX-auto-save t)
(setq TeX-parse-self t)
;;and multifiles documents
(setq-default TeX-master nil)
;; Add menu-bar-index
(add-hook 'reftex-load-hook 'imenu-add-menubar-index)
(add-hook 'reftex-mode-hook 'imenu-add-menubar-index)
;; Bind imenu to the right mouse click
(global-set-key [down-mouse-3] 'imenu)
;; Define abbreviation that works with AUCTeX only
(define-abbrev-table 'TeX-mode-abbrev-table (make-abbrev-table))
(add-hook 'TeX-mode-hook (lambda ()
(setq abbrev-mode t)
(setq local-abbrev-table TeX-mode-abbrev-table)))
;; http://www.gnu.org/software/auctex/manual/auctex.html#SEC52
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)

;; RefTeX - built-in
;; RefTeX help you doing with labels, references...
;; http://www.emacswiki.org/emacs-en/RefTeX
;; plug RefTeX in AUCTeX
(add-hook 'latex-mode-hook 'turn-on-reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-auctex t)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'reftex-load-hook 'imenu-add-menubar-index)
(add-hook 'reftex-mode-hook 'imenu-add-menubar-index)
;; create custom sections and labels
;; e.g. here is the example of a "Poem" label that shows up at level 3 entry in TOC
; (add-hook 'reftex-load-hook
; (lambda ()
; (setq reftex-section-levels
; (cons '("poemtitle" . -3) reftex-section-levels))))

; (setq reftex-label-alist
; '(("\\poemtitle" ?P "poem:" "\\ref{%s}" nil ("poem" "poemtitle"))))

;; WhizzyTeX - install from synaptic
;;; whizzy-tex
(autoload 'whizzytex-mode
"whizzytex"
"WhizzyTeX, a minor-mode WYSIWIG environment for LaTeX" t)
(setq-default whizzy-viewers '(
("-advi" "advi -html Start-Document")
("-dvi" "xdvi")
("-ps" "gv")
))
(setq my-toggle-whizzy-count 0)
(defun my-toggle-whizzy-mode ()
(interactive)
(if (= (mod my-toggle-whizzy-count 2) 0)
(progn
(whizzytex-mode)
(message "WhizzyTeX on"))
(progn
(whizzy-mode-off)
(kill-buffer (concat "*" (buffer-name) "*"))
(message "WhizzyTeX off")))
(setq my-toggle-whizzy-count (+ my-toggle-whizzy-count 1)))

(add-hook 'LaTeX-mode-hook
(lambda ()
(define-key LaTeX-mode-map (kbd "<f9>") 'my-toggle-whizzy-mode)))

(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.
'(LaTeX-fill-break-at-separators (quote ({ })))
'(LaTeX-indent-environment-list (quote (("code" current-indentation) ("verbatim" current-indentation) ("verbatim*" current-indentation) ("array") ("displaymath") ("eqnarray") ("eqnarray*") ("equation") ("equation*") ("picture") ("tabbing") ("table") ("table*") ("tabular") ("tabular*"))))
'(LaTeX-verbatim-environments (quote ("lstlisting" "example" "code" "verbatim" "verbatim*")))
'(TeX-quote-after-quote t)
'(icicle-download-dir "~/.emacs.d/share/icicles")
'(speedbar-directory-unshown-regexp "^\\(CVS\\|RCS\\|SCCS\\|.deps\\)\\'")
'(speedbar-frame-parameters (quote ((minibuffer) (width . 20) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (set-background-color "black"))))
'(speedbar-supported-extension-expressions (quote (".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".f\\(90\\|77\\|or\\)?" ".ad*" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g" ".s?html" "[Mm]akefile\\(\\.in\\|am\\)?" "configure.ac" ".ml*" ".tig" ".\\(ll\\|yy\\)")))
'(template-auto-update (quote query)))

;; Choose special effect for these special term (TODO, FIXME, NOTE, WARNING)
;; in your source code (C, C++, Java...)
;;          The major modes to get this effect is listed as c-mode c++-mode java-mode ...
;;          The terms to be in this effect is listed in the pattern variable
(make-face 'special-words)
(set-face-attribute 'special-words nil
:foreground "White" :background "Firebrick")
(let ((prog-modes '( c-mode c++-mode java-mode ada-mode sh-mode tcl-mode
cperl-mode python-mode ruby-mode lisp-mode ))
(pattern "\\<\\(FIXME\\|TODO\\|NOTE\\|WARNING\\):"))
(mapcar
(lambda (mode)
(font-lock-add-keywords mode `((,pattern 1 'special-words prepend))))
prog-modes))

;; Aspell - a replacement for ispell
;; just install it from repository (sudo aptitude)
;; http://aspell.net/0.50-doc/man-html/4_Customizing.html
;; http://aspell.net/0.50-doc/man-html/5_Working.html
(setq-default ispell-program-name "aspell")
(setq ispell-dictionary "english")      ;
;(setq-default ispell-extra-args '("--reverse")) ; for some reason, ispell 3.0 want to reverse the suggestion list
;(setq ispell-personal-dictionary "~/MyEmacs/Configure-File/Ispell/personal-dictionary") ;
;(setq ispell-silently-savep t)          ;??????????????

;; PerlNow  --- collection of utility commands for perl programmers who use emacs.
;; These commands are designed to help automate some routine tasks
;;     in the initial creation of perl scripts and modules. Commands are
;;    also provided to assist in running, testing and debugging inside of emacs.
;; http://obsidianrook.com/perlnow/
;; require template.el
;; for template.el (a necessary package for perlnow)
(require 'template)
(template-initialize)
;; for PerlNow
(require 'perlnow)
(global-set-key "\C-c's" 'perlnow-script)
(global-set-key "\C-c'm" 'perlnow-module)
(global-set-key "\C-c'o" 'perlnow-object-module)
(global-set-key "\C-c'h" 'perlnow-h2xs)
(global-set-key "\C-c'c" 'perlnow-run-check)
(global-set-key "\C-c'r" 'perlnow-run)
(global-set-key "\C-c'a" 'perlnow-alt-run)
(global-set-key "\C-c'd" 'perlnow-perldb)
(global-set-key "\C-c'R" 'perlnow-set-run-string)
(global-set-key "\C-c'A" 'perlnow-set-alt-run-string)
(global-set-key "\C-c't" 'perlnow-edit-test-file)
(global-set-key "\C-c'b" 'perlnow-back-to-code)
(global-set-key "\C-c'~" 'perlnow-perlify-this-buffer-simple)
(global-set-key [f4] 'perlnow-script)
(add-hook 'cperl-mode-hook '(lambda () (define-key cperl-mode-map [f1] 'perlnow-perl-check) ))
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)

;;
;; Emacs-PDE (collection of extension and configuration for
;; Perl programming in Emacs
(add-to-list 'load-path "~/.emacs.d/share/pde/lisp")
(add-to-list 'load-path "~/.emacs.d/share/pde")
(load "pde-load")
(require 'pde-load)

;; CPerl-Mode  (more advanced than perlmode)
(mapc
(lambda (pair)
(if (eq (cdr pair) 'perl-mode)
(setcdr pair 'cperl-mode)))
(append auto-mode-alist interpreter-mode-alist))

;; CPerlMode-OutlineMinorMode
; Outline-minor-mode key map
(define-prefix-command 'cm-map nil "Outline-")
; HIDE
(define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
(define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
(define-key cm-map "o" 'hide-other)        ; Hide other branches
(define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
(define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
(define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
; SHOW
(define-key cm-map "a" 'show-all)          ; Show (expand) everything
(define-key cm-map "e" 'show-entry)        ; Show this heading's body
(define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
(define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
(define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
; MOVE
(define-key cm-map "u" 'outline-up-heading)                ; Up
(define-key cm-map "n" 'outline-next-visible-heading)      ; Next
(define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
(define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
(define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
(global-set-key "\M-o" cm-map)
;;     =head1
;;    package
;;    =head2
;;    =item
;;    sub
(defmacro join (join-char &rest others) `(mapconcat 'identity ',others ,join-char))
(setq my-cperl-outline-regexp
(concat
"^"                              ; Start of line
"[ \\t]*"                        ; Skip leading whitespace
"\\("                            ; begin capture group \1
(join "\\|"
"=head[12]"                  ; POD header
"package"                    ; package
"=item"                      ; POD item
"sub"                        ; subroutine definition
)
"\\)"                            ; end capture group \1
"\\b"                            ; Word boundary
))
;; Adjust outline level
(setq cperl-mode-hook 'my-cperl-customizations)
(defun my-cperl-customizations ()
"cperl-mode customizations that must be done after cperl-mode loads"
(outline-minor-mode)
(abbrev-mode)

(defun cperl-outline-level ()
(looking-at outline-regexp)
(let ((match (match-string 1)))
(cond
((eq match "=head1" ) 1)
((eq match "package") 2)
((eq match "=head2" ) 3)
((eq match "=item"  ) 4)
((eq match "sub"    ) 5)
(t 7)
)))

(setq cperl-outline-regexp  my-cperl-outline-regexp)
(setq outline-regexp        cperl-outline-regexp)
(setq outline-level        'cperl-outline-level)
)

;; change indentation for perl code
;http://www.emacswiki.org/emacs/IndentingPerl
(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
(defun n-cperl-mode-hook ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 0)
(setq cperl-extra-newline-before-brace t)
; (set-face-background 'cperl-array-face "wheat")
; (set-face-background 'cperl-hash-face "wheat")
)

;; Remove ^M annoying character in the Emacs shell
;; http://www.emacswiki.org/emacs-en/ShellMode
(add-hook 'comint-output-filter-functions
'comint-strip-ctrl-m)

;;  Icicles - Code completion ('TAB completion)
;; http://www.emacswiki.org/emacs-en/Icicles
;; http://www.emacswiki.org/emacs-en/Icicles_-_Libraries
(load "icicles-install")
;; these below are customized from Icicles library
(custom-set-faces
;; custom-set-faces 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.
'(background "blue")
'(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
'(font-lock-comment-face ((t (:foreground "MediumAquamarine"))))
'(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
'(font-lock-doc-string-face ((t (:foreground "green2"))))
'(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
'(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
'(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
'(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
'(font-lock-string-face ((t (:foreground "LimeGreen"))))
'(font-lock-type-face ((t (:foreground "#9290ff"))))
'(font-lock-variable-name-face ((t (:foreground "PaleGreen"))))
'(font-lock-warning-face ((((class color) (background dark)) (:foreground "yellow" :background "red"))))
'(highlight ((t (:background "CornflowerBlue"))))
'(hl-line ((t (:inherit highlight :background "brown" :height 1.2))))
'(list-mode-item-selected ((t (:background "gold"))))
'(makefile-space-face ((t (:background "wheat"))))
'(mode-line ((t (:background "Navy"))))
'(paren-match ((t (:background "darkseagreen4"))))
'(region ((t (:background "DarkSlateBlue"))))
'(show-paren-match ((t (:foreground "black" :background "wheat"))))
'(show-paren-match-face ((t (:foreground "black" :background "wheat"))) t)
'(show-paren-mismatch ((((class color)) (:foreground "white" :background "red"))))
'(show-paren-mismatch-face ((((class color)) (:foreground "white" :background "red"))) t)
'(speedbar-button-face ((((class color) (background dark)) (:foreground "green4"))))
'(speedbar-directory-face ((((class color) (background dark)) (:foreground "khaki"))))
'(speedbar-file-face ((((class color) (background dark)) (:foreground "cyan"))))
'(speedbar-tag-face ((((class color) (background dark)) (:foreground "Springgreen"))))
'(vhdl-speedbar-architecture-selected-face ((((class color) (background dark)) (:underline t :foreground "Blue"))))
'(vhdl-speedbar-entity-face ((((class color) (background dark)) (:foreground "darkGreen"))))
'(vhdl-speedbar-entity-selected-face ((((class color) (background dark)) (:underline t :foreground "darkGreen"))))
'(vhdl-speedbar-package-face ((((class color) (background dark)) (:foreground "black"))))
'(vhdl-speedbar-package-selected-face ((((class color) (background dark)) (:underline t :foreground "black"))))
'(whizzy-point-face ((((class color)) (:background "red"))))
'(widget-field ((((class grayscale color) (background light)) (:background "DarkBlue")))))

;; Dictionary support  (can conflict with Look-up)
;; http://www.emacswiki.org/emacs-en/DictMode
;; Download via aptitude is a good choice (dictionary-el)
(defun my-dictionary-search ()
(interactive)
(let ((word (current-word))
(enable-recursive-minibuffers t)
(val))
(setq val (read-from-minibuffer
(concat "Word"
(when word
(concat " (" word ")"))
": ")))
(dictionary-new-search
(cons (cond
((and (equal val "") word)
word)
((> (length val) 0)
val)
(t
(error "No word to lookup")))
dictionary-default-dictionary))))
;; Look-up - dictionary look-up
;; http://www.emacswiki.org/emacs-en/LookUp
;; an integrated search interface to search words from online dictionaries
;; very EFFICIENCE and EFFECTIVE
;; can download via aptitude (lookup-el)

;; Make text change to UPPERCASE, lowercase, or Capitalize easily
;; http://www.emacswiki.org/emacs-en/SimplerWordCapitalization
;; This is active region aware with shortcut M-u, M-l, M-c
(defun region-marked? ()
(and transient-mark-mode mark-active))

(defun my-upcase ()
(interactive)
(if (region-marked?) (upcase-region (region-beginning) (region-end)) (upcase-word 1)))

(defun my-downcase ()
(interactive)
(if (region-marked?) (downcase-region (region-beginning) (region-end)) (downcase-word 1)))

(defun my-capitalize ()
(interactive)
(if (region-marked?)
(save-excursion
(let ((beg (region-beginning))
(end (region-end)))
(goto-char beg)
(while (< (point) end)
(capitalize-word 1))))
(capitalize-word 1)))

(global-set-key (kbd "M-u")       'my-upcase)
(global-set-key (kbd "M-l")       'my-downcase)
(global-set-key (kbd "M-c")       'my-capitalize)

;; save session state in Emacs
;; http://www.emacswiki.org/emacs-en/DeskTop
;; Category: http://www.emacswiki.org/cgi-bin/emacs-en?CategoryPersistence
(desktop-save-mode 1)
;; Customization follows below
(setq history-length 250)
(add-to-list 'desktop-globals-to-save 'file-name-history)

; h-line+ (high-light current line)
;; http://www.emacswiki.org/emacs-en/HighlightCurrentLine
(require 'hl-line+)

;; centered-cursor-mode
;; Good for reading text since it will always center your cursor in the center
(require 'centered-cursor-mode)
;;(require 'centered-cursor-mode)
;;      (global-centered-cursor-mode +1))

;; Flyspell - spell checking on the fly. It's a part of Emacs
;; http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html
;; http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html
;; M-\t
;; M-x customize-group flyspell
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
; suggest words can be sorted by alphabetical order or likeliness order
; by default: alphabetical order
; (setq flyspell-sort-corrections nil)

References:

  1. http://real.metasyntax.net:2357/guides/emacs.html
  2. http://members3.jcom.home.ne.jp/imaxima/Site/Welcome.html
  3. http://wxmaxima.sourceforge.net/wiki/index.php/Main_Page
  4. http://maxima.sourceforge.net/

Scite

http://www.scintilla.org/SciTE.html

Update: tham khảo thêm bài viết của serivn

Gedit

LaTeX plugin for Gedit: http://linux.softpedia.com/get/Desktop-Environment/Tools/Latex-plugin-for-Gedit-46045.shtml

First install texlive package.
Install gedit plugins extra for acept shell scripts and aply this pluginsgedit
Extract this package into /home/usrdirectory/.gnome2/gedit/

References:

  1. http://real.metasyntax.net:2357/guides/emacs.html
  2. http://members3.jcom.home.ne.jp/imaxima/Site/Welcome.html
  3. http://wxmaxima.sourceforge.net/wiki/index.php/Main_Page
  4. http://maxima.sourceforge.net/

Written by vietnamen

Tháng Hai 15, 2009 lúc 5:28 chiều

4 phản hồi

Subscribe to comments with RSS.

  1. […] on February 18, 2009 by vietnamen Để xem thông tin về cách cài đặt Emacs, đọc Editors. Sau đây là một vài bổ sung về chức năng khi khuôn khổ bài viết trên quá […]

  2. […] Tháng Tư 29, 2009 in Tin học, Ubuntu, living better with Ubuntu | Tags: AUCTeX, LaTeX Hôm nay mình muốn nói về LaTeX, một ngôn ngữ giúp viết các tài liệu (article, book, report) một cách professional. Về mặt editor, xin xem bài TeX-editor. […]

  3. Blog của bạn rất hữu ích cho người sử dụng eMacs🙂
    Về SciTE mình có viết một bài tỉ mỉ hơn tại đây:
    http://serivn.wordpress.com/2009/08/05/scite-st-how-to/

    serivn

    Tháng Tám 6, 2009 at 7:31 sáng

    • Thanks, em. co gi do’ng gop thi trao doi them voi anh nhe.

      vietnamen

      Tháng Tám 19, 2009 at 1:46 chiều


Gửi phản hồi

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Log Out / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Log Out / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Log Out / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Log Out / Thay đổi )

Connecting to %s

%d bloggers like this: