Emacs config utilizing prelude as a base
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.

128 lines
4.6 KiB

  1. ;; Emacs users obviously have little need for Command and Option keys,
  2. ;; but they do need Meta and Super
  3. (when (string= system-type "darwin")
  4. (setq mac-command-modifier 'super)
  5. (setq mac-option-modifier 'meta))
  6. ;; Death to the tabs!
  7. (setq-default indent-tabs-mode nil)
  8. ;; delete the selection with a keypress
  9. (delete-selection-mode t)
  10. ;; highlight when searching and replacing
  11. (setq search-highlight t
  12. query-replace-highlight t)
  13. ;; store all backup and autosave files in the tmp dir
  14. (setq backup-directory-alist
  15. `((".*" . ,temporary-file-directory)))
  16. (setq auto-save-file-name-transforms
  17. `((".*" ,temporary-file-directory t)))
  18. ;; revert buffers automatically when underlying files are changed externally
  19. (global-auto-revert-mode t)
  20. ;; hippie expand is dabbrev expand on steroids
  21. (setq hippie-expand-try-functions-list '(try-expand-dabbrev
  22. try-expand-dabbrev-all-buffers
  23. try-expand-dabbrev-from-kill
  24. try-complete-file-name-partially
  25. try-complete-file-name
  26. try-expand-all-abbrevs
  27. try-expand-list
  28. try-expand-line
  29. try-complete-lisp-symbol-partially
  30. try-complete-lisp-symbol))
  31. ;; meaningful names for buffers with the same name
  32. (require 'uniquify)
  33. (setq uniquify-buffer-name-style 'forward)
  34. (setq uniquify-separator "/")
  35. (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
  36. (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
  37. ;; saveplace: save location in file when saving files
  38. (setq save-place-file "~/.emacs.d/saveplace")
  39. (setq-default save-place t) ;; activate it for all buffers
  40. (require 'saveplace) ;; get the package
  41. ;; savehist: save some history
  42. (setq savehist-additional-variables ;; also save...
  43. '(search ring regexp-search-ring) ;; ... my search entries
  44. savehist-autosave-interval 60 ;; save every minute (default: 5 min)
  45. savehist-file (concat "~/.emacs.d" "/savehist")) ;; keep my home clean
  46. (savehist-mode t) ;; do customization before activation
  47. ;; save recent files
  48. (setq recentf-save-file (concat prelude-dir "recentf") ;; keep ~/ clean
  49. recentf-max-saved-items 100 ;; max save 100
  50. recentf-max-menu-items 15) ;; max 15 in menu
  51. (recentf-mode t) ;; turn it on
  52. ;; time-stamps
  53. ;; when there's "Time-stamp: <>" in the first 10 lines of the file
  54. (setq
  55. time-stamp-active t ; do enable time-stamps
  56. time-stamp-line-limit 10 ; check first 10 buffer lines for Time-stamp: <>
  57. time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format
  58. (add-hook 'write-file-hooks 'time-stamp) ; update when saving
  59. ;; use shift + arrow keys to switch between visible buffers
  60. (require 'windmove)
  61. (windmove-default-keybindings 'super)
  62. ;; show-paren-mode: subtle highlighting of matching parens
  63. (show-paren-mode t)
  64. (setq show-paren-style 'parenthesis)
  65. ;; tramp, for sudo access
  66. (require 'tramp)
  67. ;; keep in mind known issues with zsh - see emacs wiki
  68. (setq tramp-default-method "ssh")
  69. ;; now we can use tramp to open files
  70. ;; requiring root access
  71. (defun find-alternative-file-with-sudo ()
  72. "Open current buffer as root!"
  73. (interactive)
  74. (when buffer-file-name
  75. (find-alternate-file
  76. sudo/su can be used as well, but they
  77. do not work for me
  78. (concat "/ssh:root@localhost:"
  79. buffer-file-name))))
  80. ;; ido-mode
  81. (ido-mode t)
  82. (setq ido-enable-prefix nil
  83. ido-enable-flex-matching t
  84. ido-create-new-buffer 'always
  85. ido-use-filename-at-point 'guess
  86. ido-max-prospects 10
  87. ido-default-file-method 'selected-window)
  88. ;; auto-completion in minibuffer
  89. (icomplete-mode +1)
  90. (set-default 'imenu-auto-rescan t)
  91. ;; flyspell-mode
  92. (setq ispell-program-name "aspell" ; use aspell instead of ispell
  93. ispell-extra-args '("--sug-mode=ultra"))
  94. (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
  95. (add-hook 'message-mode-hook 'turn-on-flyspell)
  96. (add-hook 'text-mode-hook 'turn-on-flyspell)
  97. (defun turn-on-flyspell ()
  98. "Force flyspell-mode on using a positive argument. For use in hooks."
  99. (interactive)
  100. (flyspell-mode 1))
  101. ;; enable narrow to region
  102. (put 'narrow-to-region 'disabled nil)
  103. ;; bookmarks
  104. (setq bookmark-default-file "~/.emacs.d/bookmarks"
  105. bookmark-save-flag 1)
  106. (provide 'editor-prelude)