Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 10.22 KB | None | 0 0
  1. ;; Action start
  2.  
  3. (setq tab-width 4)
  4.  
  5. ;; We start by doing some helm config
  6.  
  7. (require 'helm)
  8. (require 'helm-config)
  9. (require 'helm-command)
  10.  
  11. ;; Allow helm to fuzzy match
  12. (setq helm-M-x-fuzzy-match t)
  13. (setq helm-buffers-fuzzy-matching t
  14.       helm-recentf-fuzzy-match    t)
  15. (setq helm-semantic-fuzzy-match t
  16.       helm-imenu-fuzzy-match    t)
  17.  
  18. ;; When downloading files, allow helm to use google to suggest the file to download
  19. (when (executable-find "curl")
  20.   (setq helm-google-suggest-use-curl-p t))
  21.  
  22. ;; Let helm auto-resize
  23. (helm-autoresize-mode t)
  24.  
  25. (setq helm-split-window-in-side-p           t ; open helm buffer inside current window, not occupy whole other window
  26.       helm-move-to-line-cycle-in-source     t ; move to end or beginning of source when reaching top or bottom of source.
  27.       helm-ff-search-library-in-sexp        t ; search for library in `require' and `declare-function' sexp.
  28.       helm-scroll-amount                    8 ; scroll 8 lines other window using M-<next>/M-<prior>
  29.       helm-ff-file-name-history-use-recentf t)
  30.  
  31. (helm-mode t) ;; Turn on helm
  32.  
  33.  
  34. ;; Other things to set
  35.  
  36. (setq default-directory (concat (getenv "HOME") "/")) ;; This sets the default file loader to be at home (this is an issue when using windows)
  37. (custom-set-variables '(markdown-command "C:\\Users\\Tom Almeida\\AppData\\Local\\Pandoc\\pandoc.exe"))
  38.  
  39. ;; (sml/setup) ;; Allow Smart-mode-line to load
  40. (setq sml/theme 'powerline)
  41. (sml/setup)
  42.  
  43. ;; (set-frame-parameter nil 'fullscreen 'fullboth) ;; Turn on full-screen
  44.  
  45. ;; Org-mode settings
  46.  
  47. (setq org-log-done t) ;; Tell me when I complete things
  48. (setq org-agenda-files (list "~/Dropbox/Orgs/starter.org"
  49.                  "~/Dropbox/Orgs/work.org"
  50.                  "~/Dropbox/Orgs/uni.org")) ;; The list of files that agenda uses
  51.  
  52. ;; A couple of handy functions that save the state of the window config and reload them later
  53.  
  54. (defun quicksave()
  55.   (interactive)
  56.   (window-configuration-to-register ?m))
  57.  
  58. (defun quickload()
  59.   (interactive)
  60.   (jump-to-register ?m))
  61.  
  62. ;; Key setting time
  63.  
  64. (global-set-key (kbd "<f5>") 'quickload)
  65. (global-set-key (kbd "<f6>") 'quicksave)
  66.  
  67. (global-set-key (kbd "C-c h") 'helm-command-prefix)
  68. (global-unset-key (kbd "C-x c"))
  69. (global-set-key (kbd "M-x") 'helm-M-x)
  70. (global-set-key (kbd "C-x b") 'helm-mini)
  71. (global-set-key (kbd "C-x C-x") 'helm-mini)
  72. (global-set-key (kbd "C-x C-f") 'helm-find-files)
  73. (define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
  74. (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
  75. (define-key helm-map (kbd "C-z")  'helm-select-action) ; list actions using C-z
  76.  
  77.  
  78. (global-set-key (kbd "\C-cl") 'org-store-link)
  79. (global-set-key (kbd "\C-ca") 'org-agenda)
  80.  
  81. (require 'sr-speedbar)
  82. (global-set-key (kbd "C-t") 'sr-speedbar-toggle)
  83.  
  84.  
  85. ;; Eventually I want to make WARS (colemak wasd) my emacs movement keys.
  86. ;; Unfortunately, that will require a fair bit of redoing
  87.  
  88. ;; Not implimented:
  89. ;;     Clone-buffer
  90. ;;    
  91.  
  92. ;; Repeats:
  93. ;;
  94.  
  95. (defun warsKeys()
  96.   (interactive)
  97.  
  98.   ;; resetting the helm hotkeys
  99.  
  100.  
  101.   (define-key helm-map (kbd "C-u") 'helm-previous-line)
  102.   (define-key helm-map (kbd "C-e") 'helm-next-line)
  103.   (define-key helm-map (kbd "C-n") nil)
  104.   (define-key helm-map (kbd "C-p") nil)
  105.   (define-key helm-map (kbd "C-l") 'helm-yank-text-at-point)
  106.   (define-key helm-map (kbd "C-b") 'helm-recenter-top-bottom-other-window)
  107.  
  108.   ;; ensuring that universal-argument works correctly on C-p
  109.  
  110.   (define-key universal-argument-map (kbd "C-p") 'universal-argument-more)
  111.   (define-key universal-argument-map (kbd "C-u") 'nil)
  112.  
  113.   ;; ensuring that search is correctly done
  114.  
  115.   (define-key isearch-mode-map (kbd "C-s") nil)
  116.   (define-key isearch-mode-map (kbd "C-r") nil)
  117.   (define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
  118.   (define-key isearch-mode-map (kbd "M-f") 'isearch-repeat-backward)
  119.  
  120.   ;;  doing some org-mode resetting so that org-mode navigation works correctly
  121.   (add-hook 'org-mode-hook
  122.         '(lambda ()
  123.   (define-key org-mode-map (kbd "C-e") nil)
  124.   (define-key org-mode-map (kbd "C-a") nil)
  125.   (define-key org-mode-map (kbd "C-i") nil)
  126.   (define-key org-mode-map (kbd "M-i") 'org-end-of-line)
  127.   (define-key org-mode-map (kbd "M-n") 'org-beginning-of-line)))
  128.  
  129.   ;; resetting some things in markdown-mode so that navigation works correctly
  130.   (add-hook 'markdown-mode-hook
  131.         '(lambda()
  132.            (define-key markdown-mode-map (kbd "C-i") nil)
  133.            (define-key markdown-mode-map (kbd "TAB") nil)
  134.            (define-key markdown-mode-map (kbd "<tab>") 'markdown-cycle)
  135.                    (define-key markdown-mode-map (kbd "M-n") nil)))
  136.  
  137.   ;; ensuring that it works properly for emacs-lisp-mode
  138.   (add-hook 'emacs-lisp-mode
  139.         '(lambda()
  140.            (define-key emacs-lisp-mode-map (kbd "C-M-i") nil)))
  141.   (define-key emacs-lisp-mode-map (kbd "C-M-i") nil)
  142.  
  143.   ;; Making sure that tab still works on ERC
  144.   (add-hook 'erc-mode-hook
  145.         '(lambda ()
  146.            (define-key erc-mode-map (kbd "<tab>" ) 'erc-pcomplete)))
  147.  
  148.   ;; Making sure that C-i still works when editing C code
  149.   (add-hook 'c-mode-hook '(lambda () (define-key c-mode-map (kbd "C-i") nil)))
  150.   (add-hook 'c++-mode-hook '(lambda () (define-key c++-mode-map (kbd "C-i") nil)))
  151.  
  152.   (global-set-key (kbd "C-w") 'windmove-up) ;; removes kill-region
  153.   (global-set-key (kbd "C-r") 'windmove-down) ;; removes isearch-backward
  154.   (global-set-key (kbd "C-a") 'windmove-left) ;; removes move-beginning-of-line
  155.   (global-set-key (kbd "C-s") 'windmove-right) ;; removes isearch-forward
  156.  
  157.   (global-set-key (kbd "C-u") 'previous-line) ;; removes universal-argument
  158.   (global-set-key (kbd "C-e") 'next-line) ;; removes move-end-line
  159.   (global-set-key (kbd "C-n") 'backward-char) ;; removes next-line
  160.   (global-set-key (kbd "C-i") 'forward-char) ;;
  161.   (global-set-key (kbd "M-n") 'move-beginning-of-line) ;; removes clone-buffer
  162.   (global-set-key (kbd "M-i") 'move-end-of-line) ;; removes tab-to-tab-stop
  163.   (global-set-key (kbd "M-u") 'backward-word) ;; removes upcase-word
  164.   (global-set-key (kbd "M-e") 'forward-word) ;; removes forward-sentence
  165.   (global-set-key (kbd "C-M-e") 'scroll-up-command) ;; removes end-of-defun
  166.   (global-set-key (kbd "C-M-u") 'scroll-down-command) ;; removes backward-up-list
  167.   (global-set-key (kbd "C-M-n") 'beginning-of-buffer) ;; removes forward-list
  168.   (global-set-key (kbd "C-M-i") 'end-of-buffer) ;;
  169.  
  170.   (global-set-key (kbd "C-f") 'isearch-forward) ;; removes forward-char
  171.   (global-set-key (kbd "M-f") 'isearch-backward) ;; removes forward-word
  172.  
  173.   (global-set-key (kbd "C-l") 'kill-region) ;; removes recenter-top-bottom
  174.   (global-set-key (kbd "M-l") 'kill-ring-save) ;; removes downcase-word
  175.   (global-set-key [tab] 'tab-to-tab-stop) ;; removes tab binding to C-i
  176.   (global-set-key (kbd "C-b") 'recenter-top-bottom) ;; removes backward-char
  177.   (global-set-key (kbd "C-p") 'universal-argument) ;; removes previous-line
  178.  
  179.   (define-key helm-M-x-map (kbd "C-u") nil)
  180.   (define-key helm-M-x-map (kbd "C-p") 'helm-M-x-universal-argument)
  181. )
  182.  
  183. (defun defaultKeys()
  184.   (interactive)
  185.  
  186.   (global-set-key (kbd "C-u") 'universal-argument)
  187.   (global-set-key (kbd "C-M-e") 'end-of-defun)
  188.   (global-set-key (kbd "C-M-u") 'backward-up-list)
  189.   (global-set-key (kbd "C-M-n") 'forward-list)
  190.   (global-set-key (kbd "M-i") 'tab-to-tab-stop)
  191.   (global-set-key (kbd "M-e") 'forward-sentence)
  192.  
  193.   (define-key helm-map (kbd "C-n") 'helm-next-line)
  194.   (define-key helm-map (kbd "C-p") 'helm-previous-line)
  195.   (define-key helm-map (kbd "<right>") 'helm-next-source)
  196.   (define-key helm-map (kbd "<left>") 'helm-previous-source)
  197.   (define-key helm-map (kbd "<next>") 'helm-next-page)
  198.   (define-key helm-map (kbd "<prior>") 'helm-previous-page)
  199.    
  200.   (global-set-key (kbd "C-<right>") 'windmove-right)
  201.   (global-set-key (kbd "C-<left>") 'windmove-left)
  202.   (global-set-key (kbd "C-<up>") 'windmove-up)
  203.   (global-set-key (kbd "C-<down>") 'windmove-down)
  204.  
  205.   (global-set-key (kbd "<right>") 'forward-char)
  206.   (global-set-key (kbd "<left>") 'backward-char)
  207.   (global-set-key (kbd "<up>") 'previous-line)
  208.   (global-set-key (kbd "<down>") 'next-line)
  209.  
  210.   (global-set-key (kbd "C-p") 'previous-line)
  211.   (global-set-key (kbd "C-n") 'next-line)
  212.   (global-set-key (kbd "C-b") 'backward-char)
  213.   (global-set-key (kbd "C-f") 'forward-char)
  214.   (global-set-key (kbd "C-a") 'move-beginning-of-line)
  215.   (global-set-key (kbd "C-e") 'move-end-of-line)
  216.   (global-set-key (kbd "M-b") 'backward-word)
  217.   (global-set-key (kbd "M-f") 'forward-word)
  218.   (global-set-key (kbd "C-v") 'scroll-up-command)
  219.   (global-set-key (kbd "M-v") 'scroll-down-command)
  220.   (global-set-key (kbd "M-<") 'beginning-of-buffer)
  221.   (global-set-key (kbd "M->") 'end-of-buffer)
  222.  
  223.   (global-set-key (kbd "C-s") 'isearch-forward)
  224.   (global-set-key (kbd "C-r") 'isearch-backward)
  225.   (global-set-key (kbd "C-M-s") 'isearch-forward-regexp)
  226.   (global-set-key (kbd "C-M-r") 'isearch-backward-regexp)
  227.  
  228.   (global-set-key (kbd "C-w") 'kill-region)
  229.   (global-set-key (kbd "M-w") 'kill-ring-save)
  230.  
  231.   (global-set-key (kbd "M-n") 'clone-buffer)
  232.  
  233.   (global-set-key (kbd "C-q") 'quoted-insert)
  234.  
  235.   (global-set-key (kbd "C-M-a") 'beginning-of-defun)
  236.   )
  237.  
  238.  
  239. (global-set-key (kbd "<f8>") 'defaultKeys)
  240. (global-set-key (kbd "<f7>") 'warsKeys)
  241. (warsKeys)
  242.  
  243. ;; Make it so that the major mode defines the title
  244. (setq frame-title-format "(%m) %b")
  245.  
  246. ;; Start the server
  247. (load "server")
  248. (unless (server-running-p) (server-start))
  249.  
  250. ;; Tab width things
  251. (setq-default indent-tabs-mode nil)
  252. (setq tab-width 4)
  253.  
  254. ;; Dev env things
  255. (c-add-style "my-style"
  256.          '("stroustrup"
  257.            (indent-tabs-mode . nil)        ; use spaces rather than tabs
  258.            (c-basic-offset . 4)            ; indent by four spaces
  259.            (c-offsets-alist . ((inline-open . 0)  ; custom indentation rules
  260.                    (brace-list-open . 0)
  261.                    (statement-case-open . +)))))
  262.  
  263. (defun c-hook ()
  264.     (c-set-style "my-style")
  265.     (define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
  266.     ('electric-pair-mode))
  267. (add-hook 'c++-mode-hook 'c-hook)
  268. (add-hook 'c-mode-hook 'c-hook)
  269.  
  270. ;; Flycheck things
  271. (add-hook 'c++-mode-hook (lambda () (setq flycheck-gcc-language-standard "c++11")))
  272. (add-hook 'c-mode-hook (lambda () (flycheck-mode)))
  273. (add-hook 'c++-mode-hook (lambda () (flycheck-mode)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement