Skip to content

Instantly share code, notes, and snippets.

@Morozov-5F
Last active December 14, 2016 07:15
Show Gist options
  • Save Morozov-5F/0f6a70d4bae8554081cd84647696cb55 to your computer and use it in GitHub Desktop.
Save Morozov-5F/0f6a70d4bae8554081cd84647696cb55 to your computer and use it in GitHub Desktop.
My .emacs
;; System-type definition
(defun system-is-linux()
(string-equal system-type "gnu/linux"))
(defun system-is-windows()
(string-equal system-type "windows-nt"))
(defun system-is-osx()
(string-equal system-type "darwin"))
;; If linux or OSX, start emacs as server
(when (or (system-is-linux) (system-is-osx))
(require 'server)
(unless (server-running-p)
(server-start)))
(when (or (system-is-linux) (system-is-osx))
(add-to-list 'load-path "~/.emacs.d/plugins/"))
;; Git
;; (require 'git)
(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.
'(ansi-color-faces-vector [default default default italic underline success warning error])
'(ansi-color-names-vector ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"])
'(custom-safe-themes (quote ("b9b7551ad28ec3453c7ace2de0e21f4eef1c4b7d289c7b253b902f8df7f77b60" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" default)))
'(dtrt-indent-mode t nil (dtrt-indent))
'(inhibit-startup-screen t))
(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.
)
;; OSX bash_profile
(when (system-is-osx)
(add-hook 'after-init-hook 'exec-path-from-shell-initialize))
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(width . 100))
(when window-system (set-frame-size (selected-frame) 100 40))
;;(setq-default fill-column 80)
;; Package manager initialization
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(when (< emacs-major-version 24)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;; Credintials
(setq user-full-name "Eugene Morozov")
(setq user-mail-adress "[email protected]")
;; Name of current buffer in the title bar
(setq frame-title-format "GNU Emacs: %b")
;; Paren-mode
(show-paren-mode t)
;; Autoclosing brackets
(defvar electric-pair-modes-blacklist '(org-mode))
(defun inhibit-electric-pair-mode (char)
(member major-mode electric-pair-modes-blacklist))
(setq electric-pair-inhibit-predicate #'inhibit-electric-pair-mode)
(electric-pair-mode 1)
(electric-indent-mode -1)
;; Delete selection
(delete-selection-mode)
;; Dired
(require 'dired)
(setq dired-recursive-deletes 'top)
;; Imenu
(require 'imenu)
(setq imenu-auto-rescan t)
(setq imenu-use-popup-menu nil)
(global-set-key (kbd "<f6>") 'imenu)
;; Inhibit startup/splash screen
(setq inhibit-splash-screen t)
(setq inhibit-startup-message t) ;; C-h C-a shows help
;; Disable GUI components
(tooltip-mode -1)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(blink-cursor-mode -1)
(setq use-dialog-box nil)
(setq redisplay-dont-pause t)
(setq ring-bell-function 'ignore)
;; Disable auto-backups
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq auto-save-list-file-name nil)
;; Encodings
(set-language-environment 'UTF-8)
(if (or (system-is-linux) (system-is-osx))
(progn
(setq default-buffer-coding-system 'utf-8)
(setq-default coding-system-for-read 'utf-8)
(setq file-name-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(prefer-coding-system 'utf-8)))
;; Line numbers
(require 'linum)
(line-number-mode t)
(global-linum-mode t)
(column-number-mode t)
(setq linum-format "%4d \u2502 ")
;; Line wrapping
(setq word-wrap t)
(global-visual-line-mode t)
;; Start window size
;; (when (window-system)
;; (set-frame-size (selected-frame) 100 50))
;; Font config
;; (set-default-font "Menlo 16")
;; Buffer selection
(require 'bs)
(require 'ibuffer)
(defalias 'list-buffers 'ibuffer) ;; C-x C-b - buffer list
(global-set-key (kbd "<f2>") 'bs-show)
(c-add-style "LynxStyle"
'("bsd"
(c-basic-offset 3)
(c-offset-alist . (
(c .c-lineup-C-coments)
(statement-case-open .0)
(substatement-open .0)
(case-label .+)))
))
;; Indentation settings
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq-default c-default-style "bsd"
c-basic-offset 3
indent-tabs-mode nil)
(setq-default standart-indent 4)
(setq-default lisp-body-indent 4)
(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))
(global-set-key (kbd "RET") 'newline-and-indent)
;; Clipboard settings
(setq x-select-enable-clipboard t)
;; End of file newlines
(setq require-final-newline t)
(setq next-line-add-newlines nil)
;; Highlight search result
(setq search-highlight t)
(setq query-replace-highlight t)
;; M-arrow buffer transistions
(if (equal nil (equal major-mode 'org-mode))
(windmove-default-keybindings 'meta))
;; Delete trailing whitespaces, format buffer and untabify when save
(defun format-current-buffer()
(indent-region (point-min) (point-max)))
(defun untabify-current-buffer()
(if (not indent-tabs-mode)
(untabify (point-min) (point-max)))
nil)
;; (add-to-list 'write-file-functions 'format-current-buffer)
;; (add-to-list 'write-file-functions 'untabify-current-buffer)
(add-to-list 'write-file-functions 'delete-trailing-whitespace)
;; Bookmarks
(require 'bookmark)
(setq bookmark-save-flag t)
(when (file-exists-p (concat user-emacs-directory "bookmarks"))
(bookmark-load bookmark-default-file t))
(global-set-key (kbd "<f3>") 'bookmark-set)
(global-set-key (kbd "<f4>") 'bookmark-jump)
(global-set-key (kbd "<f5>") 'bookmark-bmenu-list)
(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
;; Scrolling settings
(setq scroll-step 1)
(setq scroll-margin 10)
(setq scroll-conservatively 1000)
;; Autocomplete
(defun ac-init()
(require 'auto-complete-config)
(ac-config-default)
(setq ac-auto-start t)
(setq ac-auto-show-menu t)
(global-auto-complete-mode t)
;; (add-to-list 'ac-modes 'c-mode)
(add-to-list 'ac-sources 'ac-source-semantic)
(add-to-list 'ac-sources 'ac-source-variables)
(add-to-list 'ac-sources 'ac-source-functions)
(add-to-list 'ac-sources 'ac-source-dictionary)
(add-to-list 'ac-sources 'ac-source-words-in-all-buffer)
(add-to-list 'ac-sources 'ac-source-files-in-current-dir))
(ac-init)
;; CEDET
(require 'cedet)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-show-parser-state-mode)
(semantic-mode t)
(global-ede-mode t)
(require 'ede/generic)
(require 'semantic/ia)
(ede-enable-generic-projects)
;; Custom color themes
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'gruvbox t)
;; Org-mode settings
(require 'org)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-set-key "\C-cl" 'org-store-link)
(setq org-log-done t)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;; Org root directory
(setq org-directory "~/org")
;; Org mobile directory
(setq org-mobile-directory "~/Dropbox/org/")
;; Org agenda files
(setq org-agenda-files (list "~/org/work.org"))
;; Enable encryption
(setq org-mobile-use-encryption t)
;; yasnippet config
(setq yas-snippet-dirs
'("~/.emacs.d/snippets"))
(yas-global-mode 1)
;; Fill column-indicator
(require 'fill-column-indicator)
(setq fci-rule-column 80)
(setq fci-rule-width 1)
(setq fci-mode t)
(add-hook 'c-mode-hook 'fci-mode)
(defun sanityinc/fci-enabled-p () (symbol-value 'fci-mode))
(defvar sanityinc/fci-mode-suppressed nil)
(make-variable-buffer-local 'sanityinc/fci-mode-suppressed)
(defadvice popup-create (before suppress-fci-mode activate)
"Suspend fci-mode while popups are visible"
(let ((fci-enabled (sanityinc/fci-enabled-p)))
(when fci-enabled
(setq sanityinc/fci-mode-suppressed fci-enabled)
(turn-off-fci-mode))))
(defadvice popup-delete (after restore-fci-mode activate)
"Restore fci-mode when all popups have closed"
(when (and sanityinc/fci-mode-suppressed
(null popup-instances))
(setq sanityinc/fci-mode-suppressed nil)
(turn-on-fci-mode)))
;; Neo Tree
;; (add-to-list 'load-path "/some/path/neotree")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; GNU Global Tags
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode 1))))
;; Emerge settings
(setq emerge-diff-options "--ignore-all-space")
;; Compile settings
(add-hook 'c-mode-common-hook
(lambda () (define-key c-mode-base-map (kbd "C-c C-RET") 'compile)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment