Last active
June 16, 2017 17:16
-
-
Save perheld/072a790596027952d0cdf418ccc7c891 to your computer and use it in GitHub Desktop.
my emacs config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; .emacs --- perkas emacs settings | |
;;; Commentary: | |
;; Fancy up things | |
;; Added by Package.el. This must come before configurations of | |
;; installed packages. Don't delete this line. If you don't want it, | |
;; just comment it out by adding a semicolon to the start of the line. | |
;; You may delete these explanatory comments. | |
(package-initialize) | |
(menu-bar-mode 0) | |
(tool-bar-mode 0) | |
(scroll-bar-mode 0) | |
(show-paren-mode t) | |
;;(set-face-background 'show-paren-mismatch-face "red") | |
;;(set-face-background 'show-paren-match-face "#d8d8d8") | |
(setq show-paren-style 'expression) | |
;; Hilight trailing whitespace | |
;; like this --> | |
;; | |
(setq-default show-trailing-whitespace t) | |
(set-face-background 'trailing-whitespace "orange1") | |
;; Goto line on Meta-g | |
(global-set-key "\M-g" 'goto-line) | |
;; Visit tag on ctrl + . | |
(global-set-key (kbd "C-.") 'find-tag) | |
;; Change window on nice keys | |
;;(global-set-key [\M-tab] 'next-multiframe-window) | |
(global-set-key [\M-s-up] 'windmove-up) | |
(global-set-key [\M-s-down] 'windmove-down) | |
(global-set-key [\M-s-right] 'windmove-right) | |
(global-set-key [\M-s-left] 'windmove-left) | |
;; More packages | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
;; I dont want the welcome screen. give me a empty scratch buffer | |
(setq inhibit-startup-message t) | |
(setq initial-scratch-message "") | |
;; uniquify buffer names | |
(require 'uniquify) ; bundled with GNU emacs 23.2.1 or before. On in 24.4 | |
(setq uniquify-buffer-name-style 'post-forward-angle-brackets) ; emacs 24.4 style ⁖ cat.png<dirName> | |
;; Treat 'y' or <CR> as yes, 'n' as no. | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(define-key query-replace-map [return] 'act) | |
(define-key query-replace-map [?\C-m] 'act) | |
;; ack stuff from andre | |
(defvar ack-default-dir "") | |
(defvar ack-command "/usr/bin/ack") | |
(defvar ack-history nil) | |
(defun ab/ack-run (what where) | |
(interactive (list (read-string "What: " (thing-at-point 'symbol)) | |
(read-directory-name "Where: " ack-default-dir))) | |
(setq ack-default-dir where) | |
(let ((compilation-ask-about-save nil) | |
(default-directory where)) | |
(cl-flet ((compilation-buffer-name (&rest args) "*ack*")) | |
(compilation-start | |
(concat ack-command " -i --smart-case --noheading --nocolor --type-add python=.pyx,pxi,pxd --type-set drdl=.drdl --type-set semla=.semla " (shell-quote-argument what) " " where "/"))) | |
)) | |
(global-set-key (kbd "\C-a") 'ab/ack-run) | |
(global-set-key "\C-n" 'next-error) | |
(global-set-key "\C-p" 'previous-error) | |
;; Google from inside emacs | |
(defun perka-googletext () | |
"Googles a query or region if any." | |
(interactive) | |
(browse-url | |
(concat | |
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=" | |
(if mark-active | |
(buffer-substring (region-beginning) (region-end)) | |
(read-string "Google: "))))) | |
(global-set-key (kbd "s-g") 'perka-googletext) | |
;; ido! | |
(setq ido-everywhere t) | |
(ido-mode t) | |
(setq ido-file-extensions-order '(".pyx" ".y" ".l" t)) | |
(setq ido-enable-flex-matching t) | |
;; Display ido results vertically, rather than horizontally | |
(setq ido-decorations (quote ("\n-> " "" "\n " "\n ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]"))) | |
;; hilight current line | |
(global-hl-line-mode 1) | |
(set-face-background 'hl-line "#330") | |
;; Force gdb-mi to not dedicate any windows | |
(defadvice gdb-display-buffer (after undedicate-gdb-display-buffer) | |
(set-window-dedicated-p ad-return-value nil)) | |
(ad-activate 'gdb-display-buffer) | |
(defadvice gdb-set-window-buffer (after undedicate-gdb-set-window-buffer (name &optional ignore-dedi window)) | |
(set-window-dedicated-p window nil)) | |
(ad-activate 'gdb-set-window-buffer) | |
;; ask before quiting emacs. why would you want to leave?! | |
(add-hook 'kill-emacs-query-functions | |
(lambda () (y-or-n-p "Do you really want to exit Emacs? ")) | |
'append) | |
;; Set longitude and latitude for M-x sunrise-sunset | |
(setq calendar-latitude 55.589838 calendar-longitude 13.005037) | |
;; knowing the time is nice | |
(setq display-time-day-and-date t | |
display-time-24hr-format t) | |
(display-time) | |
;;(add-hook 'after-init-hook #'global-flycheck-mode) | |
(global-set-key (kbd "\C-q") 'quick-calc) | |
;; magit! | |
(setq magit-process-popup-time 0) | |
(global-set-key "\C-cm" 'magit-status) | |
(global-set-key "\C-cl" 'magit-log-head) | |
;; lots of stuff from wanders here for C code | |
(defun aw-str-isprefixp (str prefix) | |
"" | |
(let ((plen (length prefix))) | |
(and (>= (length str) plen) | |
(string-equal prefix (substring str 0 plen))))) | |
(defun aw-as-autostyles () | |
"" | |
(let (res) | |
(dolist (stylename (mapcar 'car c-style-alist) res) | |
(if (aw-str-isprefixp stylename "auto-") | |
(setq res (cons (substring stylename 5) res)))))) | |
(defun aw-list-str-match (lst x) | |
"Return first matching entry in list of patterns" | |
(if lst | |
(if (string-match (car lst) x) | |
(car lst) | |
(aw-list-str-match (cdr lst) x)))) | |
(defun aw-as-find-match (matches p) | |
"" | |
(if p | |
(or | |
(aw-list-str-match matches (car p)) | |
(aw-as-find-match matches (cdr p))))) | |
(defun aw-as-hook () | |
"" | |
(when (buffer-file-name) | |
(message (format "Looking for style for %s" (buffer-file-name))) | |
(let ((x (aw-as-find-match (aw-as-autostyles) (split-string (buffer-file-name))))) | |
(when x | |
(message "Using C style %s" x) | |
(c-set-style (concat "auto-" x)))))) | |
;;; Hide ifdef mode | |
(defun aw-c-setup-hideifdef () | |
(setq hide-ifdef-shadow t) | |
(setq hide-ifdef-initially t) | |
(hide-ifdef-mode 1)) | |
(add-hook 'c-mode-hook 'aw-c-setup-hideifdef) | |
;; scroll margin is nice | |
(setq scroll-margin 3) | |
; This is based on the trick described here: http://www.emacswiki.org/emacs/SmartTabs | |
; but instead of macros-generating-advices it uses the indent-line-function variable | |
(defun aw-c-smarttab-indent-line-function () | |
(cond | |
(indent-tabs-mode | |
(let ((c-basic-offset fill-column) | |
(tab-width fill-column)) | |
(c-indent-line))) | |
(t (c-indent-line)))) | |
; | |
(c-add-style "aw-base" | |
'("linux" | |
(tab-width . 4) | |
(c-basic-offset . 4) | |
(c-offsets-alist . ((case-label . +))) | |
(indent-line-function . aw-c-smarttab-indent-line-function) | |
)) | |
;; | |
(c-add-style "auto-packetlogic2*" | |
'("aw-base")) | |
(c-add-style "auto-kernel*" | |
'("linux")) | |
(c-add-style "auto-/*" | |
'("aw-base")) | |
(add-hook 'c-mode-hook 'aw-as-hook) | |
(load-file "~/.emacs.d/git-find-file.el") | |
(require 'git-find-file) | |
(global-set-key (kbd "C-x f") 'git-find-file) | |
;; drag stuff is nice | |
;;(drag-stuff-globa;;l-mode t) | |
;;(global-set-key (kbd "M-p") 'drag-stuff-up) | |
;;(global-set-key (kbd "M-n") 'drag-stuff-down) | |
;;; .emacs ends here | |
(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. | |
'(c-default-style | |
(quote | |
((c-mode . "aw-base") | |
(java-mode . "java") | |
(awk-mode . "awk") | |
(other . "gnu")))) | |
'(custom-enabled-themes (quote (tsdh-dark))) | |
'(go-command "/home/perka/go/bin/go") | |
'(gofmt-command "/home/perka/go/bin/gofmt") | |
'(package-selected-packages | |
(quote | |
(git-gutter flycheck-pyflakes req-package magit go-mode drag-stuff auto-complete)))) | |
(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. | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment