Advertisement
danielhilst

.emacs

Jan 13th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 5.47 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 (:background "blue")))))
  56.  
  57. ;; show parenthesis and put a space between
  58. ;; first char in a line and line numbers
  59. (show-paren-mode t)
  60. (setq linum-format "%d ")
  61.  
  62. ;; Colors
  63. (global-font-lock-mode t)
  64.  
  65. ;; Colors
  66. (if (display-graphic-p)
  67.     (progn
  68.       (set-background-color "black")
  69.       (set-foreground-color "white")
  70.       (set-cursor-color "green"))
  71.   (set-face-foreground 'minibuffer-prompt "white"))
  72.  
  73. ;; EShell
  74. (add-hook 'eshell-mode-hook (lambda ()
  75.                               (define-key eshell-mode-map "\C-a" 'eshell-bol)))
  76.  
  77. (defun require-or-get-and-require (feature url full-filename)
  78.   "Download feature from url is not already there, then require feature
  79. The full-filename must be on path"
  80.   (unless (require feature nil t)
  81.     (condition-case err
  82.         (with-current-buffer (url-retrieve-synchronously url)
  83.           (goto-char (point-min))
  84.           (write-region (1+ (re-search-forward "^$")) ;; Skip HTTP header
  85.                         (point-max)
  86.                         full-filename)
  87.           (require feature))
  88.       (error
  89.        (message (format "Error: %s while downloading file %s" (nth 1 err) full-filename))))))
  90. (byte-compile 'require-or-get-and-require)
  91.  
  92. (require-or-get-and-require
  93.  'xcscope
  94.  "http://inst.eecs.berkeley.edu/~cs186/fa05/debugging/xcscope.el"
  95.  "~/.emacs.d/lisp/xcscope.el")
  96. (setq cscope-use-face nil)
  97.  
  98. ;; Neopastebin
  99. (add-to-list 'load-path "~/programming/emacs-pastebin/")
  100. (require 'neopastebin)
  101. (pastebin-create-login :dev-key "86d04e1d25921b3373b20793d5ce064f"
  102.                        :username "danielhilst")
  103.  
  104. (defun jffs2size (size)
  105.   "Calculate de size of a jffs2 filesystem, given its real size in bytes"
  106.   (interactive "nSize: ")
  107.   (let* ((lexical-binding t)
  108.         (pg-size 2048)
  109.         (size (format "%X" (+ size (- pg-size (% size pg-size))))))
  110.     (kill-new size)
  111.     (message (format "Size send to clipboard, %s" size))))
  112.  
  113.  
  114. (require-or-get-and-require
  115.  'bb-mode
  116.  "https://raw.githubusercontent.com/mferland/bb-mode/master/bb-mode.el"
  117.  "~/.emacs.d/lisp/bb-mode.el")
  118. (setq auto-mode-alist (cons '("\\.bb$" . bb-mode) auto-mode-alist))
  119. (setq auto-mode-alist (cons '("\\.inc$" . bb-mode) auto-mode-alist))
  120. (setq auto-mode-alist (cons '("\\.bbappend$" . bb-mode) auto-mode-alist))
  121. (setq auto-mode-alist (cons '("\\.bbclass$" . bb-mode) auto-mode-alist))
  122. (setq auto-mode-alist (cons '("\\.conf$" . bb-mode) auto-mode-alist))
  123.  
  124. (defun bytes-in-region ()
  125.   "Count bytes in region"
  126.   (interactive)
  127.   (message (format "%d bytes" (- (region-end) (region-beginning)))))
  128.  
  129. (custom-set-variables
  130.  ;; custom-set-variables was added by Custom.
  131.  ;; If you edit it by hand, you could mess it up, so be careful.
  132.  ;; Your init file should contain only one such instance.
  133.  ;; If there is more than one, they won't work right.
  134.  '(pastebin-default-paste-list-limit 200))
  135. (custom-set-faces
  136.  ;; custom-set-faces was added by Custom.
  137.  ;; If you edit it by hand, you could mess it up, so be careful.
  138.  ;; Your init file should contain only one such instance.
  139.  ;; If there is more than one, they won't work right.
  140.  )
  141.  
  142. ;; Wrinting latex
  143. (defun pdf-update ()
  144.   "Recreates the PDF file from a .tex buffer"
  145.   (interactive)
  146.   (call-process "pdflatex" nil "*pdflatex*" nil (buffer-file-name)))
  147. (add-hook 'latex-mode-hook (lambda ()
  148.                              (add-hook 'after-save-hook 'pdf-update)))
  149.  
  150.  
  151. ;; MELPA
  152. (require 'package) ;; You might already have this line
  153. (add-to-list 'package-archives
  154.                           '("melpa" . "https://melpa.org/packages/"))
  155.  
  156.  
  157. ;; keep session
  158. (desktop-save-mode t)
  159.  
  160. ;; Better window moving binds
  161. (global-set-key (kbd "C-<up>") 'windmove-up)
  162. (global-set-key (kbd "C-<down>") 'windmove-down)
  163. (global-set-key (kbd "C-<right>") 'windmove-right)
  164. (global-set-key (kbd "C-<left>") 'windmove-left)
  165. (global-set-key (kbd "<up>") 'enlarge-window)
  166. (global-set-key (kbd "<down>") 'shrink-window)
  167. (global-set-key (kbd "<right>") 'enlarge-window-horizontally)
  168. (global-set-key (kbd "<left>") 'shrink-window-horizontally)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement