(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.
'(display-time-mode t)
'(setq neo-window-width t)
'(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.
'(default ((t (:family "나눔고딕코딩" :foundry "SAND" :slant normal :weight bold :height 125 :width normal)))))
;; 튜토리얼 메시지 없애기
(setq inhibit-startup-message t)
;; 영역이 선택된 상태에서 붙여넣기 입력시 선택 영역을 지우고 paste 하도록 변경
(delete-selection-mode t)
;; 커서 모양
;; (setq-default cursor-type 'box)
(setq-default cursor-type 'bar)
;; (setq-default cursor-type 'hbar)
;; 커서 라인 표시하기
;;(global-hl-line-mode 1)
;; 화면 왼쪽에 라인넘버 표시
;;(global-linum-mode t)
;; 선택 영역 표시
(transient-mark-mode t)
;; 윈도우 제목 설정
(setq frame-title-format "Emacs - %b")
(setq icon-title-format "Emacs - %b")
;; (setq frame-title-format
;; '(buffer-file-name
;; "Emacs - [%f]"
;; (dired-directory dired-directory "Emacs - [%b]")))
;; 미니버퍼 히스토리를 저장한다.
(savehist-mode 1)
;; 기본 모드 : text-mode
;;(setq initial-major-mode 'text-mode)
;==============================================================================
;; prog mode 설정하기(emacs 24+ only)
;; (참조 : http://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Major-Modes.html)
;==============================================================================
;; prog mode 에 설정을 해두면 각각의 언어에서 별도 설정을 하지 않아도 된다.
;; prog mode 를 상속하지 않는 경우 별도로 설정해야 한다.
(defun set-default-programming-style ()
;; -------------------------------------------------------------------------
;; 엔터 입력시 들여쓰기
(local-set-key (kbd "RET") 'newline-and-indent)
;; -------------------------------------------------------------------------
;; 탭키를 일반 에디터에서 작동하는 방식으로 변경
;; (local-set-key (kbd "TAB") 'self-insert-command)
;; 탭키 입력시 영역지정되어 있으면 영역 들여쓰기. 영역없으면 탭키.
(local-set-key (kbd "TAB") 'indent-block)
;; 들여쓰기 할 때 실제 탭문자 입력
(setq indent-tabs-mode t)
;; 탭 사이즈 4
(setq tab-width 4)
;; -------------------------------------------------------------------------
;; 줄번호 표시
(linum-mode 1)
;; -------------------------------------------------------------------------
;; 대응하는 괄호 표시
(show-paren-mode t)
;; -------------------------------------------------------------------------
;; 커서라인 표시
(global-hl-line-mode))
(add-hook 'prog-mode-hook 'set-default-programming-style)
(defun indent-block()
(interactive)
(if (region-active-p)
(shift-region tab-width)
(insert-tab))
(setq deactivate-mark nil))
(defun unindent-block()
(interactive)
(shift-region (- tab-width))
(setq deactivate-mark nil))
(defun shift-region(numcols)
"shift selected region"
(make-region-as-full-line)
(if (region-active-p)
(save-excursion
(indent-rigidly (region-beginning) (region-end) numcols)
(setq deactivate-mark nil))))
(defun make-region-as-full-line()
"expand the region to the beginning and end of the area selected"
(if (region-active-p)
(progn
(if (< (point) (mark))
(if (not(bolp))
(progn
(beginning-of-line)
(exchange-point-and-mark)
(end-of-line)))))))
(define-key global-map (kbd "M-]") 'indent-block)
(define-key global-map (kbd "M-[") 'unindent-block)
(define-key global-map (kbd "<backtab>") 'unindent-block)
;==============================================================================
;; cc mode
;==============================================================================
;; cc mode
(require 'cc-mode)
(setq auto-mode-alist
(append
'(("\\.C$" . c++-mode)
("\\.H$" . c++-mode)
("\\.cc$" . c++-mode)
("\\.cpp$" . c++-mode)
("\\.hh$" . c++-mode)
("\\.c$" . c-mode)
("\\.h$" . c-mode)
("\\.m$" . objc-mode)
("\\.java$" . java-mode)
) auto-mode-alist))
; set k&r style
;; 참고 : http://davidha.wordpress.com/2009/05/15/emacs-cc-modes-built-in-styles-gallery/
(setq
c-default-style "k&r"
c-basic-offset 4
cperl-indent-level 4)
(add-hook 'c-mode-common-hook
(lambda ()
(setq c-basic-offset 4)
))
;; MS Windows 입력기 사용않함
;; (필요 : http://www.emacswiki.org/emacs/DisableImeForEmacs)
;; =============================================================================
(let ((dife (expand-file-name "~/emacs/DIFE.exe")))
(if (eq system-type 'windows-nt)
(progn
(if (file-exists-p dife)
(w32-shell-execute nil dife)))))
(global-set-key [(kana)] 'toggle-input-method)
(global-set-key [(kanji)] 'hangul-to-hanja-conversion)
;; =============================================================================
;; 상태표시줄(status bar)에 디렉토리를 포함한 파일명 표시
;; =============================================================================
(setq-default mode-line-buffer-identification
(list 'buffer-file-name
(propertized-buffer-identification "%12f")
(propertized-buffer-identification "%12b")))
;; (add-hook 'dired-mode-hook
;; (lambda ()
;; ;; TODO: handle (DIRECTORY FILE ...) list value for dired-directory
;; (setq mode-line-buffer-identification
;; ;; emulate "%17b" (see dired-mode):
;; '(:eval
;; (propertized-buffer-identification
;; (if (< (length default-directory) 17)
;; (concat default-directory
;; (make-string (- 17 (length default-directory))
;; ?\s))
;; default-directory))))))
;==============================================================================
;; 최근 열었던 파일 가져오기
;==============================================================================
(recentf-mode 1)
(setq recentf-max-saved-items 1200)
;; 제외할 파일
(add-to-list 'recentf-exclude "Temporary Internet Files")
;; 자동 저장기능 활성화
;;(setq recentf-auto-save-timer
;; (run-with-idle-timer 30 t 'recentf-save-list))
(global-set-key [f12] 'recentf-open-files)
;; 탭키를 이용하여 최근 파일명 완성하기
(defun recentf-open-files-compl ()
(interactive)
(let* ((all-files recentf-list)
(tocpl (mapcar (function
(lambda (x) (cons (file-name-nondirectory x) x))) all-files))
(prompt (append '("File name: ") tocpl))
(fname (completing-read (car prompt) (cdr prompt) nil nil)))
(find-file (cdr (assoc-string fname tocpl nil)))))
(global-set-key "\C-c\C-r" 'recentf-open-files-compl)
;==============================================================================
;; Auto Save & Backup File
;==============================================================================
(setq make-backup-files t)
(setq auto-save-default t)
(setq
make-backup-files t
backup-by-copying t
delete-old-versions t
kept-new-versions 10
kept-old-versions 10
version-control t) ;; Make numbered backups
;; create the autosave dir if necessary, since emacs won't.
(make-directory "~/.autosave.d/" t)
;; 디렉토리 설정
(setq
bacnkup-directory-alist `((".*" . ,"~/.autosave.d/"))
auto-save-file-name-transforms `((".*" ,"~/.autosave.d/" t))
tramp-auto-save-directory "~/.autosave.d/")
;; ftp 파일에 대해 백업파일 설정
(setq ange-ftp-auto-save 1) ;; only 0 or 1 (DO NOT USE t or nil !!!)
(setq ange-ftp-make-backup-files t)
;; auto-save every 100 input events
(setq auto-save-interval 100)
;; auto-save after 30 seconds idle time
(setq auto-save-timeout 30)
;; 상태표시줄에 시간 표시하기
(require 'time)
;;(setq display-time-24hr-format t)
;;(setq display-time-day-and-date t)
(setq display-time-string-forms
'(year "-" month "-" day
" " 24-hours ":" minutes
(if time-zone " (") time-zone (if time-zone ")")
(if mail " Mail" "")))
(display-time)
;==============================================================================
;; 버퍼 선택 툴
;==============================================================================
(require 'bs)
(global-set-key [C-tab] 'bs-show)
;;(global-set-key '[C-tab] 'bs-cycle-next)
;;(global-set-key [C-S-tab] 'bs-cycle-next)
;;(global-set-key [C-S-tab] 'bs-cycle-previous)
;; ("all" . bs-config--all)
;; ("files" . bs-config--only-files)
;; ("files-and-scratch" . bs-config--files-and-scratch)
;; ("all-intern-last" . bs-config--all-intern-last)
;; (setq bs-default-configuration "all")
(setq bs-default-configuration "files-and-scratch")
(defun my-bs--get-modification-time-string (_start-buffer _all-buffers)
"Return last modified time of file"
(let ((file (buffer-file-name)))
(if (and file (listp (visited-file-modtime)))
(if (eq (car (visited-file-modtime)) -1)
(string)
(format-time-string "%Y-%m-%d %H:%M:%S" (visited-file-modtime)))
(string))))
(setq bs-attributes-list
'(("" 1 1 left bs--get-marked-string)
("M" 1 1 left bs--get-modified-string)
("R" 2 2 left bs--get-readonly-string)
("Buffer" 50 50 left bs--get-name)
("" 2 2 left " ")
("Size" 8 8 right bs--get-size-string)
("" 2 2 left " ")
("Last Modified" 19 19 left my-bs--get-modification-time-string)
("" 2 2 left " ")
("Mode" 20 20 left bs--get-mode-name)
("" 2 2 left " ")
("File" 20 20 left bs--get-file-name)))
;; 특정 문자열 강조
(setq bs-mode-font-lock-keywords
(list
;; dev server
'("61.222.123.2" 0 font-lock-function-name-face)
;; prd server
'("219.212.111.94" 0 font-lock-keyword-face)
;;'("emacs" 0 font-lock-function-name-face)
;;'("scratch" 0 font-lock-keyword-face)
;;'("emacs" 0 font-lock-comment-face)
))
;==============================================================================
;; 비주얼 북마크
;; (필요 : https://github.com/joodland/bm)
;==============================================================================
(add-to-list 'load-path "~/my-lisp")
(require 'bm)
;; 모든 버퍼의 북마크로 이동한다
(setq bm-cycle-all-buffers t)
;; M$ Visual Studio key setup.
(global-set-key (kbd "<C-f2>") 'bm-toggle)
(global-set-key (kbd "<f2>") 'bm-next)
(global-set-key (kbd "<S-f2>") 'bm-previous)
(defun left-margin-mouse-get-line-at-click ()
(save-excursion
(let ((click-y (cdr (cdr (mouse-position))))
(line-move-visual-store line-move-visual))
(setq line-move-visual t)
(goto-char (window-start))
(next-line (1- click-y))
(setq line-move-visual line-move-visual-store)
;; If you are using tabbar substitute the next line with
;; (line-number-at-pos))))
(1+ (line-number-at-pos)))))
(defun left-margin-mouse-goto-line-at-click ()
(interactive)
(goto-line (left-margin-mouse-get-line-at-click)))
(defun left-margin-mouse-toggle-boomark ()
(interactive)
(left-margin-mouse-goto-line-at-click)
(bm-toggle))
;; 라인넘버 표시줄을 이용해 북마크한다.
(global-set-key (kbd "<left-margin> <down-mouse-1>") 'left-margin-mouse-goto-line-at-click)
(global-set-key (kbd "<left-margin> <mouse-1>") 'bm-toggle)
;; =============================================================================
;; 패키지 시스템(MELPA)
;; =============================================================================
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t))
;; ===========================================================================
;; NeoTree Setting ;; 패키지 시스템 설정후 네오트리 다운로드
;; ===========================================================================
(add-to-list 'load-path "~/.emacs.d/elpa/neotree-20161228.1739/")
(require 'neotree)
;; 아이콘 사용안함
(setq neo-theme 'ascii)
;; 폭을 40으로 지정
(setq neo-window-width 30)
(define-key global-map (kbd "C-x t") 'neotree-toggle)
;; =============================================================================
;; auto-complete ;; 패키지 시스템 설정후 오토 컴플릿트 다운로드
;; =============================================================================
(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-20150408.1132/")
(require 'auto-complete)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20161029.643/dict")
(setq ac-comphist-file "~/.emacs.d/elpa/auto-complete-20161029.643/ac-comphist.dat")
;; 자동완성 활성화
(global-auto-complete-mode t)
;; 자동완성 목록만 표시
(setq ac-expand-on-auto-complete nil)
;; TAB 키 누르면 자동완성 시작
(ac-set-trigger-key "TAB")
;; 5글자 입력시 자동완성 시작
(setq ac-auto-start 5)
;; 자동완성 후보목록
(setq ac-auto-show-menu t) ;; 목록 표시함
;; (setq ac-auto-show-menu nil) ;; 목록 표시않함
;; (setq ac-auto-show-menu 0.2) ;; 0.2 초 후 목록 표시함
(setq ac-menu-height 10) ;; 10 lines
;; 대소문자
;; (setq ac-ignore-case t) ;; 구분않함
(setq ac-ignore-case 'smart) ;; 입력값에 대문자가 있을 경우에만 구분
;; (setq ac-ignore-case nil) ;; 항상 구분
(set-face-foreground 'ac-candidate-face "blue4")
(set-face-background 'ac-candidate-face "DodgerBlue1")
(set-face-foreground 'ac-selection-face "white")
(set-face-background 'ac-selection-face "steelblue")
(set-face-foreground 'ac-completion-face "white")
(set-face-background 'ac-completion-face "black")
;==============================================================================
;; AUTO COMPLETE CLANG
;; 패키지 시스템(MELPA) 을 이용해 설치한다.
;==============================================================================
(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-clang-20140409.52/")
(require 'auto-complete-clang)
(defcustom mycustom-system-include-paths '("./include/" "/opt/local/include" "/usr/include" )
"This is a list of include paths that are used by the clang auto completion."
:group 'mycustom
:type '(repeat directory)
)
(setq clang-completion-suppress-error 't)
(setq ac-clang-flags
(mapcar (lambda (item)(concat "-I" item))
(append mycustom-system-include-paths)))
;; =============================================================================
;; yasnippet ;; 다운로드후 설정
;; =============================================================================
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-20161221.1953/")
(require 'yasnippet)
(setq yas/root-directory "~/.emacs.d/elpa/yasnippet-20161221.1953/snippets")
;; yasnippet 활성화
(yas-global-mode 1)
;; =============================================================================
;; cscope cscope 설치후 cscope-indexer 설치후 MELPA를 이용하여 xcscope설치한다.
;; =============================================================================
(require 'xcscope)
;; 이맥스가 cscope 를 인식하지 못하면 아래 내용을 추가해준다.
;; (setq cscope-program "/usr/local/bin/cscope.exe")
(cscope-setup)
;; =============================================================================
;; autopair
;; (필요 : MELPA, autopair)
;; =============================================================================
(require 'autopair)
;; autopair 활성화
(autopair-global-mode)
;; source - header 간 이동
;;(add-hook 'c-mode-common-hook
;; (lambda()
;; (local-set-key (kbd "C-c o") 'ff-find-other-file)))
;==============================================================================
;; 윈도우 위치 & 사이즈 설정(GUI 버전)
;==============================================================================
(toggle-frame-maximized)
;; =============================================================================
;; zenburn-theme
;; (필요 : MELPA, zenburn-theme)
;; =============================================================================
(require 'zenburn-theme)
(load-theme 'zenburn t)
;;(Set-face-attribute 'region nil :background "#666")
(set-face-attribute 'region nil :background "#4169e1")
(set-face-attribute 'isearch nil :background "#4169e1")
(set-face-background 'hl-line "MidnightBlue")
(add-hook 'objc-mode-hook 'my-objc-mode-hook)
(defun my-objc-mode-hook()
"My Objc customisations."
(setq ff-search-directories '(".")
ff-other-file-alist '(("\\.m$" (".h"))
("\\.h$" (".m"))))
(local-set-key (kbd "C-c f") 'ff-find-other-file))
;; =============================================================================
;; 영역 들여쓰기
;; =============================================================================
(defun my-indent-block()
(interactive)
(if mark-active
(my-shift-region tab-width)
(if (minibuffer-selected-window)
(minibuffer-complete)
(insert-tab))))
(defun my-unindent-block()
(interactive)
(if mark-active
(my-shift-region (- tab-width))
(message "do nothing for <backtab> key.")))
(defun my-shift-region(numcols)
"shift selected region"
(my-make-region-as-full-line)
(if mark-active
(save-excursion
(indent-rigidly (region-beginning) (region-end) numcols)
(setq deactivate-mark nil))))
(defun my-make-region-as-full-line()
"expand the region to the beginning and end of the area selected"
(when mark-active
(if (< (point) (mark))
(when (not(bolp))
(beginning-of-line)
(exchange-point-and-mark)
(end-of-line)))
(if (< (mark) (point))
(when (not(eolp))
(end-of-line)
(exchange-point-and-mark)
(beginning-of-line)))))
(define-key global-map (kbd "<tab>") 'my-indent-block)
(define-key global-map (kbd "<backtab>") 'my-unindent-block) ;;백탭 (쉐프트 탭)
;;파일 찾기
(define-key global-map (kbd "C-c f") 'find-name-dired)
'리눅스(ubuntu) > Emacs 관련' 카테고리의 다른 글
이맥스 관련 자료 모음 (0) | 2017.01.08 |
---|---|
관련 사이트 (0) | 2017.01.08 |
gtags 리눅스상에서 설치 (0) | 2017.01.06 |
이멕스 단축키 (0) | 2017.01.02 |
이멕스 초기 설정하기 (0) | 2017.01.02 |