수요일, 8월 30, 2006

Emacs: how to enable syntax highlight for make file?

Add the below commands to .emacs file.

(setq auto-mode-alist
(append '(
("\\.[Ss]$" . asm-mode)
("\\.68k$" . asm-mode)
("\\.inc$" . asm-mode)
("\\.[bB][aA][tT]$" . bat-mode)
("\\.x$" . c-mode)
("\\.[Hh]$" . c++-mode)
("\\.sqc$" . c++-mode)
("\\.el$" . emacs-lisp-mode)
("\\.emacs$" . emacs-lisp-mode)
("\\.bin$" . hexl-mode)
("\\.txt$" . text-mode)
("\\.java$" . java-mode)
("\\.mak$" . makefile-mode)
("[Mm]akefile.*$" . makefile-mode)
("\\.prop.*$" . makefile-mode)
("\\.cshrc$" . sh-mode)
("\\.jsp$" . html-mode)
("\\.xsd$" . sgml-mode)
("\\.xsl$" . sgml-mode)
("\\.v$" . verilog-mode)
("\\.vv$" . verilog-mode)
("\\.Xdefaults$" . xrdb-mode)
) auto-mode-alist))

목요일, 8월 24, 2006

Emacs: Show line number from editor

Download setnu.el from:
http://www.emacswiki.org/cgi-bin/wiki/setnu.el

Append the below two lines to setnu.el lisp code.
(add-hook 'c-mode-hook 'turn-on-setnu-mode)
(add-hook 'java-mode-hook 'turn-on-setnu-mode)

Load it from .emacs file.

Done. Now, you can see the line number from Emacs editor when you are editing C or Java source codes.

Emacs: Color Theme

http://www.emacswiki.org/cgi-bin/wiki?ColorTheme

  1. Download ColorTheme
  2. Copy ColorTheme folder to Emacs 'site-lisp' folder
  3. Check about the colors from this page
  4. Add the below line to your .emacs file
    1. (require 'color-theme)
      (color-theme-initialize)
      (color-theme-colorName)
  5. Now, you can see the color theme from your Emacs!

수요일, 8월 23, 2006

Emacs: Indentation

  • Region indentation
    • C-4 C-X- : Indent region as 4 spaces
    • C-- C-4 C-X- : Dedent region as 4 spaces
  • Line break and indent
    • C-j
  • Back to indentation
    • M-m
  • Open line under the current line
    • ?
  • Open line above the current line
    • ?

bash: comparison operator

  • String Comparison
    • str1 = str2
    • str1 != str2
    • str1 < str2
    • str1 > str2
    • -n str1 : str1 is not null
    • -z str1 : str1 is null
  • File Attribute Operator
    • -a file : file exists
    • -d file : file is a directory
    • -e file : same as -a
    • -f file : file is a regular file
    • -r file : read permission
    • -s file : file is not empty
    • -w file : write permission
    • -x file : execute permission
    • -N file : modified since it was last read
    • -O file : you own file
    • -G file : group ID matched yours
    • file1 -nt file2 : file1 is newer than file2
    • file1 -ot file2 : file1 is older than file2
  • Integer Conditions
    • -lt : Less than
    • -le : Less than equal
    • -eq : Equal
    • -ge : Greater than or equal
    • -gt : Greater than
    • -ne : Not equal

Refer page114, page 117 and page 121 of Learning the bash

월요일, 8월 21, 2006

bash: string operators

  • ${varname:-word}
    • echo ${count:-0} : prints '0' if count is null.
  • ${varname:=word}
    • echo ${count:=0} : prints '0' and assign 0 to count if count is null.
  • ${varname:?message}
    • echo ${count:?NULL} : prints 'bash: count: NULL' if count is null.
  • ${varname:+word}
    • echo ${count:+0} : prints '0' if count it NOT null.
  • ${varname:offset:length}
    • var1='sample'
    • ehco ${var1:1:2} : prints 'am'.
  • ${varname#pattern}
    • echo ${PWD} is '/home/wonkim'.
    • echo ${PWD#*/} is 'home/wonkim'.
  • ${varname##pattern}
    • echo ${PWD##*/} is 'wonkim'.
  • ${varname%pattern}
    • echo {PWD%/*} is '/home'.
  • ${varname%%pattern}
    • ehco {PWD%%/*} is null.
  • ${varname/pattern/string}
    • echo {PWD/\//:} is ':home/wk157575'
  • ${varname//pattern/string}
    • ehco {PWD//\//:} is ':home:wk157575'
Refer 'page 91' and 'pag 96' of Learning the bash

토요일, 8월 19, 2006

bash: Emacs mode editing commands

CTRL-A : Move to beginning of line
CTRL-K : Kill forward to end of line
CTRL-Y : Yank
CTRL-_ : Undo
CTRL-x ( : Start key macro recording
CTRL-x ) : End key macro recording
CTRL-x e : Execute the last macro
ESC-CTRL-H : Kill one word backward
ESC-D : Kill one word forward
ESC-? : List the possible completion
ESC-L : Change word after point to all lowercase letters
ESC-. : Insert last word in previous command line after point

금요일, 8월 18, 2006

Emacs: delete all string from command input mode

Try to use:

C-a-k

to delete all string

C-BS

to delete word

Emacs + Cscope + Java

How to enable Java context searching Emacs by using cscope?

* Add 'java' file type to cscope-indexer script file.
* egrep -i '\.([chly](xx|pp)*|cc|hh|java)$'

* Add 'java mode hook' to xcscope.el lisp file.
* (add-hook 'java-mode-hook (function cscope:hook))

That's all. Now you can browsing Java symbol by using cscope whithin Emacs.

목요일, 8월 17, 2006

새로운 에디터에 적응하기

아마 나와 같이 소프트웨어 업계에 종사하는 분이라면 충분히 공감할 수 있으리라 생각이 드는데. "에디터"를 바꾼다는 일이 꽤나 어렵다.
그동안 휴대폰 관련 개발일을 하며 불법으로 구해 사용하던 소XXXXX트라는 에디터를 과감히(?) 버리고 GNU Emacs를 사용하기 위해 씨름하고 있다.
익숙치 않은 에디터 익히랴 일하랴 평소보다 효율이 한 2배 정도 줄어든 것 같기는 한데 요 Emacs라는 에디터가 쏠쏠한 공부하는 재미를 주는 이점이 있다. ^^
아마도 한 3개월정도 사용하면 어느정도 손에 익으리라 생각된다. Emacs가 익숙해질만 하면 Emacs Lisp도 한번 공부해볼까나?
이 에디터에 익숙해지면 어떤 직장을 구해도 불법 에디터를 사용할 일은 없어지겠지?

수요일, 8월 16, 2006

Emacs keyboard macro and repeat command

Start keyboard macro: C-x (
End keyboard macro: C-x )
Execute the last macro: C-x e
Repeat the last command: C-x z {z...}