buffer.cfg.el 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ;;; buffer.cfg.el --- Summary
  2. ;;; Commentary:
  3. ;;; configuration for buffer-related stuff.
  4. ;;; Code:
  5. (use-package comint
  6. :functions my-shell-turn-echo-off View-quit
  7. :defines comint-process-echoes universal-argument-num-events
  8. :init
  9. (defun my-shell-turn-echo-off ()
  10. "Do not echo stuff in shell-mode."
  11. (setq comint-process-echoes t))
  12. (add-hook 'shell-mode-hook #'my-shell-turn-echo-off)
  13. :bind (:map comint-mode-map
  14. ("C-c C-l" . helm-comint-input-ring)))
  15. (use-package compile
  16. :defines compilation-scroll-output
  17. :init
  18. (setq compilation-scroll-output t))
  19. ;; Case-insensitive search
  20. (setq case-fold-search t)
  21. (setq current-language-environment "UTF-8")
  22. (setq default-input-method "utf-8")
  23. (prefer-coding-system 'utf-8)
  24. (when (display-graphic-p)
  25. (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
  26. (use-package dired
  27. :config
  28. ;; Don't spawn a new buffer for every directory I visit.
  29. (put 'dired-find-alternate-file 'disabled nil)
  30. :bind (:map dired-mode-map
  31. ("RET" . dired-find-alternate-file)))
  32. (use-package smartscan
  33. :config
  34. (global-smartscan-mode 1))
  35. (use-package saveplace
  36. :defines save-place-file
  37. :config
  38. (setq-default save-place t)
  39. (setq save-place-file (concat user-emacs-directory "saved-places")))
  40. ;; Same-frame speedbar
  41. (use-package sr-speedbar
  42. :init
  43. ;; Use Semantic with Speedbar
  44. (add-hook 'speedbar-load-hook #'(lambda () (require 'semantic/sb)))
  45. ;; Win-S
  46. :bind ("s-S" . sr-speedbar-toggle))
  47. (global-set-key (kbd "RET") 'newline-and-indent)
  48. (setq require-final-newline t)
  49. ;; Start from the top when usint C-l
  50. (setq recenter-positions '(top middle bottom))
  51. ;; use shift to move around windows
  52. (windmove-default-keybindings 'shift)
  53. ;; Window splitting and navigation.
  54. (winner-mode 1)
  55. (use-package windresize
  56. :bind ("C-c r" . windresize))
  57. (use-package popwin
  58. :functions popwin-mode
  59. :config
  60. (popwin-mode 1))
  61. ;; Make unique buffer names better.
  62. ;; That's the default in emacs 24.4 and above.
  63. (use-package uniquify
  64. :if (string< emacs-version "24.4")
  65. :config
  66. (setq uniquify-buffer-name-style 'post-forward-angle-brackets))
  67. ;; http://www.masteringemacs.org/articles/2014/02/28/my-emacs-keybindings/
  68. (defun kill-this-buffer ()
  69. "Kill the current buffer."
  70. (interactive)
  71. (kill-buffer (current-buffer)))
  72. (global-set-key "\C-x\C-k" 'kill-this-buffer)
  73. (defun revert-this-buffer ()
  74. "Revert the current buffer."
  75. (interactive)
  76. (revert-buffer nil t t)
  77. (message (concat "Reverted buffer " (buffer-name))))
  78. (global-set-key [f6] 'revert-this-buffer)
  79. ;; http://www.emacswiki.org/emacs/FlySpell
  80. ;; Printing messages for every word (when checking the entire buffer) causes an enormous slowdown.
  81. (use-package flyspell
  82. :config
  83. (setq flyspell-issue-message-flag nil)
  84. :delight flyspell-mode)
  85. (use-package ispell
  86. :if (executable-find "aspell")
  87. :config
  88. (when (boundp 'ispell-list-command)
  89. (setq
  90. ;; http://www.emacswiki.org/emacs/FlySpell
  91. ;; Use --list instead of -l because the -l option means --lang in aspell
  92. ispell-list-command "--list"))
  93. (setq ispell-program-name "aspell"
  94. ;; http://blog.binchen.org/posts/effective-spell-check-in-emacs.html
  95. ;; force the English dictionary, support Camel Case spelling check (--run-together)
  96. ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together" "--run-together-limit=5" "--run-together-min=2")))
  97. (use-package hideshow
  98. :delight hs-minor-mode)
  99. (use-package drag-stuff
  100. :defines drag-stuff-mode-map
  101. ;; Explicitly define keys as drag-stuff ones don't seem to work.
  102. :bind (:map drag-stuff-mode-map
  103. ("<M-S-up>" . drag-stuff-up)
  104. ("<M-S-down>" . drag-stuff-down)
  105. ("<M-S-left>" . drag-stuff-left)
  106. ("<M-S-right>" . drag-stuff-right))
  107. :delight drag-stuff-mode)
  108. (drag-stuff-global-mode t)
  109. (use-package clean-aindent-mode
  110. :init
  111. (add-hook 'prog-mode-hook #'clean-aindent-mode))
  112. ;; unobtrusively trim white spaces from end of line
  113. (use-package ws-butler
  114. :init
  115. (add-hook 'prog-mode-hook #'ws-butler-mode)
  116. :delight ws-butler-mode)
  117. ;; improved undo system
  118. (use-package undo-tree
  119. :config
  120. (global-undo-tree-mode)
  121. :delight undo-tree-mode)
  122. ;; Works best when Editorconfig C Core is installed
  123. (use-package editorconfig
  124. :config
  125. (editorconfig-mode 1)
  126. :delight editorconfig-mode)
  127. ;; Better navigation for CamelCase words
  128. (use-package subword
  129. :hook ((java-mode kotlin-mode go-mode) . subword-mode))
  130. ;; AutoType Skeletons
  131. ;; They can be called like a function: M-x <skeleton name> in a buffer
  132. ;; See http://www.gnu.org/software/emacs/manual/html_mono/autotype.html
  133. (define-skeleton my/skeletons/elisp-package
  134. "Skeleton to Elisp packages"
  135. > ";;; " (buffer-name) " --- Summary\n"
  136. > ";;; Commentary:\n"
  137. > ";;; " _ "\n"
  138. > ";;; Code:\n"
  139. > "\n"
  140. > "(provide '" (substring (buffer-name) 0 -3) ")\n"
  141. > ";;; " (buffer-name) " ends here\n")
  142. (use-package direnv :config (direnv-mode))
  143. (provide 'buffer.cfg)
  144. ;;; buffer.cfg.el ends here