Advertisement
danielhilst

.emacs

Jan 14th, 2016
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 6.64 KB | None | 0 0
  1. ;; Load path
  2. (add-to-list 'load-path "~/.emacs.d/lisp")
  3.  
  4. ;; Scroll one line
  5. (setq scroll-step 1)
  6.  
  7. ;; Show parents
  8. (show-paren-mode t)
  9.  
  10. ;; C (from kernel.org coding style)
  11. (setq c-default-style "linux")
  12. (defun c-lineup-arglist-tabs-only (ignored)
  13.   "Line up argument lists by tabs, not spaces"
  14.   (let* ((anchor (c-langelem-pos c-syntactic-element))
  15.          (column (c-langelem-2nd-pos c-syntactic-element))
  16.          (offset (- (1+ column) anchor))
  17.          (steps (floor offset c-basic-offset)))
  18.     (* (max steps 1)
  19.        c-basic-offset)))
  20. (add-hook 'c-mode-common-hook
  21.           (lambda ()
  22.             ;; Add kernel style
  23.             (c-add-style
  24.              "linux-tabs-only"
  25.              '("linux" (c-offsets-alist
  26.                         (arglist-cont-nonempty
  27.                          c-lineup-gcc-asm-reg
  28.                          c-lineup-arglist-tabs-only))))))
  29.  
  30. (add-hook 'c-mode-hook
  31.           (lambda ()
  32.             (setq indent-tabs-mode t)
  33.             (setq show-trailing-whitespace t)
  34.             (c-set-style "linux-tabs-only")))
  35.  
  36.  
  37. ;; auto complete c code
  38. (add-hook 'c-mode-hook
  39.       (lambda ()
  40.         ;;;; Company mode
  41.         (company-mode t)
  42.         (irony-mode t)
  43.         (setq-local company-idle-delay nil)
  44.         (define-key company-mode-map (kbd "C-x C-o") 'company-irony)
  45.         ;; (define-key company-mode-map (kbd "C-x C-o") 'company-complete)
  46.         (define-key company-active-map (kbd "C-p") 'company-select-previous)
  47.         (define-key company-active-map (kbd "C-n") 'company-select-next)
  48.         ))
  49.  
  50. (deftheme jellybeans
  51.   "Created 2013-11-05.")
  52. (custom-theme-set-faces
  53.  'jellybeans
  54.  ;; company
  55.   '(company-tooltip ((t (:foreground "white"))))
  56.   '(company-tooltip ((t (:background "blue")))))
  57.  
  58. ;; gdb customization
  59. (defvar gud-gdb-command-name "gdb -i=mi " "gdb command line")
  60. (when (getenv "GDB")
  61.   (setq gud-gdb-command-name (concat (getenv "GDB") " -i=mi ")))
  62. (add-hook 'gud-mode-hook
  63.       (lambda ()
  64.         (let ((sdk-target-sysroot (getenv "SDKTARGETSYSROOT"))
  65.           (gdb-solib-search-path (getenv "GDB_SOLIBSEARCHPATH"))
  66.           (gdb-target (getenv "GDB_TARGET")))
  67.           (when sdk-target-sysroot
  68.         (gud-call (concat "set sysroot " sdk-target-sysroot)))
  69.           (when gdb-solib-search-path
  70.         (gud-call (concat "set solib-search-path " gdb-solib-search-path)))
  71.           (when gdb-target
  72.         (gud-call (concat "target " gdb-target))))))
  73.        
  74. ;; gdb highlight line
  75. ;; (defvar gud-overlay
  76. ;;   (let* ((ov (make-overlay (point-min) (point-min))))
  77. ;;     (overlay-put ov 'face 'secondary-selection)
  78. ;;     ov)
  79. ;;   "Overlay variable for GUD highlighting.")
  80.  
  81. ;; (defadvice gud-display-line (after my-gud-highlight act)
  82. ;;   "Highlight current line."
  83. ;;   (let* ((ov gud-overlay)
  84. ;;   (bf (gud-find-file true-file)))
  85. ;;     (with-current-buffer bf
  86. ;;       (move-overlay ov (line-beginning-position) (line-beginning-position 2)
  87. ;;          ;;(move-overlay ov (line-beginning-position) (line-end-position)
  88. ;;          (current-buffer)))))
  89.  
  90. ;; (defun gud-kill-buffer ()
  91. ;;   (if (derived-mode-p 'gud-mode)
  92. ;;       (delete-overlay gud-overlay)))
  93.  
  94. ;;   (add-hook 'kill-buffer-hook 'gud-kill-buffer)
  95.  
  96. ;; show parenthesis and put a space between
  97. ;; first char in a line and line numbers
  98. (show-paren-mode t)
  99. (setq linum-format "%d ")
  100.  
  101. ;; Colors
  102. (global-font-lock-mode t)
  103.  
  104. ;; Colors
  105. (if (display-graphic-p)
  106.     (progn
  107.       (set-background-color "black")
  108.       (set-foreground-color "white")
  109.       (set-cursor-color "green"))
  110.   (set-face-foreground 'minibuffer-prompt "white"))
  111.  
  112. ;; EShell
  113. (add-hook 'eshell-mode-hook (lambda ()
  114.                               (define-key eshell-mode-map "\C-a" 'eshell-bol)))
  115.  
  116. (defun require-or-get-and-require (feature url full-filename)
  117.   "Download feature from url is not already there, then require feature
  118. The full-filename must be on path"
  119.   (unless (require feature nil t)
  120.     (condition-case err
  121.         (with-current-buffer (url-retrieve-synchronously url)
  122.           (goto-char (point-min))
  123.           (write-region (1+ (re-search-forward "^$")) ;; Skip HTTP header
  124.                         (point-max)
  125.                         full-filename)
  126.           (require feature))
  127.       (error
  128.        (message (format "Error: %s while downloading file %s" (nth 1 err) full-filename))))))
  129. (byte-compile 'require-or-get-and-require)
  130.  
  131. (require-or-get-and-require
  132.  'xcscope
  133.  "http://inst.eecs.berkeley.edu/~cs186/fa05/debugging/xcscope.el"
  134.  "~/.emacs.d/lisp/xcscope.el")
  135. (setq cscope-use-face nil)
  136.  
  137. ;; Neopastebin
  138. (add-to-list 'load-path "~/programming/emacs-pastebin/")
  139. (require 'neopastebin)
  140. (pastebin-create-login :dev-key "86d04e1d25921b3373b20793d5ce064f"
  141.                        :username "danielhilst")
  142.  
  143. (defun jffs2size (size)
  144.   "Calculate de size of a jffs2 filesystem, given its real size in bytes"
  145.   (interactive "nSize: ")
  146.   (let* ((lexical-binding t)
  147.         (pg-size 2048)
  148.         (size (format "%X" (+ size (- pg-size (% size pg-size))))))
  149.     (kill-new size)
  150.     (message (format "Size send to clipboard, %s" size))))
  151.  
  152.  
  153. (require-or-get-and-require
  154.  'bb-mode
  155.  "https://raw.githubusercontent.com/mferland/bb-mode/master/bb-mode.el"
  156.  "~/.emacs.d/lisp/bb-mode.el")
  157. (setq auto-mode-alist (cons '("\\.bb$" . bb-mode) auto-mode-alist))
  158. (setq auto-mode-alist (cons '("\\.inc$" . bb-mode) auto-mode-alist))
  159. (setq auto-mode-alist (cons '("\\.bbappend$" . bb-mode) auto-mode-alist))
  160. (setq auto-mode-alist (cons '("\\.bbclass$" . bb-mode) auto-mode-alist))
  161. (setq auto-mode-alist (cons '("\\.conf$" . bb-mode) auto-mode-alist))
  162.  
  163. (defun bytes-in-region ()
  164.   "Count bytes in region"
  165.   (interactive)
  166.   (message (format "%d bytes" (- (region-end) (region-beginning)))))
  167.  
  168. (custom-set-variables
  169.  ;; custom-set-variables was added by Custom.
  170.  ;; If you edit it by hand, you could mess it up, so be careful.
  171.  ;; Your init file should contain only one such instance.
  172.  ;; If there is more than one, they won't work right.
  173.  '(pastebin-default-paste-list-limit 200))
  174. (custom-set-faces
  175.  ;; custom-set-faces was added by Custom.
  176.  ;; If you edit it by hand, you could mess it up, so be careful.
  177.  ;; Your init file should contain only one such instance.
  178.  ;; If there is more than one, they won't work right.
  179.  )
  180.  
  181. ;; Wrinting latex
  182. (defun pdf-update ()
  183.   "Recreates the PDF file from a .tex buffer"
  184.   (interactive)
  185.   (call-process "pdflatex" nil "*pdflatex*" nil (buffer-file-name)))
  186. (add-hook 'latex-mode-hook (lambda ()
  187.                              (add-hook 'after-save-hook 'pdf-update)))
  188.  
  189.  
  190. ;; MELPA
  191. (require 'package) ;; You might already have this line
  192. (add-to-list 'package-archives
  193.          '("melpa" . "https://melpa.org/packages/"))
  194.  
  195.  
  196. ;; keep session
  197. (desktop-save-mode t)
  198.  
  199. ;; Better window moving binds
  200. ;; (global-set-key (kbd "C-c C-p") 'windmove-up)
  201. ;; (global-set-key (kbd "C-c C-n") 'windmove-down)
  202. ;; (global-set-key (kbd "C-c C-f") 'windmove-left)
  203. ;; (global-set-key (kbd "C-c C-b") 'windmove-rigth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement