Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
166 lines (125 sloc) 4.52 KB
;; Tested environment:
;; - Aquamacs 23.3 on OS X (install by manual)
;; - GNU Emacs 22.1.1 on OS X (ship with Apple)
;; - GNU Emacs 23.1.1 on Ubuntu 10.04 (package named emacs23-lucid)
;; - GNU Emacs 23.4.1 on Debian stable
;; - GNU Emacs 24.5.1 (x86_64-apple-darwin14.5.0, Carbon Version 157 AppKit 1348.17) of 2015-12-15 on bos-mp6ry, http://emacsformacosx.com/
;; share X11's clipboard
(setq x-select-enable-clipboard t)
(set-language-environment 'UTF-8)
(set-locale-environment "UTF-8")
;; http://www.gnu.org/software/emacs/manual/html_node/elisp/System-Environment.html
(cond
((string-equal system-type "windows-nt")
(progn
(message "Microsoft Windows")))
((string-equal system-type "darwin")
(progn
(message "Mac OS X"))
(set-face-attribute 'default nil :height 160)
)
((string-equal system-type "gnu/linux")
(progn
(message "Linux"))
(custom-set-faces '(default ((t (:height 140 :family "Consolas" :embolden t)))))
))
;; no linebreak
(setq default-fill-column 10000)
(add-hook 'text-mode-hook (lambda () (auto-fill-mode 0)))
(global-set-key [(f1)] 'delete-trailing-whitespace)
(defun duplicate-line()
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank)
)
(global-set-key (kbd "C-d") 'duplicate-line)
;; no X beep/bell
(setq visible-bell t)
;; no backup 'file~'
(setq make-backup-files nil)
;; no backup '#file'
(setq auto-save-default nil)
;; highline current line
(global-hl-line-mode t)
;; auto move mouse while cursor close to mouse
(mouse-avoidance-mode 'animate)
(transient-mark-mode t)
;; mouse cursor color
(setq-default cursor-type 'box)
;; highline matched brackets
(show-paren-mode t)
;; show column number in mini-buffer
(column-number-mode t)
;; (global-linum-mode t)
;; For Aquamacs
;; open file by dragging to an emacs window, http://goo.gl/kkxho
;;
(define-key global-map [ns-drag-file] 'ns-find-file)
;; http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/CodingStyle;hb=refs/heads/master
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces"
(let* ((anchor (c-langelem-pos c-syntactic-element))
(column (c-langelem-2nd-pos c-syntactic-element))
(offset (- (1+ column) anchor))
(steps (floor offset c-basic-offset)))
(* (max steps 1)
c-basic-offset)))
(add-hook 'c-mode-common-hook
(lambda ()
;; Add kernel style
(c-add-style
"linux-tabs-only"
'("linux" (c-offsets-alist
(arglist-cont-nonempty
c-lineup-gcc-asm-reg
c-lineup-arglist-tabs-only))))))
(add-hook 'c-mode-hook
(lambda ()
(let ((filename (buffer-file-name)))
;; Enable kernel mode for the appropriate files
(when (and filename
(string-match (expand-file-name "~/code/")
filename))
(setq indent-tabs-mode t)
(c-set-style "linux-tabs-only")))))
;; (if (file-exists-p "~/Downloads/lees_emacs_pkgs/cscope-15.8a/contrib/xcscope/xcscope.el")
;; (load-file "~/Downloads/lees_emacs_pkgs/cscope-15.8a/contrib/xcscope/xcscope.el")
;; (require 'xcscope)
;; )
(add-to-list 'load-path
"~/Downloads/lees_emacs_pkgs/yasnippet")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/Downloads/lees_emacs_pkgs/yasnippet/snippets")
(if (file-exists-p "~/Downloads/lees_emacs_pkgs/dot-mode.el")
(load-file "~/Downloads/lees_emacs_pkgs/dot-mode.el")
(require 'dot-mode)
(add-hook 'find-file-hooks 'dot-mode-on)
)
;; (if (file-exists-p "~/Downloads/lees_emacs_pkgs/eim.el")
;; (load-file "~/Downloads/lees_emacs_pkgs/eim.el")
;; )
;; (put 'upcase-region 'disabled nil)
;; (put 'set-goal-column 'disabled nil)
;; fix emacs bug for fcitx
(global-set-key (kbd "C-SPC") nil)
;; color & theme
;; http://lifegoo.pluskid.org/wiki/EmacsColorTheme.html
(load-file "~/Downloads/lees_emacs_pkgs/color-theme.el")
(require 'color-theme)
;; (color-theme-billw)
;; (color-theme-aalto-light)
;; http://stackoverflow.com/questions/4177929/how-to-change-the-indentation-width-in-emacs-javascript-mode
(setq js-indent-level 2)
;; http://stackoverflow.com/questions/4006005/how-can-i-set-emacs-tab-settings-by-file-type
(setq css-indent-offset 2)
(put 'upcase-region 'disabled nil)
(if (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives
'("elpy" . "http://jorgenschaefer.github.io/packages/"))
)