;; Load path (add-to-list 'load-path "~/.emacs.d/lisp") ;; Scroll one line (setq scroll-step 1) ;; Show parents (show-paren-mode t) ;; C (from kernel.org coding style) (setq c-default-style "linux") (defun c-lineup-arglist-tabs-only (ignored) "Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element)) (column (c-langelem-2nd-pos c-syntactic-element)) (offset (- (1+ column) anchor)) (steps (floor offset c-basic-offset))) (* (max steps 1) c-basic-offset))) (add-hook 'c-mode-common-hook (lambda () ;; Add kernel style (c-add-style "linux-tabs-only" '("linux" (c-offsets-alist (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist-tabs-only)))))) (add-hook 'c-mode-hook (lambda () (setq indent-tabs-mode t) (setq show-trailing-whitespace t) (c-set-style "linux-tabs-only"))) ;; auto complete c code (add-hook 'c-mode-hook (lambda () ;;;; Company mode (company-mode t) (irony-mode t) (setq-local company-idle-delay nil) (define-key company-mode-map (kbd "C-x C-o") 'company-irony) ;; (define-key company-mode-map (kbd "C-x C-o") 'company-complete) (define-key company-active-map (kbd "C-p") 'company-select-previous) (define-key company-active-map (kbd "C-n") 'company-select-next) )) (deftheme jellybeans "Created 2013-11-05.") (custom-theme-set-faces 'jellybeans ;; company '(company-tooltip ((t (:foreground "white")))) '(company-tooltip ((t (:background "blue"))))) ;; gdb customization (defvar gud-gdb-command-name "gdb -i=mi " "gdb command line") (when (getenv "GDB") (setq gud-gdb-command-name (concat (getenv "GDB") " -i=mi "))) (add-hook 'gud-mode-hook (lambda () (let ((sdk-target-sysroot (getenv "SDKTARGETSYSROOT")) (gdb-solib-search-path (getenv "GDB_SOLIBSEARCHPATH")) (gdb-target (getenv "GDB_TARGET"))) (when sdk-target-sysroot (gud-call (concat "set sysroot " sdk-target-sysroot))) (when gdb-solib-search-path (gud-call (concat "set solib-search-path " gdb-solib-search-path))) (when gdb-target (gud-call (concat "target " gdb-target)))))) ;; gdb highlight line ;; (defvar gud-overlay ;; (let* ((ov (make-overlay (point-min) (point-min)))) ;; (overlay-put ov 'face 'secondary-selection) ;; ov) ;; "Overlay variable for GUD highlighting.") ;; (defadvice gud-display-line (after my-gud-highlight act) ;; "Highlight current line." ;; (let* ((ov gud-overlay) ;; (bf (gud-find-file true-file))) ;; (with-current-buffer bf ;; (move-overlay ov (line-beginning-position) (line-beginning-position 2) ;; ;;(move-overlay ov (line-beginning-position) (line-end-position) ;; (current-buffer))))) ;; (defun gud-kill-buffer () ;; (if (derived-mode-p 'gud-mode) ;; (delete-overlay gud-overlay))) ;; (add-hook 'kill-buffer-hook 'gud-kill-buffer) ;; show parenthesis and put a space between ;; first char in a line and line numbers (show-paren-mode t) (setq linum-format "%d ") ;; Colors (global-font-lock-mode t) ;; Colors (if (display-graphic-p) (progn (set-background-color "black") (set-foreground-color "white") (set-cursor-color "green")) (set-face-foreground 'minibuffer-prompt "white")) ;; EShell (add-hook 'eshell-mode-hook (lambda () (define-key eshell-mode-map "\C-a" 'eshell-bol))) (defun require-or-get-and-require (feature url full-filename) "Download feature from url is not already there, then require feature The full-filename must be on path" (unless (require feature nil t) (condition-case err (with-current-buffer (url-retrieve-synchronously url) (goto-char (point-min)) (write-region (1+ (re-search-forward "^$")) ;; Skip HTTP header (point-max) full-filename) (require feature)) (error (message (format "Error: %s while downloading file %s" (nth 1 err) full-filename)))))) (byte-compile 'require-or-get-and-require) (require-or-get-and-require 'xcscope "http://inst.eecs.berkeley.edu/~cs186/fa05/debugging/xcscope.el" "~/.emacs.d/lisp/xcscope.el") (setq cscope-use-face nil) ;; Neopastebin (add-to-list 'load-path "~/programming/emacs-pastebin/") (require 'neopastebin) (pastebin-create-login :dev-key "86d04e1d25921b3373b20793d5ce064f" :username "danielhilst") (defun jffs2size (size) "Calculate de size of a jffs2 filesystem, given its real size in bytes" (interactive "nSize: ") (let* ((lexical-binding t) (pg-size 2048) (size (format "%X" (+ size (- pg-size (% size pg-size)))))) (kill-new size) (message (format "Size send to clipboard, %s" size)))) (require-or-get-and-require 'bb-mode "https://raw.githubusercontent.com/mferland/bb-mode/master/bb-mode.el" "~/.emacs.d/lisp/bb-mode.el") (setq auto-mode-alist (cons '("\\.bb$" . bb-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.inc$" . bb-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.bbappend$" . bb-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.bbclass$" . bb-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.conf$" . bb-mode) auto-mode-alist)) (defun bytes-in-region () "Count bytes in region" (interactive) (message (format "%d bytes" (- (region-end) (region-beginning))))) (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. '(pastebin-default-paste-list-limit 200)) (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. ) ;; Wrinting latex (defun pdf-update () "Recreates the PDF file from a .tex buffer" (interactive) (call-process "pdflatex" nil "*pdflatex*" nil (buffer-file-name))) (add-hook 'latex-mode-hook (lambda () (add-hook 'after-save-hook 'pdf-update))) ;; MELPA (require 'package) ;; You might already have this line (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) ;; keep session (desktop-save-mode t) ;; Better window moving binds ;; (global-set-key (kbd "C-c C-p") 'windmove-up) ;; (global-set-key (kbd "C-c C-n") 'windmove-down) ;; (global-set-key (kbd "C-c C-f") 'windmove-left) ;; (global-set-key (kbd "C-c C-b") 'windmove-rigth)