"Dot emacs"의 두 판 사이의 차이

ph
이동: 둘러보기, 검색
77번째 줄: 77번째 줄:
 
;; Specify my function (maybe I should have done a lambda function)             
 
;; Specify my function (maybe I should have done a lambda function)             
 
(setq compilation-exit-message-function 'compilation-exit-autoclose)
 
(setq compilation-exit-message-function 'compilation-exit-autoclose)
 +
 +
(global-set-key "%" 'match-paren)
 +
(defun match-paren (arg)
 +
  "Go to the matching paren if on a paren; otherwise insert %."
 +
  (interactive "p")
 +
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
 +
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
 +
        (t (self-insert-command (or arg 1)))))
 +
 +
(defun find-word-under-cursor (arg)
 +
  (interactive "p")
 +
  (if (looking-at "\\<") () (re-search-backward "\\<" (point-min)))
 +
  (isearch-forward))
  
  
 
</source>
 
</source>

2011년 5월 11일 (수) 18:01 판

(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.                           
 '(tool-bar-mode nil))
(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.                           
 )

;; (setq inhibit-default-init t)                                                

;; turn on font-lock mode                                                       
(when (fboundp 'global-font-lock-mode)
  (global-font-lock-mode t))

;; enable visual feedback on selections                                         
(setq transient-mark-mode t)

(setq column-number-mode t)

;; default to better frame titles                                               
(setq frame-title-format
      (concat  "%b - emacs@" system-name))

(global-set-key (kbd "<f3>") 'buffer-menu)
(global-set-key (kbd "<f2>") 'find-file)

;;(global-set-key (kbd "M-") 'list-buffers)                                     
(global-set-key (kbd "M-s") 'save-buffer)
(global-set-key (kbd "M-p") 'scroll-down)
(global-set-key (kbd "M-n") 'scroll-up)
(global-set-key (kbd "<select>") 'move-end-of-line) ; weird                     
(global-set-key (kbd "C-x SPC") 'set-mark-command)  ; for mac                   
(global-set-key (kbd "ESC <deletechar>") 'kill-word)

(menu-bar-mode -1)

(add-to-list 'load-path "/Users/ph/.elisp")
(load "php-mode")
(add-to-list 'auto-mode-alist '("\\.nhn\\'" . php-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\'" . sgml-mode))
(setq make-backup-files nil)

(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;;(add-to-list 'auto-mode-alist '("\\.nhn$" . js2-mode))                        
;;(add-to-list 'auto-mode-alist '("\\.tpl$" . js2-mode))                        
(set-variable  'scroll-step 1)
;;(setq indent-tabs-mode nil)                                                   
(setq-default tab-width 4)
;;(setq c-basic-offset 4)                     

(add-hook 'c++-mode-hook '(lambda ()
                            (local-set-key (kbd "RET") 'newline-and-indent)))
(setq c-default-style "stroustrup")

(require 'linum)


;; http://www.emacswiki.org/emacs/ModeCompile                                   
;; Helper for compilation. Close the compilation window if                      
;; there was no error at all.                                                   
(defun compilation-exit-autoclose (status code msg)
  ;; If M-x compile exists with a 0                                             
  (when (and (eq status 'exit) (zerop code))
    ;; then bury the *compilation* buffer, so that C-x b doesn't go there       
    (bury-buffer)
    ;; and delete the *compilation* window                                      
    (delete-window (get-buffer-window (get-buffer "*compilation*"))))
  ;; Always return the anticipated result of compilation-exit-message-function  
  (cons msg code))
;; Specify my function (maybe I should have done a lambda function)             
(setq compilation-exit-message-function 'compilation-exit-autoclose)

(global-set-key "%" 'match-paren)
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))

(defun find-word-under-cursor (arg)
  (interactive "p")
  (if (looking-at "\\<") () (re-search-backward "\\<" (point-min)))
  (isearch-forward))