Skip to content

Instantly share code, notes, and snippets.

@KarthikNayak
Last active July 18, 2021 05:06
Show Gist options
  • Save KarthikNayak/7472966 to your computer and use it in GitHub Desktop.
Save KarthikNayak/7472966 to your computer and use it in GitHub Desktop.
Emacs Config File
;;packages
(load "package")
(package-initialize)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(setq package-archive-enable-alist '(("melpa" deft magit)))
;;disable auto save
(setq auto-save-default nil)
;;screen settings
(setq inhibit-splash-screen t)
(menu-bar-mode -1)
(tool-bar-mode -1)
(setq-default indicate-empty-lines t)
(when (not indicate-empty-lines)
(toggle-indicate-empty-lines))
(setq echo-keystrokes 0.1
use-dialog-box nil
visible-bell t)
(show-paren-mode t)
(setq column-number-mode t)
(global-linum-mode t)
(delete-selection-mode t)
(display-time-mode 1)
;;ac c headers
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers))
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
;;c helper
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
;;basic c stuff
(require 'cc-mode)
(setq-default c-basic-offset 8 c-default-style "linux")
(setq-default tab-width 8 indent-tabs-mode t)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
;;python
(require 'package)
(add-to-list 'package-archives
'("elpy" . "http://jorgenschaefer.github.io/packages/"))
(package-initialize)
(elpy-enable)
(elpy-use-ipython)
;;recentf
(require 'recentf)
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
(recentf-mode t)
(setq recentf-max-saved-items 50)
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
;;markdown
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdown$" . markdown-mode))
(add-hook 'markdown-mode-hook (lambda () (visual-line-mode t)))
(setq markdown-command "pandoc --smart -f markdown -t html")
;;details
(setq user-full-name "Karthik Nayak")
(setq user-mail-address "[email protected]")
;;no backup
(setq make-backup-files nil)
;;smex and ido for faster navigation
(setq smex-save-file (expand-file-name ".smex-items" user-emacs-directory))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(setq ido-use-filename-at-point 'guess)
(global-set-key
"\M-x"
(lambda ()
(interactive)
(call-interactively
(intern
(ido-completing-read
"M-x "
(all-completions "" obarray 'commandp))))))
;;yasnippet and ac
(require 'yasnippet)
(yas-global-mode 1)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/dict")
(ac-config-default)
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")
;;ac complete clang
(require 'auto-complete-clang)
(define-key c++-mode-map (kbd "C-S-q") 'ac-complete-clang)
;;fly check
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(add-hook 'after-init-hook #'global-flycheck-mode)
;;autopair
(require 'autopair)
(autopair-global-mode 1)
(setq autopair-autowrap t)
;;theme
(load-theme 'zenburn t)
;;gtags
(setq load-path (cons "/usr/share/emacs/site-lisp/gtags.el" load-path))
(autoload 'gtags-mode "gtags" "" t)
(add-hook 'c-mode-hook
'(lambda ()
(gtags-mode t)
))
;;; Enable helm-gtags-mode
(add-hook 'c-mode-hook 'helm-gtags-mode)
(add-hook 'c++-mode-hook 'helm-gtags-mode)
(add-hook 'asm-mode-hook 'helm-gtags-mode)
;; customize
(custom-set-variables
'(helm-gtags-path-style 'relative)
'(helm-gtags-ignore-case t)
'(helm-gtags-auto-update t))
;; key bindings
(eval-after-load "helm-gtags"
'(progn
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-find-tag)
(define-key helm-gtags-mode-map (kbd "M-'") 'helm-gtags-find-rtag)
(define-key helm-gtags-mode-map (kbd "M-;") 'helm-gtags-find-symbol)
(define-key helm-gtags-mode-map (kbd "M-g M-p") 'helm-gtags-parse-file)
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
(define-key helm-gtags-mode-map (kbd "M-*") 'helm-gtags-pop-stack)))
;;white space
(require 'whitespace)
(setq whitespace-line-column 80) ;; limit line length
(setq whitespace-style '(face lines-tail))
(add-hook 'prog-mode-hook 'whitespace-mode)
;;; .emacs ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment