;; ####################################### MODES FOR ADDITIONAL FILE EXTENTIONS #######################################
(add-to-list 'auto-mode-alist '("\\.bb\\'" . makefile-mode))
(add-to-list 'auto-mode-alist '("\\.spec\\'" . makefile-mode))
(add-to-list 'auto-mode-alist '("\\.con\\'" . c-mode))
(setq custom-safe-themes t)
(setq package-enable-at-startup nil) ; To avoid initializing twice
(setq save-interprogram-paste-before-kill t)
;;(global-unset-key (kbd "M-,"))
; (global-set-key (kbd "M-,") 'find-next-tag)
(fset 'yes-or-no-p 'y-or-n-p)
(global-set-key (kbd "C-<right>") 'forward-word)
(global-set-key (kbd "C-<left>") 'backward-word)
(setq make-backup-files nil) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# file
(global-set-key (kbd "C-x \\") 'align-regexp)
(global-set-key (kbd "S-<right>") 'move-cursor-next-pane)
(global-set-key (kbd "S-<left>") 'move-cursor-previous-pane)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-c\C-c" 'compile)
(global-set-key "\C-c\C-k" 'indent-for-comment)
(global-set-key "\C-c\C-l" 'indent-new-comment-line)
(global-set-key "\C-c\C-s" 'kill-compilation)
(global-set-key "\C-c\M-b" 'emu-backend-find)
(global-set-key "\C-co" 'switch-to-minibuffer) ;; Bind to `C-c o'
(define-key global-map "\C-c\C-w" 'my-insert-word-regexp)
(global-set-key [(shift f1)] 'next-error)
(define-key global-map [f1] '(lambda () (interactive) (switch-to-buffer "*ansi-term*") (delete-other-windows)))
(define-key global-map [f3] 'git-status)
(define-key global-map [f4] 'find-tag-at-point) ;; etags find...
(define-key global-map [f5] 'revert-buffer)
(define-key global-map [f6] 'show-menu-and-line)
(define-key global-map [f7] 'repeat-complex-command)
(define-key global-map [f9] 'manual-entry) ;; man <command>
;; (define-key global-map [f10]'cleanuptabs-buffer)
(define-key global-map [f11]'grep)
(global-set-key [(shift f12)] 'toolbar-com);; pile
(define-key global-map [f27]'beginning-of-buffer)
(define-key global-map [f29]'scroll-down)
(define-key global-map [f33]'end-of-buffer)
(define-key global-map [f35]'scroll-up)
(global-unset-key [home])
(global-unset-key [end])
(define-key function-key-map [home] 'beginning-of-buffer)
(define-key function-key-map [end] 'end-of-buffer)
(setq linum-format "%d ")
;; enable linum-mode for all the buffers except some specific ones
(define-global-minor-mode my-global-linum-mode linum-mode
(lambda ()
(when (not (memq major-mode
(list 'term-mode)))
(linum-mode))))
(my-global-linum-mode 1)
;; window navigation
;; (global-set-key (kbd "S-<right>") 'other-window)
;; (global-set-key (kbd "S-<left>") 'prev-window)
;; Comment/uncomment current line
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)
(next-line)))
(global-set-key (kbd "C-c C-v") 'comment-or-uncomment-region-or-line)
;; DEBUGGING
;; (toggle-debug-on-error 1)
;; Mode line config
(column-number-mode 1)
;; hide default TOOLBAR
(hide-ifdef-mode 1)
;; hightlight brackets
(show-paren-mode t)
;; disable toolbar
(tool-bar-mode -1)
;; hightlight current line
(global-hl-line-mode 1)
;; Suppress starting emacs message
(setq inhibit-startup-message 1)
;;Displays the current function name in the mode line
(which-function-mode 1)
(menu-bar-mode 0)
(scroll-bar-mode 0)
;;Show current ifdef
;;(setq which-func-functions '(name-of-current-conditional))
;; Top frame: <filename with full path>
(setq frame-title-format "%b")
;; Cursor color
;; (set-cursor-color "red")
(blink-cursor-mode 0)
(defvar x-strech-cursor)
(setq x-strech-cursor 1)
;; Overwrite selected text
(delete-selection-mode 1)
;; Copy/paste from another system apps
(setq x-select-enable-clipboard t)
;; scrolling speed
;; (setq mouse-wheel-scroll-amount '(2 ((shift) . 2) ((control) . nil)))
(setq mouse-wheel-progressive-speed nil)
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
(use-package undo-tree
:ensure t
:diminish undo-tree-mode
:init
(global-undo-tree-mode)
)
(use-package hungry-delete
:ensure t
:diminish hungry-delete-mode
:config (global-hungry-delete-mode))
(use-package aggressive-indent
:ensure t
:init
(progn
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
(add-hook 'css-mode-hook #'aggressive-indent-mode)
(add-hook 'c-mode-hook #'aggressive-indent-mode)
(add-hook 'c++-mode-hook #'aggressive-indent-mode)
(add-hook 'css-mode-hook #'aggressive-indent-mode)
(add-hook 'shell-script-mode #'aggressive-indent-mode)
)
)
(use-package expand-region
:ensure t
:init
;; disable M-q "fill paragraph"
(defun my-expand-region-bind-hook()
(local-unset-key (kbd "M-q"))
)
(add-hook 'c-mode-hook 'my-expand-region-bind-hook)
(add-hook 'c++-mode-hook 'my-expand-region-bind-hook)
:config
;; expand region seems to be not working properly with this mode enabled
(setq shift-select-mode nil)
:bind
("M-q" . er/expand-region)
)
(use-package smartparens
:ensure t)
(use-package iedit
:ensure t)
(use-package visual-regexp
:ensure t
:bind
(("C-c r" . vr/replace)
("C-c q" . vr/query-replace)
("C-c m" . vr/mc-mark)
)
)
(use-package ialign
:ensure t)
(use-package wgrep
:ensure t
:config
(setq wgrep-enable-key "r"))
(use-package move-text
:ensure t
:init
(move-text-default-bindings)
)
(use-package ag
:ensure t)
(use-package ivy
:ensure t
:diminish ivy-mode
:config
(setq ivy-format-function 'ivy-format-function-arrow)
;; change face to highlighting instead of default underlining
(set-face-attribute 'ivy-current-match nil :background "#000000" :underline nil)
)
Needed for nicer counsel
(use-package smex
:ensure t
:init
(smex-initialize)
)
(use-package counsel
:ensure t
:bind
(("M-y" . counsel-yank-pop)
:map ivy-minibuffer-map
("M-y" . ivy-next-line)
)
)
(use-package counsel-projectile
:ensure t)
(use-package swiper
:ensure t
:bind
(("\C-s" . swiper)
("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("<f2> f" . counsel-describe-function)
("<f2> v" . counsel-describe-variable))
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(setq ivy-display-style 'fancy)
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
)
)
(defalias 'list-buffers 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq ibuffer-saved-filter-groups
(quote (("default"
("dired" (mode . dired-mode))
("org" (mode . org-mode))
("magit" (name . "^magit.*$"))
("shell" (or (mode . eshell-mode) (mode . shell-mode) (mode . shell-script-mode)))
("c/c++" (or
(mode . c++-mode)
(mode . c-mode)))
("tcl" (or
(mode . tcl-mode)
))
("log-files" (name . "^\\.log$|messages[.]?[1-9]*$"))
;; ("log-files" (name . "^\\.log$"))
("cnf-files" (name . "^\\.cnf$"))
("xml-files" (name . "^\\.xml$"))
("other-languages" (or
(mode . java-mode)
(mode . python-mode)
(mode . groovy-mode)
))
("emacs" (or
(name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$")))
("gdb" (or (mode . gdb-threads-mode) (mode . gud-mode) (mode . gdb-locals-mode) (mode . gdb-inferior-io-mode)))
))))
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-auto-mode 1)
(ibuffer-switch-to-saved-filter-groups "default")))
;; don't show these
;;(add-to-list 'ibuffer-never-show-predicates "zowie")
;; Don't show filter groups if there are no buffers in that group
(setq ibuffer-show-empty-filter-groups nil)
(use-package smooth-scrolling
:ensure t
:config
(smooth-scrolling-mode 1))
(use-package ace-window
:ensure t
:init
(global-set-key [remap other-window] 'ace-window)
)
(use-package xcscope
:ensure t
:config
(setq cscope-program "gtags-cscope")
:init
(cscope-setup))
(use-package ggtags
:ensure t
:hook ((c-mode c++-mode) . ggtags-mode)
)
(use-package flycheck
:ensure t
:diminish flycheck-mode
:init
(add-hook 'after-init-hook #'global-flycheck-mode)
:config
(use-package flycheck-irony
:ensure t
:init
(add-hook 'flycheck-mode-hook 'flycheck-irony-setup)
)
(setq-default flycheck-temp-prefix ".")
(setq-default temporary-file-directory "~/emacs-tmp")
)
(use-package flycheck-pos-tip
:ensure pos-tip
:config
(flycheck-pos-tip-mode)
)
(use-package flycheck-popup-tip
:ensure t
:config (eval-after-load 'flycheck
(if (display-graphic-p)
(flycheck-pos-tip-mode)
(flycheck-popup-tip-mode))))
;; load POPUP first
(use-package popup
:ensure t
)
(use-package auto-complete
:disabled t
:ensure t
:config
(ac-config-default)
:init
(setq ac-modes '(sh-mode emacs-lisp-mode lisp-mode lisp-interaction-mode python-mode))
)
(use-package company
:ensure t
:diminish company-mode
:defer t
:init
(defun company-term-hook ()
(company-mode -1)
)
(progn
(add-hook 'term-mode-hook 'company-term-hook)
(add-hook 'after-init-hook 'global-company-mode)
)
:config
(use-package company-irony
:ensure t
:defer t
:init
(add-to-list 'company-backends 'company-irony))
(use-package company-shell :ensure t
:init
(add-to-list 'company-backends '(company-shell company-shell-env company-fish-shell)))
(use-package company-quickhelp :ensure t
:config
(company-quickhelp-mode 1)
(setq company-quickhelp-delay 1)
:bind ("\C-c h" . #'company-quickhelp-manual-begin))
(setq company-idle-delay 0
company-minimum-prefix-length 2
company-show-numbers t
company-tooltip-limit 20
company-dabbrev-downcase nil
)
:bind ("\C-q" . company-complete-common)
)
(use-package yasnippet
:ensure t
:init
(setq yas-snippet-dirs
'("~/.emacs.d/snippets" ;; personal snippets
))
(yas-global-mode 1)
)
(use-package yasnippet-snippets
:ensure t)
(use-package irony
:ensure t
:init
:hook ((c++-mode c-mode objc-mode) . irony-mode)
:config
(defun my-irony-mode-hook ()
(define-key irony-mode-map [remap completion-at-point]
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
)
(add-hook 'c-mode-hook 'hide-ifdef-mode)
(use-package hideshow-org
:ensure t
:bind ("C-r" . hs-toggle-hiding))
;;(customize-variable (quote tab-stop-list))
(setq c-default-style "bsd"
c-basic-offset 4)
(custom-set-variables
'(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
;; don't indent "case" branch in "switch" according to coding style
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-offset 'case-label '0)))
(use-package diff-hl
:ensure t)
(use-package quickrun
:ensure t)
(use-package git-messenger
:ensure t
:config
(setq git-messenger:use-magit-popup t))
(use-package projectile
:ensure t
:init
(add-hook 'c-mode-hook 'projectile-mode)
)
(use-package treemacs
:ensure t
:defer t
:config
(progn
(use-package treemacs-evil
:ensure t
:demand t)
(setq treemacs-follow-after-init t
treemacs-width 35
treemacs-indentation 2
treemacs-git-integration t
treemacs-collapse-dirs 3
treemacs-silent-refresh nil
treemacs-change-root-without-asking nil
treemacs-sorting 'alphabetic-desc
treemacs-show-hidden-files t
treemacs-never-persist nil
treemacs-is-never-other-window nil
treemacs-goto-tag-strategy 'refetch-index)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t))
:bind
(:map global-map
([f8] . treemacs)
("M-0" . treemacs-select-window)
("C-c 1" . treemacs-delete-other-windows)
)
)
(use-package treemacs-projectile
:defer t
:ensure t
:config
(setq treemacs-header-function #'treemacs-projectile-create-header))
(use-package magit
:ensure t
:bind ("C-x g" . magit-status)
)
(use-package with-editor
:ensure t
)
(require 'with-editor)
(require 'magit)
(with-eval-after-load 'info
(info-initialize)
(add-to-list 'Info-directory-list
"~/.emacs.d/plugins/magit/Documentation/"))
(use-package gitignore-mode
:ensure t
)
(use-package gitconfig-mode
:ensure t
)
;; C-X M-X to wotk with M-X in ansi-term
;; xterm-mouse-mode to enable mouse moving
;; (define-key input-decode-map "\e[46;5u" (kbd "C-."))
;; (define-key input-decode-map "\e[44;5u" (kbd "C-,"))
;; (define-key input-decode-map "\e[60;6u" (kbd "C-<"))
;; (define-key input-decode-map "\e[62;6u" (kbd "C->"))
;; (define-key input-decode-map "\e[59;5u" (kbd "C-;"))
;; (define-key input-decode-map "\e[40;6u" (kbd "C-("))
;; (define-key input-decode-map "\e[41;6u" (kbd "C-)"))
;; (define-key input-decode-map "\e[49;5u" (kbd "C-1"))
;; (define-key input-decode-map "\e[39;5u" (kbd "C-'"))
;; (define-key input-decode-map "\e[45;5u" (kbd "C--"))
;; (define-key input-decode-map "\e[43;6u" (kbd "C-+"))
;; (define-key input-decode-map "\e[61;5u" (kbd "C-="))
;; (define-key input-decode-map "\e[63;6u" (kbd "C-?"))
(defun term-send-Cright ()
(interactive)
(term-send-raw-string "\e[1;5C"))
(defun term-send-Cleft ()
(interactive)
(term-send-raw-string "\e[1;5D"))
(defun term-send-C-dot ()
(interactive)
(term-send-raw-string "\e[27;5;46~"))
(defun fix-ansi-term-keys ()
(define-key term-raw-map (kbd "C-<right>") 'term-send-Cright)
(define-key term-raw-map (kbd "C-<left>") 'term-send-Cleft)
(define-key term-raw-map (kbd "C-.") 'term-send-C-dot)
;; (global-set-key (kbd "C-<right>") 'forward-word)
;; (global-set-key (kbd "C-<left>") 'backward-word)
)
(add-hook 'term-mode-hook 'fix-ansi-term-keys)
(defun fix-performance-bug ()
(setq bidi-paragraph-direction 'left-to-right))
(add-hook 'term-mode-hook 'fix-performance-bug)
;; to avoid problems with control codes
(defun my-term-use-utf8 ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(add-hook 'term-exec-hook 'my-term-use-utf8)
(defadvice ansi-term (after advise-ansi-term-coding-system)
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(ad-activate 'ansi-term)
(use-package org
:ensure t
:init
(add-hook 'org-mode-hook
(lambda ()
;; (org-set-local 'yas/trigger-key [tab])
(define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
)
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
;; for the presentations
(use-package ox-reveal
:ensure t
:config
(setq org-reveal-root "file:///home/xegodup/Tools/GitRepos/reveal.js"))
(use-package org-jira
:ensure t)
(setq org-capture-templates
'(("s" "Should try for emacs" entry (file+olp "/home/xegodup/Dropbox/org/orgzly/Emacs.org" "Should try")
"* TODO %?\n %i\n %T")
("m" "Modes" entry (file+olp "/home/xegodup/Dropbox/org/orgzly/Emacs.org" "Modes to be checked out")
"* TODO %?\n %i\n %T")
("j" "Journal" entry (file+olp+datetree "~/org/journal.org")
"* %?\nEntered on %U\n %i\n %a")))
(use-package diminish
:ensure t)
(use-package dashboard
:ensure t
:init
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
:config
(use-package page-break-lines
:ensure t)
(setq dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
(dashboard-setup-startup-hook))
(use-package groovy-mode
:ensure t
)
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown")
:config
(defun my-flymd-browser-function (url)
(let ((browse-url-browser-function 'browse-url-firefox))
(browse-url url)))
(setq flymd-browser-open-function 'my-flymd-browser-function)
)
(use-package flymd
:ensure t)
(use-package yaml-mode
:ensure t
)
(use-package smart-mode-line
:ensure t
:config
(sml/setup)
(setq sml/no-confirm-load-theme t)
)
(let ((which-func '(which-func-mode ("" which-func-format " "))))
(setq-default mode-line-format (remove which-func mode-line-format))
(setq-default mode-line-misc-info (remove which-func mode-line-misc-info))
(setq cell (last mode-line-format 7))
(setcdr cell
(cons which-func
(cdr cell))))
(use-package doom-modeline
:disabled t
:ensure t
:defer t
:hook (after-init . doom-modeline-init))
(use-package powerline
:disabled t
:ensure t
:config
(setq powerline-arrow-shape 'curve)
(set-face-attribute 'mode-line nil
:foreground "Black"
:background "DarkOrange"
:box nil)
)
(use-package spaceline
:disabled t
:ensure t
:init
(require 'spaceline-config)
(set-face-attribute 'mode-line nil :box nil)
(setq powerline-default-separator 'wave)
(spaceline-emacs-theme)
)
(use-package spaceline-config
;; :ensure spaceline
:disabled t
:config
(spaceline-helm-mode 1)
(spaceline-install
'main
'((buffer-modified :tight-right t)
((remote-host :tight-right t buffer-id :tight-right t) :face font-lock-keyword-face :tight-right t)
(line-column :face font-lock-preprocessor-face)
(which-function :face font-lock-function-name-face)
(version-control :when active :face font-lock-keyword-face)
(process :when active))
'((selection-info :face region :when mark-active)
((flycheck-error flycheck-warning flycheck-info) :when active)
(global :when active)
(major-mode :face error)))
)
(use-package which-key
:ensure t
:diminish which-key-mode
:config (which-key-mode))
;; All the buffers that haven’t been visited in 3 days will be killed
(require 'midnight)
(midnight-delay-set 'midnight-delay "4:30am")
(use-package htmlize
:ensure t
)
(use-package disaster
:ensure t
:bind ("C-c d" . disaster)
)
(use-package dired-rainbow
:ensure t)
(use-package rainbow-mode
:ensure t)
(use-package command-log-mode
:ensure t
:init
(setq command-log-mode-auto-show t))
(use-package cheatsheet
:ensure t)
(cheatsheet-add-group 'Marking
'(:key "C-SPC C-SPC" :description "Set mark at the point.")
'(:key "C-x C-x" :description "Go back to the mark.")
'(:key "C-u C-SPC" :description "Cycle through the mark ring of the current buffer.")
'(:key "C-x C-SPC" :description "Cycle through the global mark ring.")
'(:key "counseal-mark-ring" :description "Interactive cycle through the mark ring of the current buffer."))
(use-package flyspell-correct-ivy
:ensure t)
(use-package flyspell-correct-popup
:ensure t
:bind ("C-;" . flyspell-correct-previous-word-generic)
:config
(define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic))
(use-package google-translate
:ensure t
:config
(setq google-translate-default-target-language "ru"))
(use-package keyfreq
:ensure t
:init
(keyfreq-mode 1)
(keyfreq-autosave-mode 1)
)
(use-package speed-type
:ensure t)
(use-package dimmer
:ensure t
:config
(dimmer-mode))
(use-package zenburn-theme
:ensure t
:init (load-theme 'zenburn t))
(set-face-background 'show-paren-match "sea green")
(set-face-background 'show-paren-mismatch "orange red")
(set-face-foreground 'which-func "#93E0E3")
(set-face-background 'hl-line "gray5")
(set-face-foreground 'highlight nil)
(put 'downcase-region 'disabled nil)
;; hightlight function calls (they have default color otherwise)
(defvar font-lock-function-call-face
'font-lock-function-call-face
"Face name to use for format specifiers.")
(defface font-lock-function-call-face
'((t . (:foreground "orangered" :bold t)))
"Face to display method calls in.")
(font-lock-add-keywords
'c-mode
'(("\\(\\w+\\)\\s-*\("
(1 font-lock-function-call-face)))
t)
;; change 'select region' faces
(set-face-attribute 'region nil :background "#276E9E")
(set-face-attribute 'region nil :foreground "#FFFFFF")