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.

167 lines
5.6 KiB

  1. ;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings.
  2. ;;
  3. ;; Copyright (c) 2011 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
  6. ;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Lots of useful keybindings.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. (defcustom prelude-enable-additional-keybindings t
  29. "Enable Prelude additional global keybindings"
  30. :type 'boolean
  31. :group 'prelude)
  32. (defcustom prelude-disable-arrow-navigation t
  33. "Disable arrow navigation"
  34. :type 'boolean
  35. :group 'prelude)
  36. (when prelude-enable-additional-keybindings
  37. ;; You know, like Readline.
  38. (global-set-key (kbd "C-M-h") 'backward-kill-word)
  39. ;; Align your code in a pretty way.
  40. (global-set-key (kbd "C-x \\") 'align-regexp)
  41. ;; Perform general cleanup.
  42. (global-set-key (kbd "C-c n") 'prelude-cleanup-buffer)
  43. ;; Font size
  44. (define-key global-map (kbd "C-+") 'text-scale-increase)
  45. (define-key global-map (kbd "C--") 'text-scale-decrease)
  46. ;; Jump to a definition in the current file. (This is awesome.)
  47. (global-set-key (kbd "M-i") 'prelude-ido-goto-symbol)
  48. ;; File finding
  49. (global-set-key (kbd "C-x f") 'prelude-recentf-ido-find-file)
  50. (global-set-key (kbd "C-c r") 'bury-buffer)
  51. (global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
  52. ;; Window switching. (C-x o goes to the next window)
  53. (global-set-key (kbd "C-x O") (lambda ()
  54. (interactive)
  55. (other-window -1))) ;; back one
  56. ;; Indentation help
  57. (global-set-key (kbd "C-x ^") 'join-line)
  58. (global-set-key (kbd "C-M-\\") 'prelude-indent-region-or-buffer)
  59. ;; Start proced in a similar manner to dired
  60. (global-set-key (kbd "C-x p") 'proced)
  61. ;; Start eshell or switch to it if it's active.
  62. (global-set-key (kbd "C-x m") 'eshell)
  63. ;; Start a new eshell even if one is active.
  64. (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
  65. ;; Start a regular shell if you prefer that.
  66. (global-set-key (kbd "C-x M-m") 'shell)
  67. ;; If you want to be able to M-x without meta
  68. (global-set-key (kbd "C-x C-m") 'execute-extended-command)
  69. ;; Fetch the contents at a URL, display it raw.
  70. (global-set-key (kbd "C-x C-h") 'prelude-view-url)
  71. ;; A complementary binding to the apropos-command(C-h a)
  72. (global-set-key (kbd "C-h A") 'apropos)
  73. ;; Should be able to eval-and-replace anywhere.
  74. (global-set-key (kbd "C-c e") 'prelude-eval-and-replace)
  75. ;; Magit rules!
  76. (global-set-key (kbd "C-x g") 'magit-status)
  77. ;; Activate occur easily inside isearch
  78. (define-key isearch-mode-map (kbd "C-o")
  79. (lambda () (interactive)
  80. (let ((case-fold-search isearch-case-fold-search))
  81. (occur (if isearch-regexp
  82. isearch-string
  83. (regexp-quote isearch-string))))))
  84. ;; cycle through buffers
  85. (global-set-key (kbd "<C-tab>") 'bury-buffer)
  86. ;; use hippie-expand instead of dabbrev
  87. (global-set-key (kbd "M-/") 'hippie-expand)
  88. ;; spell check Bulgarian text
  89. (global-set-key (kbd "C-c B")
  90. (lambda()(interactive)
  91. (ispell-change-dictionary "bulgarian")
  92. (flyspell-buffer)))
  93. ;; replace buffer-menu with ibuffer
  94. (global-set-key (kbd "C-x C-b") 'ibuffer)
  95. ;; swap windows
  96. (global-set-key (kbd "C-c s") 'prelude-swap-windows)
  97. ;; duplicate the current line or region
  98. (global-set-key (kbd "C-c d") 'prelude-duplicate-current-line-or-region)
  99. ;; rename buffer & visited file
  100. (global-set-key (kbd "C-c r") 'prelude-rename-file-and-buffer)
  101. ;; open an ansi-term buffer
  102. (global-set-key (kbd "C-x t") 'prelude-visit-term-buffer)
  103. ;; toggle input method
  104. (global-set-key (kbd "C-\\") 'prelude-toggle-bulgarian-input-method)
  105. ;; search with google
  106. (global-set-key (kbd "C-c g") 'prelude-google)
  107. ;; open in external application
  108. (global-set-key (kbd "C-c o") 'prelude-open-with)
  109. ;; toggle menu-bar visibility
  110. (global-set-key (kbd "<f12>") 'menu-bar-mode))
  111. (when prelude-disable-arrow-navigation
  112. ;; real Emacs hackers don't use the arrow keys
  113. (global-set-key (kbd "<up>") (lambda ()
  114. (interactive)
  115. (message "Arrow key navigation is disabled. Use C-p instead.")))
  116. (global-set-key (kbd "<down>") (lambda ()
  117. (interactive)
  118. (message "Arrow key navigation is disabled. Use C-n instead.")))
  119. (global-set-key (kbd "<left>") (lambda ()
  120. (interactive)
  121. (message "Arrow key navigation is disabled. Use C-b instead.")))
  122. (global-set-key (kbd "<right>") (lambda ()
  123. (interactive)
  124. (message "Arrow key navigation is disabled. Use C-f instead."))))
  125. (provide 'prelude-global-keybindings)
  126. ;;; prelude-global-keybindings.el ends here