Skip to content

Instantly share code, notes, and snippets.

@Morozov-5F
Created December 17, 2017 11:35
Show Gist options
  • Save Morozov-5F/44a8ffb68f7653466d0c90446af1e0b2 to your computer and use it in GitHub Desktop.
Save Morozov-5F/44a8ffb68f7653466d0c90446af1e0b2 to your computer and use it in GitHub Desktop.
Lightweight Emacs config
;; Enable package management
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;; Start Emacs server
(require 'server)
(unless (server-running-p)
(server-start))
;; 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)
;; 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)
;; Line wrapping
(setq word-wrap t)
(global-visual-line-mode t)
;; Indentation settings
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq-default c-default-style "bsd"
c-basic-offset 4
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)
;; Delete trailing whitespace on save
(add-to-list 'write-file-functions 'delete-trailing-whitespace)
;; 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)
;; Scrolling settings
(setq scroll-step 1)
(setq scroll-margin 10)
(setq scroll-conservatively 1000)
;; GNU Global Tags
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
(ggtags-mode 1))))
;; That simple -- global company mode
(global-company-mode)
;; Dynamic Abbrev (expanders)
(global-set-key (kbd "C-<tab>") 'dabbrev-expand)
(define-key minibuffer-local-map (kbd "C-<tab>") 'dabbrev-expand)
;; Setup CEDET
;; Code completion
(require 'cc-mode)
(require 'semantic)
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(semantic-mode 1)
;; Project management with EDE
(require 'cedet)
(global-ede-mode t)
(load-file "~/.emacs.d/cedet-projects.el")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment