Add config.org + replace setup-editing/general.el
This commit is contained in:
parent
ae07ba56ef
commit
3abf958cc8
7 changed files with 454 additions and 325 deletions
439
config.org
Normal file
439
config.org
Normal file
|
|
@ -0,0 +1,439 @@
|
||||||
|
#+STARTUP: overview
|
||||||
|
#+TITLE: My Emacs
|
||||||
|
#+CREATOR: Laurens Miers
|
||||||
|
#+LANGUAGE: en
|
||||||
|
[[./img/dash_logo.png]]
|
||||||
|
|
||||||
|
* Installation
|
||||||
|
|
||||||
|
My personal emacs configuration
|
||||||
|
|
||||||
|
(Heavily) Inspired by the following configs:
|
||||||
|
- https://github.com/tuhdo/emacs-c-ide-demo
|
||||||
|
- https://github.com/daedreth/UncleDavesEmacs
|
||||||
|
|
||||||
|
This configuration requires the installation of :
|
||||||
|
|
||||||
|
- the GNU =global= package (for gtags)
|
||||||
|
- =clang= (for ivory)
|
||||||
|
- =cmake= (for ivory)
|
||||||
|
- =llvm-libs= (for cmake, somehow not a dependency on Manjaro when installing cmake)
|
||||||
|
- Use python-pip to install =jedi=, =flake8=, =importmagic= and =autopep8= (for elpy)
|
||||||
|
- =ditaa= (for ascii to image generation in org-mode)
|
||||||
|
|
||||||
|
When first checking out this config, run =irony-install-server= to make and install the irony-server.
|
||||||
|
|
||||||
|
* General stuff
|
||||||
|
** Unsorted
|
||||||
|
|
||||||
|
Collection of stuff that needs to be sorted...someday....maybe...
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key (kbd "M-p") 'fill-paragraph)
|
||||||
|
#+END_SRC
|
||||||
|
** Macro's
|
||||||
|
|
||||||
|
Rebind the macro keys to Fx keys to give them a decent purpose.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key [f9] 'start-kbd-macro)
|
||||||
|
(global-set-key [f10] 'end-kbd-macro)
|
||||||
|
(global-set-key [f11] 'call-last-kbd-macro)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Goto-line
|
||||||
|
|
||||||
|
Starting with Emacs 23.2, =M-g g= is bound to goto-line.
|
||||||
|
However, I find this too long. So rebind it:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key (kbd "M-g") 'goto-line)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Rectangle
|
||||||
|
|
||||||
|
Most rectangle functions are by default mapped to something like =C-x r (other-char)=.
|
||||||
|
I use =string-insert-rectangle= and =query-replace-regexp= quite a lot,
|
||||||
|
so rebind it to something easy to remember.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key (kbd "C-x r i") 'string-insert-rectangle)
|
||||||
|
(global-set-key (kbd "C-x r r") 'query-replace-regexp)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Garbage collection (gc)
|
||||||
|
|
||||||
|
I used to have the following enabled in my init to increase the gc threshold to speed-up emacs startup:
|
||||||
|
(stolen from [[http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/]])
|
||||||
|
|
||||||
|
#+BEGIN_SRC
|
||||||
|
;; (setq gc-cons-threshold 100000000)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
But according to this: [[https://lists.gnu.org/archive/html/help-gnu-emacs/2007-06/msg00243.html ]],
|
||||||
|
it is no longer necessary.
|
||||||
|
|
||||||
|
** Yes-or-no questions
|
||||||
|
|
||||||
|
Because I'm lazy, important yes-or-no questions can be answered with y-or-n:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Emacs fullscreen at startup
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Multi-frame rebindings
|
||||||
|
|
||||||
|
Sometimes I have multiple emacs-frames open.
|
||||||
|
I prefer that the normal =C-x o= can deal with this.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
;; Use C-x o to switch to other frame when using multi-monitor
|
||||||
|
(global-set-key (kbd "C-x o") 'next-multiframe-window)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Now that =next-multiframe-window= is bound to =C-x o=,
|
||||||
|
Bind =C-x p= to =previous-multiframe-window=.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key (kbd "\C-x p") 'previous-multiframe-window)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Enable disabled commands
|
||||||
|
|
||||||
|
Some commands are disabled to protect the user.
|
||||||
|
Narrow-region/page is a really handy feature, enable it:
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(put 'narrow-to-page 'disabled nil)
|
||||||
|
(put 'narrow-to-region 'disabled nil)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Buffers
|
||||||
|
|
||||||
|
Why is this not built-in?
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun kill-all-buffers ()
|
||||||
|
"Kill all buffers without regard for their origin."
|
||||||
|
(interactive)
|
||||||
|
(mapc 'kill-buffer (buffer-list)))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Helping vim-users
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defconst wq "This is not vi! Use C-x C-c instead.")
|
||||||
|
(defconst w "This is not vi! Use C-x C-s instead.")
|
||||||
|
(defconst q! "This is EMACS not vi! Use C-x C-c instead.")
|
||||||
|
(defconst wq! "This is EMACS not vi! Use C-x C-c instead.")
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Theme
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package monokai-theme
|
||||||
|
:ensure t
|
||||||
|
:init
|
||||||
|
(load-theme 'monokai t)
|
||||||
|
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Highlight line
|
||||||
|
|
||||||
|
Highlight line will highlight the current line we are on.
|
||||||
|
Enable highlight-line globally and replace its background colour.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-hl-line-mode 1)
|
||||||
|
(set-face-background hl-line-face "dark slate grey")
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Dashboard
|
||||||
|
|
||||||
|
I use the dashboard as start screen.
|
||||||
|
Since I like it to give me a list of recent files, we need to enable =recentf-mode=.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package dashboard
|
||||||
|
:ensure t
|
||||||
|
:init
|
||||||
|
(recentf-mode 1)
|
||||||
|
:config
|
||||||
|
(dashboard-setup-startup-hook)
|
||||||
|
(setq dashboard-startup-banner "~/.emacs.d/img/dash_logo.png")
|
||||||
|
(setq dashboard-items '((recents . 10)
|
||||||
|
(bookmarks . 5)
|
||||||
|
))
|
||||||
|
(setq dashboard-banner-logo-title "")
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Zygospore
|
||||||
|
|
||||||
|
Revert =C-x 1= by pressing =C-x 1= again:
|
||||||
|
[[https://github.com/louiskottmann/zygospore.el]]
|
||||||
|
|
||||||
|
FYI: At one point, used this together with sr-speedbar. They did not play well together...
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package zygospore
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(global-set-key (kbd "C-x 1") 'zygospore-toggle-delete-other-windows)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Mode-line
|
||||||
|
|
||||||
|
[[https://github.com/Malabarba/smart-mode-line]]
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package smart-mode-line
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(setq sml/no-confirm-load-theme t)
|
||||||
|
(setq sml/theme 'powerline)
|
||||||
|
(sml/setup)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Editing settings
|
||||||
|
|
||||||
|
** Kill-ring customization
|
||||||
|
|
||||||
|
Setting =kill-whole-line= to non-nil means when we execute =C-k= at the beginning of a line
|
||||||
|
will the entire line including the following newline will be deleted.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq kill-ring-max 5000) ; increase kill-ring capacity
|
||||||
|
(setq kill-whole-line t)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Newline at end-of-file
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq mode-require-final-newline t) ; add a newline to end of file
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Enable column numbers
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq column-number-mode 1)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Look-and-feel modifications
|
||||||
|
|
||||||
|
Remove scroll-, tool- and menu-bar. I don't use them so free some space.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(scroll-bar-mode -1)
|
||||||
|
(tool-bar-mode -1)
|
||||||
|
(menu-bar-mode -1)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Tab-width
|
||||||
|
|
||||||
|
Set the default tab width.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq-default tab-width 4)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Automatic indent
|
||||||
|
|
||||||
|
Automatically indent when pressing =RET=.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(global-set-key (kbd "RET") 'newline-and-indent)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Delete trailing whitespace
|
||||||
|
|
||||||
|
Automatically delete trailing whitespace when saving a file.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Undo-tree
|
||||||
|
|
||||||
|
Undo with =C-/=.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package undo-tree
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(global-undo-tree-mode)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Volatile highlights
|
||||||
|
|
||||||
|
Show/highlight changes when doing undo/yanks/kills/...
|
||||||
|
|
||||||
|
https://github.com/k-talo/volatile-highlights.el
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package volatile-highlights
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(volatile-highlights-mode t)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* iedit
|
||||||
|
|
||||||
|
Highlight occurences of symbol and replace them simultanously.
|
||||||
|
Shortkey: =C-;=
|
||||||
|
|
||||||
|
https://github.com/victorhge/iedit
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package iedit
|
||||||
|
:ensure t
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Smartparens
|
||||||
|
|
||||||
|
Smart minor-mode to deal with pairs.
|
||||||
|
|
||||||
|
https://github.com/Fuco1/smartparens
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package smartparens
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(require 'smartparens-config)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; old config stuff
|
||||||
|
;; (setq sp-base-key-bindings 'paredit)
|
||||||
|
;; (setq sp-autoskip-closing-pair 'always)
|
||||||
|
;; (setq sp-hybrid-kill-entire-symbol nil)
|
||||||
|
;; (sp-use-paredit-bindings)
|
||||||
|
;;
|
||||||
|
;; (show-smartparens-global-mode +1)
|
||||||
|
;; (smartparens-global-mode 1)
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; keybinding management smartparens ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; cl-package contains the loop macro
|
||||||
|
;; (require 'cl)
|
||||||
|
;;
|
||||||
|
;; (defmacro def-pairs (pairs)
|
||||||
|
;; `(progn
|
||||||
|
;; ,@(loop for (key . val) in pairs
|
||||||
|
;; collect
|
||||||
|
;; `(defun ,(read (concat
|
||||||
|
;; "wrap-with-"
|
||||||
|
;; (prin1-to-string key)
|
||||||
|
;; "s"))
|
||||||
|
;; (&optional arg)
|
||||||
|
;; (interactive "p")
|
||||||
|
;; (sp-wrap-with-pair ,val)))))
|
||||||
|
;;
|
||||||
|
;; (def-pairs ((paren . "(")
|
||||||
|
;; (bracket . "[")
|
||||||
|
;; (brace . "{")
|
||||||
|
;; (single-quote . "'")
|
||||||
|
;; (double-quote . "\"")
|
||||||
|
;; (underscore . "_")
|
||||||
|
;; (back-quote . "`")))
|
||||||
|
;;
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c (") 'wrap-with-parens)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c [") 'wrap-with-brackets)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c {") 'wrap-with-braces)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c '") 'wrap-with-single-quotes)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c \"") 'wrap-with-double-quotes)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c _") 'wrap-with-underscores)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c `") 'wrap-with-back-quotes)
|
||||||
|
;;
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c s r") 'sp-rewrap-sexp)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-c s u") 'sp-unwrap-sexp)
|
||||||
|
;;
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
|
||||||
|
;;
|
||||||
|
;; ;; TODO: in manjaro this selects keyboard-layout or something
|
||||||
|
;; ;;(define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp)
|
||||||
|
;;
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-n") 'sp-next-sexp)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-p") 'sp-previous-sexp)
|
||||||
|
;;
|
||||||
|
;; ;; TODO: for some reason this does not work
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-a") 'sp-beginning-of-sexp)
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-e") 'sp-end-of-sexp)
|
||||||
|
;;
|
||||||
|
;; (define-key smartparens-mode-map (kbd "C-M-h") 'mark-defun)
|
||||||
|
;;
|
||||||
|
;; (smartparens-global-mode t)
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Comment-dwim-2
|
||||||
|
|
||||||
|
Replacement for built-in =comment-dwim=, more comment features.
|
||||||
|
|
||||||
|
https://github.com/remyferre/comment-dwim-2
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package comment-dwim-2
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(global-set-key (kbd "M-;") 'comment-dwim-2)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Yasnippet
|
||||||
|
|
||||||
|
Template system for Emacs.
|
||||||
|
|
||||||
|
https://github.com/joaotavora/yasnippet
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package yasnippet
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(add-to-list 'load-path
|
||||||
|
"~/.emacs.d/plugins/yasnippet")
|
||||||
|
(yas-global-mode 1)
|
||||||
|
)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Old stuff, maybe usefull for lookup later
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
;; show whitespace in diff-mode
|
||||||
|
;; (add-hook 'diff-mode-hook (lambda ()
|
||||||
|
;; (setq-local whitespace-style
|
||||||
|
;; '(face
|
||||||
|
;; tabs
|
||||||
|
;; tab-mark
|
||||||
|
;; spaces
|
||||||
|
;; space-mark
|
||||||
|
;; trailing
|
||||||
|
;; indentation::space
|
||||||
|
;; indentation::tab
|
||||||
|
;; newline
|
||||||
|
;; newline-mark))
|
||||||
|
;; (whitespace-mode 1)))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
* TODO
|
||||||
|
|
||||||
|
stuff i need to look into:
|
||||||
|
- ibuffer
|
||||||
|
- switch-window
|
||||||
|
- split-and-follow-vertically/horizontally
|
||||||
|
- which-key
|
||||||
|
- symon
|
||||||
|
- spaceline
|
||||||
|
- async
|
||||||
|
- exwm
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
(setq global-mark-ring-max 5000 ; increase mark ring to contains 5000 entries
|
|
||||||
mark-ring-max 5000 ; increase kill ring to contains 5000 entries
|
|
||||||
mode-require-final-newline t ; add a newline to end of file
|
|
||||||
)
|
|
||||||
|
|
||||||
(setq kill-ring-max 5000 ; increase kill-ring capacity
|
|
||||||
kill-whole-line t ; if NIL, kill whole line and move the next line up
|
|
||||||
)
|
|
||||||
|
|
||||||
;; show column numbers
|
|
||||||
(setq column-number-mode 1)
|
|
||||||
|
|
||||||
;; Remove scroll-bar, tool-bar and menu-bar
|
|
||||||
(scroll-bar-mode -1)
|
|
||||||
(tool-bar-mode -1)
|
|
||||||
(menu-bar-mode -1)
|
|
||||||
|
|
||||||
;; set appearance of a tab that is represented by 4 spaces
|
|
||||||
(setq-default tab-width 4)
|
|
||||||
|
|
||||||
;; automatically indent when press RET
|
|
||||||
(global-set-key (kbd "RET") 'newline-and-indent)
|
|
||||||
|
|
||||||
;; Map query-replace-regexp to an easier key
|
|
||||||
(global-set-key (kbd "C-x r r") 'query-replace-regexp)
|
|
||||||
|
|
||||||
;; Map query-replace-regexp to an easier key
|
|
||||||
(global-set-key (kbd "M-p") 'fill-paragraph)
|
|
||||||
|
|
||||||
;; Delete trailing whitespace when saving file
|
|
||||||
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
||||||
|
|
||||||
;; show whitespace in diff-mode
|
|
||||||
(add-hook 'diff-mode-hook (lambda ()
|
|
||||||
(setq-local whitespace-style
|
|
||||||
'(face
|
|
||||||
tabs
|
|
||||||
tab-mark
|
|
||||||
spaces
|
|
||||||
space-mark
|
|
||||||
trailing
|
|
||||||
indentation::space
|
|
||||||
indentation::tab
|
|
||||||
newline
|
|
||||||
newline-mark))
|
|
||||||
(whitespace-mode 1)))
|
|
||||||
|
|
||||||
;; Package: undo-tree -- saner, imo, undo with C-/
|
|
||||||
(require 'undo-tree)
|
|
||||||
(global-undo-tree-mode)
|
|
||||||
|
|
||||||
;; Package: volatile-highlights --- show changes by "undo/yanks/..."
|
|
||||||
(require 'volatile-highlights)
|
|
||||||
(volatile-highlights-mode t)
|
|
||||||
|
|
||||||
;;; Package: iedit --- Replace occurences of symbol and highlight them
|
|
||||||
(require 'iedit)
|
|
||||||
|
|
||||||
;; Package: smartparens --- smart way to handle (), {}, ...
|
|
||||||
(require 'smartparens-config)
|
|
||||||
(setq sp-base-key-bindings 'paredit)
|
|
||||||
(setq sp-autoskip-closing-pair 'always)
|
|
||||||
(setq sp-hybrid-kill-entire-symbol nil)
|
|
||||||
(sp-use-paredit-bindings)
|
|
||||||
|
|
||||||
(show-smartparens-global-mode +1)
|
|
||||||
(smartparens-global-mode 1)
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; keybinding management smartparens ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; cl-package contains the loop macro
|
|
||||||
(require 'cl)
|
|
||||||
|
|
||||||
(defmacro def-pairs (pairs)
|
|
||||||
`(progn
|
|
||||||
,@(loop for (key . val) in pairs
|
|
||||||
collect
|
|
||||||
`(defun ,(read (concat
|
|
||||||
"wrap-with-"
|
|
||||||
(prin1-to-string key)
|
|
||||||
"s"))
|
|
||||||
(&optional arg)
|
|
||||||
(interactive "p")
|
|
||||||
(sp-wrap-with-pair ,val)))))
|
|
||||||
|
|
||||||
(def-pairs ((paren . "(")
|
|
||||||
(bracket . "[")
|
|
||||||
(brace . "{")
|
|
||||||
(single-quote . "'")
|
|
||||||
(double-quote . "\"")
|
|
||||||
(underscore . "_")
|
|
||||||
(back-quote . "`")))
|
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c (") 'wrap-with-parens)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c [") 'wrap-with-brackets)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c {") 'wrap-with-braces)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c '") 'wrap-with-single-quotes)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c \"") 'wrap-with-double-quotes)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c _") 'wrap-with-underscores)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c `") 'wrap-with-back-quotes)
|
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c s r") 'sp-rewrap-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c s u") 'sp-unwrap-sexp)
|
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
|
|
||||||
|
|
||||||
;; TODO: in manjaro this selects keyboard-layout or something
|
|
||||||
;;(define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp)
|
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-n") 'sp-next-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-p") 'sp-previous-sexp)
|
|
||||||
|
|
||||||
;; TODO: for some reason this does not work
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-a") 'sp-beginning-of-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-e") 'sp-end-of-sexp)
|
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-h") 'mark-defun)
|
|
||||||
|
|
||||||
(smartparens-global-mode t)
|
|
||||||
|
|
||||||
|
|
||||||
;; Package: comment-dwim-2 --- replacement for built-in comment-dwim, more comment features
|
|
||||||
(require 'comment-dwim-2)
|
|
||||||
(global-set-key (kbd "M-;") 'comment-dwim-2)
|
|
||||||
|
|
||||||
|
|
||||||
;; Package: yasnippet --- code template system
|
|
||||||
(require 'yasnippet)
|
|
||||||
(yas-global-mode 1)
|
|
||||||
|
|
||||||
(provide 'setup-editing)
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
(global-set-key [f9] 'start-kbd-macro)
|
|
||||||
(global-set-key [f10] 'end-kbd-macro)
|
|
||||||
(global-set-key [f11] 'call-last-kbd-macro)
|
|
||||||
|
|
||||||
;; Package zygospore --- revert C-x 1 by pressing C-x 1 again
|
|
||||||
;; TODO: Doesn't work with sr-speedbar
|
|
||||||
(global-set-key (kbd "C-x 1") 'zygospore-toggle-delete-other-windows)
|
|
||||||
|
|
||||||
;; Set 'M-g' to 'goto-line', it's faster and what we usually want
|
|
||||||
(global-set-key (kbd "M-g") 'goto-line)
|
|
||||||
|
|
||||||
;; Set 'C-x r i' to 'string-insert-rectangle'
|
|
||||||
;; Easier than using 'M-x' and searching for it.
|
|
||||||
(global-set-key (kbd "C-x r i") 'string-insert-rectangle)
|
|
||||||
|
|
||||||
;; set garbage collection to higher value
|
|
||||||
;; see http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
|
|
||||||
(setq gc-cons-threshold 100000000)
|
|
||||||
|
|
||||||
;; important yes-or-no questions can be answered with y-or-n
|
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
||||||
|
|
||||||
;; maximize Emacs at startup
|
|
||||||
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
|
||||||
|
|
||||||
;; Move one window back command
|
|
||||||
(global-set-key (kbd "\C-x p") 'previous-multiframe-window)
|
|
||||||
|
|
||||||
;; Use C-x o to switch to other frame when using multi-monitor
|
|
||||||
(global-set-key (kbd "C-x o") 'next-multiframe-window)
|
|
||||||
|
|
||||||
;; set my theme
|
|
||||||
(load-theme 'wombat)
|
|
||||||
|
|
||||||
;; highlight line (hl-line)
|
|
||||||
(global-hl-line-mode 1)
|
|
||||||
(set-face-background hl-line-face "dark slate grey")
|
|
||||||
|
|
||||||
;; smart mode line
|
|
||||||
(setq sml/no-confirm-load-theme t)
|
|
||||||
(setq sml/theme 'powerline)
|
|
||||||
(sml/setup)
|
|
||||||
|
|
||||||
;; enable disabled commands
|
|
||||||
(put 'narrow-to-page 'disabled nil)
|
|
||||||
(put 'narrow-to-region 'disabled nil)
|
|
||||||
|
|
||||||
;; quick function to kill all other buffers
|
|
||||||
(defun kill-other-buffers ()
|
|
||||||
"Kill all other buffers."
|
|
||||||
(interactive)
|
|
||||||
(mapc 'kill-buffer
|
|
||||||
(delq (current-buffer)
|
|
||||||
(remove-if-not 'buffer-file-name (buffer-list)))))
|
|
||||||
|
|
||||||
;; screw with vi(m)-users
|
|
||||||
(defconst wq "This is not vi! Use C-x C-c instead.")
|
|
||||||
(defconst w "This is not vi! Use C-x C-s instead.")
|
|
||||||
(defconst q! "This is EMACS not vi! Use C-x C-c instead.")
|
|
||||||
(defconst wq! "This is EMACS not vi! Use C-x C-c instead.")
|
|
||||||
|
|
||||||
(provide 'setup-general)
|
|
||||||
BIN
img/dash_logo.png
Normal file
BIN
img/dash_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
141
init.el
141
init.el
|
|
@ -1,152 +1,39 @@
|
||||||
|
|
||||||
;; add the custom dir to our load path
|
|
||||||
(add-to-list 'load-path "~/.emacs.d/custom")
|
|
||||||
|
|
||||||
;; add melpa-stable to package-archives
|
|
||||||
;; IMPORTANT: add (require 'package), else package-archives is not declared (void-variable)
|
;; IMPORTANT: add (require 'package), else package-archives is not declared (void-variable)
|
||||||
(require 'package)
|
(require 'package)
|
||||||
|
|
||||||
|
(setq package-enable-at-startup nil)
|
||||||
|
|
||||||
|
;; add melpa-stable to package-archives
|
||||||
(add-to-list 'package-archives
|
(add-to-list 'package-archives
|
||||||
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
||||||
|
|
||||||
(add-to-list 'package-archives
|
|
||||||
'("melpa" . "http://melpa.milkbox.net/packages/") t)
|
|
||||||
|
|
||||||
;; MUST be called after package-archives is updated
|
;; MUST be called after package-archives is updated
|
||||||
;; Else the automated installation logic is not able to install missing packages
|
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
|
|
||||||
;; my required packages
|
;;; Bootstrapping use-package
|
||||||
(defconst my-packages
|
(unless (package-installed-p 'use-package)
|
||||||
'(
|
(package-refresh-contents)
|
||||||
undo-tree
|
(package-install 'use-package))
|
||||||
volatile-highlights
|
|
||||||
smartparens
|
|
||||||
iedit
|
|
||||||
zygospore
|
|
||||||
comment-dwim-2
|
|
||||||
yasnippet
|
|
||||||
yasnippet-snippets
|
|
||||||
sr-speedbar
|
|
||||||
company
|
|
||||||
irony
|
|
||||||
irony-eldoc
|
|
||||||
company-irony
|
|
||||||
flycheck-irony
|
|
||||||
elpy
|
|
||||||
py-autopep8
|
|
||||||
magit
|
|
||||||
org
|
|
||||||
smart-mode-line
|
|
||||||
smart-mode-line-powerline-theme
|
|
||||||
helm
|
|
||||||
helm-gtags
|
|
||||||
helm-swoop
|
|
||||||
helm-company
|
|
||||||
dashboard
|
|
||||||
multiple-cursors
|
|
||||||
expand-region
|
|
||||||
))
|
|
||||||
|
|
||||||
;; function to install new packages
|
;;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch.
|
||||||
(defun install-packages ()
|
(when (file-readable-p "~/.emacs.d/config.org")
|
||||||
"Install all required packages."
|
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
|
||||||
(interactive)
|
|
||||||
(unless package-archive-contents
|
|
||||||
(package-refresh-contents))
|
|
||||||
(dolist (package my-packages)
|
|
||||||
(unless (package-installed-p package)
|
|
||||||
(package-install package))))
|
|
||||||
|
|
||||||
;; install packages if not yet installed
|
|
||||||
(install-packages)
|
|
||||||
|
|
||||||
;; setup general
|
|
||||||
(require 'setup-general)
|
|
||||||
|
|
||||||
;; setup general editing settings
|
|
||||||
(require 'setup-editing)
|
|
||||||
|
|
||||||
;; setup org
|
|
||||||
(require 'setup-org)
|
|
||||||
|
|
||||||
;; setup coding
|
|
||||||
(require 'setup-coding)
|
|
||||||
|
|
||||||
;; setup helm
|
|
||||||
(require 'setup-helm)
|
|
||||||
(require 'setup-helm-gtags)
|
|
||||||
|
|
||||||
;; setup speedbar
|
|
||||||
(require 'setup-speedbar)
|
|
||||||
|
|
||||||
;; setup autocompletion
|
|
||||||
(require 'setup-autocompletion)
|
|
||||||
|
|
||||||
;; setup Windows if our bootloader is Windows
|
|
||||||
(if (eq system-type 'windows-nt)
|
|
||||||
(require 'setup-windows)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; setup dashboard
|
|
||||||
(require 'setup-dashboard)
|
|
||||||
|
|
||||||
;; setup gdb
|
|
||||||
(require 'setup-gdb)
|
|
||||||
|
|
||||||
;; setup multiple cursors
|
|
||||||
(require 'setup-cursors)
|
|
||||||
|
|
||||||
;; setup expand-region
|
|
||||||
(require 'setup-expand-region)
|
|
||||||
|
|
||||||
;; start emacs server
|
|
||||||
(server-start)
|
|
||||||
|
|
||||||
|
(provide 'init)
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; 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
|
|
||||||
["#757575" "#CD5542" "#4A8F30" "#7D7C21" "#4170B3" "#9B55C3" "#68A5E9" "gray43"])
|
|
||||||
'(custom-safe-themes
|
'(custom-safe-themes
|
||||||
(quote
|
(quote
|
||||||
("84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279" "c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223" "3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" "938d8c186c4cb9ec4a8d8bc159285e0d0f07bad46edf20aa469a89d0d2a586ea" "6de7c03d614033c0403657409313d5f01202361e35490a3404e33e46663c2596" "ed317c0a3387be628a48c4bbdb316b4fa645a414838149069210b66dd521733f" "1db337246ebc9c083be0d728f8d20913a0f46edc0a00277746ba411c149d7fe5" default)))
|
("5f27195e3f4b85ac50c1e2fac080f0dd6535440891c54fcfa62cdcefedf56b1b" default)))
|
||||||
'(fci-rule-color "#2e2e2e")
|
|
||||||
'(global-company-mode t)
|
|
||||||
'(package-selected-packages
|
'(package-selected-packages
|
||||||
(quote
|
(quote
|
||||||
(ample-zen-theme ample-theme magit irony-eldoc elpy irony helm-swoop helm)))
|
(zygospore yasnippet-snippets volatile-highlights use-package undo-tree sr-speedbar smartparens smart-mode-line-powerline-theme py-autopep8 multiple-cursors magit irony-eldoc iedit helm-swoop helm-gtags helm-company flycheck-irony expand-region elpy dashboard company-irony comment-dwim-2))))
|
||||||
'(vc-annotate-background "#3b3b3b")
|
|
||||||
'(vc-annotate-color-map
|
|
||||||
(quote
|
|
||||||
((20 . "#dd5542")
|
|
||||||
(40 . "#CC5542")
|
|
||||||
(60 . "#fb8512")
|
|
||||||
(80 . "#baba36")
|
|
||||||
(100 . "#bdbc61")
|
|
||||||
(120 . "#7d7c61")
|
|
||||||
(140 . "#6abd50")
|
|
||||||
(160 . "#6aaf50")
|
|
||||||
(180 . "#6aa350")
|
|
||||||
(200 . "#6a9550")
|
|
||||||
(220 . "#6a8550")
|
|
||||||
(240 . "#6a7550")
|
|
||||||
(260 . "#9b55c3")
|
|
||||||
(280 . "#6CA0A3")
|
|
||||||
(300 . "#528fd1")
|
|
||||||
(320 . "#5180b3")
|
|
||||||
(340 . "#6380b3")
|
|
||||||
(360 . "#DC8CC3"))))
|
|
||||||
'(vc-annotate-very-old-color "#DC8CC3"))
|
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
;; custom-set-faces was added by Custom.
|
;; custom-set-faces was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
)
|
)
|
||||||
|
|
||||||
(provide 'init)
|
|
||||||
;;; init.el ends here
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
# name: for with loop variable
|
# name: for with loop variable
|
||||||
# key: fori
|
# key: fori
|
||||||
# --
|
# --
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (${1:i = 0}; ${2:i < N}; ${3:++i}) {
|
for (${1:int i = 0}; ${2:i < N}; ${3:++i}) {
|
||||||
$0
|
$0
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue