You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
6.5 KiB

  1. ;; Set enironment information
  2. (setq user-full-name "Drew Short")
  3. (setq user-email-address "warrick@sothr.com")
  4. ;; Set UTF-8 as the default encoding
  5. (prefer-coding-system 'utf-8)
  6. (setq coding-system-for-read 'utf-8)
  7. (setq coding-system-for-write 'utf-8)
  8. ;; Load common lisp
  9. (require 'cl)
  10. ;; Package management
  11. (load "package")
  12. (package-initialize)
  13. ;; Theme packages
  14. (defvar sothr/themes '(cyberpunk-theme) "Themes")
  15. ;; Tool packages
  16. (defvar sothr/tools '(auto-complete
  17. better-defaults
  18. gist
  19. projectile
  20. magit
  21. neotree
  22. slime)
  23. "Tools")
  24. ;; Additional mode packages
  25. (defvar sothr/modes '(markdown-mode
  26. go-mode
  27. rust-mode
  28. yaml-mode)
  29. "Modes")
  30. ;; Org mode specific packages
  31. (defvar sothr/org '(org
  32. org-ac
  33. org-autolist
  34. org-bullets
  35. org-doing)
  36. "Org Mode Packages")
  37. ;; Combine the package lists
  38. (defvar sothr/packages (append sothr/themes sothr/tools sothr/modes sothr/org) "Default Packages")
  39. ;; Repositories
  40. (add-to-list 'package-archives
  41. '("melpa" . "http://melpa.milkbox.net/packages/") t)
  42. (setq package-archive-enable-alist '(("melpa" deft magit)))
  43. ;; Advice from the melpa site for a package dependency validation error in emacs 24
  44. ;;(defadvice package-compute-transaction
  45. ;; (before package-compute-transaction-reverse (package-list requirements) activate compile)
  46. ;; "reverse the requirements"
  47. ;; (setq requirements (reverse requirements))
  48. ;; (print requirements))
  49. ;; Make sure default packages are installed
  50. (defun sothr/packages-installed-p ()
  51. (loop for pkg in sothr/packages
  52. when (not (package-installed-p pkg)) do (return nil)
  53. finally (return t)))
  54. ;; This is the logic that runs the above function
  55. (unless (sothr/packages-installed-p)
  56. (message "%s" "Refreshing package database...")
  57. (package-refresh-contents)
  58. (dolist (pkg sothr/packages)
  59. (when (not (package-installed-p pkg))
  60. (package-install pkg))))
  61. ;; Disable emacs help screen
  62. (setq inhibit-splash-screen t)
  63. ;; Emable emacs copying from X11
  64. (setq x-select-enable-clipboard t)
  65. ;; Always follow symbolic links back to the source file in version control
  66. (setq x-select-enable-clipboard t)
  67. ;; Markdown Mode Configuration
  68. (autoload 'markdown-mode "markdown-mode"
  69. "Major mode for editing Markdown files" t)
  70. (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
  71. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  72. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  73. ;; Set the markdown processor to grip
  74. ;; pip3 install grip
  75. (setq markdown-command "grip --export -")
  76. ;; Set NeoTree to toggle with F8
  77. (global-set-key [f8] 'neotree-toggle)
  78. ;; Default configuration for auto-complete
  79. (ac-config-default)
  80. ;; Make all files show a line number
  81. (global-linum-mode)
  82. ;; Make sure that there is spacing in linum mode
  83. ;(setq linum-format "%4d \u2502 ") ;; Fancy line with vertical bar
  84. ;; Dynamic width for lines for convienient right justification
  85. (unless window-system
  86. (add-hook 'linum-before-numbering-hook
  87. (lambda ()
  88. (setq-local linum-format-fmt
  89. (let ((w (length (number-to-string
  90. (count-lines (point-min) (point-max))))))
  91. (concat "%" (number-to-string w) "d"))))))
  92. (defun linum-format-func (line)
  93. (concat
  94. (propertize (format linum-format-fmt line) 'face 'linum)
  95. (propertize " " 'face 'mode-line)))
  96. (unless window-system
  97. (setq linum-format 'linum-format-func))
  98. ;; Configure SLIME
  99. ;; Inferior Lisp interpreter is found at $CL_BIN
  100. (setq inferior-lisp-program (getenv "CL_BIN"))
  101. (setq slime-contribs '(slime-fancy))
  102. ;; A method create a lambda that switches between
  103. ;; themes with the press of a button
  104. ;; Emcas requires explicit closures otherwise they're
  105. ;; abandoned at runtime and cryptic errors occur
  106. (let ((next nil) (themes nil))
  107. (defun make-theme-switcher (theme_list)
  108. (setf themes theme_list)
  109. #'(lambda ()
  110. (setf next (pop themes))
  111. ;; Move the first entry in the list to the last
  112. (setf themes (append themes (list next)))
  113. ;; Load the theme that was next in the list
  114. (load-theme next t))))
  115. ;; create a function to loop over and apply themes
  116. (setf load-next-theme (make-theme-switcher '(cyberpunk adwaita)))
  117. ;; Load the first theme as the default theme
  118. (funcall load-next-theme)
  119. ;; Toggle theme switch with F3
  120. (global-set-key [f3] (lambda ()
  121. (interactive)
  122. (funcall load-next-theme)))
  123. ;; Set the autoencrypt feature of emacs for .gpg files
  124. (require `epa-file)
  125. (epa-file-enable)
  126. ;; Windows specific configuration
  127. ;; A Linux environment is assumed by default
  128. ;(defun windows-config ()
  129. ;; When running in Windows, we want to use an alternate shell so we
  130. ;; can be more unixy.
  131. ;(setq shell-file-name "c:/Tools/msys64/usr/bin/zsh")
  132. ;(setq explicit-shell-file-name shell-file-name)
  133. ;(setq explicit-zsh-args '("-i")) ; Make sure the shell is in the home
  134. ;(setenv "HOME" "c:/tools/msys64/home/neria")) ; Set the home environment correctly
  135. ;(setenv "PATH"
  136. ;(concat ".:/usr/local/bin:/msys64/bin:/bin:"
  137. ;(replace-regexp-in-string "/////" "\\\\ "
  138. ;(replace-regexp-in-string "\\\\" "/"
  139. ;(replace-regexp-in-string "\\([A-Za-z]\\):" "/\\1"
  140. ;(getenv "PATH")))))))
  141. ;; Windows specific configurations
  142. ;(cond
  143. ;((string-equal system-type "windows-nt") ; MS Windows System
  144. ;(windows-config)))
  145. ;; Advice for open files as root if we don't have enough permissions
  146. (defadvice ido-find-file (after find-file-sudo activate)
  147. "Find file as root if necessary."
  148. (unless (and buffer-file-name
  149. (file-writable-p buffer-file-name))
  150. (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
  151. (custom-set-variables
  152. ;; custom-set-variables was added by Custom.
  153. ;; If you edit it by hand, you could mess it up, so be careful.
  154. ;; Your init file should contain only one such instance.
  155. ;; If there is more than one, they won't work right.
  156. '(package-selected-packages
  157. (quote
  158. (org-doing org-bullets org-autolist org-ac better-defaults yaml-mode slime rust-mode projectile markdown-mode magit go-mode gist cyberpunk-theme auto-complete))))
  159. (custom-set-faces
  160. ;; custom-set-faces was added by Custom.
  161. ;; If you edit it by hand, you could mess it up, so be careful.
  162. ;; Your init file should contain only one such instance.
  163. ;; If there is more than one, they won't work right.
  164. )