본문 바로가기
개발툴

.emacs

by 감자최고 2022. 3. 16.

(tool-bar-mode -1); hide tool-bar for using screen wider
(setq visible-bell t) ; disable beep sound (ex. when tryping scrolling beyond boundary. This blocks X11 connection and is very annoying)
;(global-set-key key binding)
;≡
;(define-key (current-global-map) key binding)
;(global-set-key (kbd "C-x C-\\") 'next-line)
;or
;(global-set-key [?\C-x ?\C-\\] 'next-line)
;or
;(global-set-key [(control ?x) (control ?\\)] 'next-line)

(global-set-key [\C-f10] 'previous-buffer)
(global-set-key [\C-f11] 'next-buffer)
(global-set-key [\C-f9] 'revert-buffer)
(global-set-key [\C-f6] 'shell)
(global-set-key [\C-f12] 'call-last-kbd-macro)
(global-set-key [\C-left] 'backward-sexp)
(global-set-key [\C-right] 'forward-sexp)
(column-number-mode )
(global-set-key [f2] 'goto-line)
(global-set-key [f5] 'find-tag)
(global-set-key [f6] 'find-tag-other-window)
(global-set-key [f7] 'tags-search)
(global-set-key [f8] 'grep)

(setq-default c-basic-offset 8
      tab-width 8
      indent-tabs-mode t)

(setq c-default-style "linux"
      c-basic-offset 8)
;(setq-default tab-width 8)

(require 'cl)

(defun ljh-forward-kill-smartexp ()
  "Kill following [ \\t]s if the cursor is on [ \\t].
or kill following [ \\t\\r\\n]s if the cursor is on [ \\r\\n].
or kill following sexps if the cursor is on '(' or '{' or '[' or ''' or '\"'.
or kill following word for the other cases."  
  (interactive "*")
  (save-excursion
    (save-restriction
      (save-match-data
(cond
 ((eobp) ;(message "eobp")
  )
 ((cl-search (string (following-char)) " \t")
  (progn ;(message "[ \\t]")
 (let ((orig-pos (point)))
   (delete-region
    orig-pos
    (progn (skip-chars-forward " \t")
   (constrain-to-field nil orig-pos t))))))
 ((cl-search (string (following-char)) "\r\n")
  (progn ;(message "[\\r\\n]")
 (let ((orig-pos (point)))
   (delete-region
    orig-pos
    (progn (skip-chars-forward " \t\r\n")
   (constrain-to-field nil orig-pos t))))))
 ((cl-search (string (following-char)) "\(\{\[\'\"")
  (progn ;(message "[\\(\\{\\[\\'\\\"]")
 (kill-sexp)))
 (t (progn ;(message )
 (kill-word 1)))
 )))))

(defun ljh-backward-kill-smartexp ()
  "Kill preceding [ \\t]s if the cursor is on [ \\t].
or kill preceding [ \\t\\r\\n]s if the cursor is on [\\r\\n].
or kill preceding sexps if the cursor is on')' or '}' or ']' or ''' or '\"'.
or kill preceding word for the other cases."  
  (interactive "*")
  (save-excursion
    (save-restriction
      (save-match-data
(cond    
 ((bobp) ;(message "bobp")
  )
 ((cl-search (string (preceding-char)) " \t")
  (progn ;(message "[ \\t]")
 (let ((orig-pos (point)))
   (delete-region
    orig-pos
    (progn (skip-chars-backward " \t")
   (constrain-to-field nil orig-pos t))))))
 ((cl-search (string (preceding-char)) "\r\n")
  (progn ;(message "[\\r\\n]")
 (let ((orig-pos (point)))
   (delete-region
    orig-pos
    (progn (skip-chars-backward " \t\r\n")
   (constrain-to-field nil orig-pos t))))))
 ((cl-search (string (preceding-char)) "\)\}\]\'\"")
  (progn ;(message "[\\)\\}\\]\\'\\\"]")
 (backward-kill-sexp)))
 (t (progn ;(message "no matchet")
   (backward-kill-word 1)))
 )))))

(global-set-key [C-delete] 'ljh-forward-kill-smartexp)
(global-set-key [C-backspace] 'ljh-backward-kill-smartexp)

;; put all backup files into ~/MyEmacsBackups
(setq backup-directory-alist '(("." . "~/MyEmacsBackups")))
(setq backup-by-copying t)

댓글