.emacs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ;; System-type definition
  2. (defun system-is-linux()
  3. (string-equal system-type "gnu/linux"))
  4. (defun system-is-windows()
  5. (string-equal system-type "windows-nt"))
  6. (defun system-is-macos()
  7. (string-equal system-type "darwin"))
  8. ;; Start Emacs as a server
  9. (when (system-is-linux)
  10. (require 'server)
  11. (unless (server-running-p)
  12. (server-start))) ;; launch emacs as a server if OS - GNU/Linux
  13. ;; MS Windows path-variable
  14. (when (system-is-windows)
  15. (setq win-sbcl-exe "C:/sbcl/sbcl.exe")
  16. (setq win-init-path "C:/.emacs.d/lisp")
  17. (setq win-init-ct-path "C:/.emacs.d/plugins/color-theme")
  18. (setq win-init-ac-path "C:/.emacs.d/plugins/auto-complete")
  19. (setq win-init-slime-path "C:/slime")
  20. (setq win-init-ac-dict-path "C:/.emacs.d/plugins/auto-complete/dict"))
  21. ;; Unix path-variable
  22. (when (system-is-linux)
  23. (setq unix-sbcl-bin "/usr/bin/sbcl")
  24. (setq unix-init-path "~/.emacs.d/lisp")
  25. (setq unix-init-ct-path "~/.emacs.d/plugins/color-theme")
  26. (setq unix-init-ac-path "~/.emacs.d/plugins/auto-complete")
  27. (setq unix-init-slime-path "/usr/share/common-lisp/source/slime/")
  28. (setq unix-init-ac-dict-path "~/.emacs.d/plugins/auto-complete/dict"))
  29. ;; Dired
  30. (require 'dired)
  31. (setq dired-recursive-deletes 'top) ;; so we can delete non-empty directories
  32. ;; Imenu
  33. (require 'imenu)
  34. (setq imenu-auto-rescan t) ;; automatically update the list of functions in the buffer
  35. (setq imenu-use-popup-menu nil) ;; Imenu dialog only in the mini-buffer
  36. (global-set-key (kbd "<f6>") 'imenu) ;; press F6 to launch Imenu
  37. ;; Display the name of the current buffer in the title bar
  38. (setq frame-title-format "GNU Emacs: %b")
  39. ;; Load path for plugins
  40. (if (system-is-windows)
  41. (add-to-list 'load-path win-init-path)
  42. (add-to-list 'load-path unix-init-path))
  43. ;; Inhibit startup/splash screen
  44. (setq inhibit-splash-screen t)
  45. (setq ingibit-startup-message t) ;;startup screen can be open with C-h
  46. ;; Show-paren-mode settings
  47. (show-paren-mode t) ;; turn on text highlight within {},[],()
  48. (setq show-paren-style 'expression) ;; highlight text inside {}, [], ()
  49. ;; Electric-modes settings
  50. (electric-pair-mode 1) ;; automatically close brackets {},[],()
  51. (electric-indent-mode -1) ;; turn off auto indent with electric-indent-mod (default in Emacs-24.4)
  52. ;; Delete selection
  53. (delete-selection-mode t)
  54. ;; Disable GUI components
  55. (tooltip-mode -1)
  56. (menu-bar-mode -1) ;; turn off GUI menu bar
  57. (tool-bar-mode -1) ;; turn off toolbar
  58. (scroll-bar-mode -1) ;; turn off scrollbar
  59. (blink-cursor-mode -1) ;; turn off cursor blink
  60. (setq use-dialog-box nil) ;; all dialogs through mini-buffer
  61. (setq redisplay-dont-pause t) ;; better buffer display
  62. (setq ring-bell-function 'ignore) ;; turn off sound notification
  63. ;; Coding-system settings
  64. (set-language-environment 'UTF-8)
  65. (if (system-is-linux) ;; utf-8 for GNU/Linux and macOS, windows-1251 for MS Windows
  66. (progn
  67. (setq default-buffer-file-coding-system 'utf-8)
  68. (setq-default coding-system-for-read 'utf-8)
  69. (setq file-name-coding-system 'utf-8)
  70. (set-selection-coding-system 'utf-8)
  71. (set-keyboard-coding-system 'utf-8-unix)
  72. (set-terminal-coding-system 'utf-8)
  73. (prefer-coding-system 'utf-8))
  74. (progn
  75. (prefer-coding-system 'windows-1251)
  76. (set-terminal-coding-system 'windows-1251)
  77. (set-keyboard-coding-system 'windows-1251-unix)
  78. (set-selection-coding-system 'windows-1251)
  79. (setq file-name-coding-system 'windows-1251)
  80. (setq-default coding-system-for-read 'windows-1251)
  81. (setq default-buffer-file-coding-system 'windows-1251)))
  82. ;; Linum plugin
  83. (require 'linum) ;; call Linum
  84. (line-number-mode t) ;; show line number in mode-line
  85. (global-linum-mode t) ;; show line number in all buffers
  86. (column-number-mode t) ;; show column number in mode-line
  87. (setq linum-format " %d") ;; set up line numbering format
  88. ;; Fringe settings
  89. (fringe-mode '(8 . 0)) ;; fringe is only on the left side
  90. (setq-default indicate-empty-lines t) ;; empty lines are marked
  91. (setq-default indicate-buffer-boundaries 'left) ;; indication are shown on the left side
  92. ;; Display file size/time in mode-line
  93. (setq display-time-24hr-format t) ;; 24-hour time format in the mode-line
  94. (display-time-mode t) ;; show time in mode-line
  95. (size-indication-mode t) ;; file size in %
  96. ;; Line wrapping
  97. (setq word-wrap t) ;; word wrapping
  98. (global-visual-line-mode t)
  99. ;; Start window size
  100. (when (window-system)
  101. (set-frame-size (selected-frame) 100 50))
  102. ;; IDO plugin
  103. (require 'ido)
  104. (ido-mode t)
  105. (icomplete-mode t)
  106. (ido-everywhere t)
  107. (setq ido-vitrual-buffers t)
  108. (setq ido-enable-flex-matching t)
  109. ;; Buffer Selection and ibuffer settings
  110. (require 'bs)
  111. (require 'ibuffer)
  112. (defalias 'list-buffers 'ibuffer) ;; separate buffer list with C-x C-b
  113. (global-set-key (kbd "<f2>") 'bs-show) ;; start buffer selection by pressing F2
  114. ;; Syntax highlighting
  115. (require 'font-lock)
  116. (global-font-lock-mode t) ;; just in case... set on since Emacs-22
  117. (setq font-lock-maximum-decoration t)
  118. ;; Indent settings
  119. (setq-default indent-tabs-mode nil) ;; turn off indentation via tab
  120. (setq-default tab-width 2) ;; tab size
  121. (setq-default c-basic-offset 2)
  122. (setq-default standart-indent 2) ;; standard offset
  123. (setq-default lisp-body-indent 2) ;; offset in lisp
  124. (global-set-key (kbd "RET") 'newline-and-indent) ;; with enter, make new line and indent
  125. (setq lisp-indent-function 'common-lisp-indent-function)
  126. ;; Scrolling settings
  127. (setq scroll-step 1) ;; up-down scrolling speed is 1
  128. (setq scroll-margin 10) ;; set up scrolling margin
  129. (setq scroll-conservatively 10000)
  130. ;; Short messages
  131. (defalias 'yes-or-no-p 'y-or-n-p)
  132. ;; Clipboard settings
  133. (setq x-select-enable-clipboard t)
  134. ;; End of file newlines
  135. ;;(setq require-final-newline t) ;; add additional newline while saving file
  136. (setq next-line-add-newlines nil) ;; do not add new line with arrow keys
  137. ;; Highlight search resaults
  138. (setq search-highlight t)
  139. (setq query-replace-highlight t)
  140. ;; Easy transition between buffers: M-arrow-keys
  141. (if (equal nil (equal major-mode 'org-mode))
  142. (windmove-default-keybindings 'meta))
  143. ;; Delete trailing whitespaces, format buffer and untabify when save buffer
  144. ;;(defun format-current-buffer()
  145. ;; (indent-region (point-min) (point-max)))
  146. ;;(defun untabify-current-buffer()
  147. ;; (if (not indent-tabs-mode)
  148. ;; (untabify (point-min) (point-max)))
  149. ;; nil)
  150. ;;(add-to-list 'write-file-functions 'format-current-buffer)
  151. ;;(add-to-list 'write-file-functions 'untabify-current-buffer)
  152. ;;(add-to-list 'write-file-functions 'delete-trailing-whitespace)
  153. ;; Mouse support
  154. (xterm-mouse-mode 1)