2012-02-23 18:02:34 +02:00
|
|
|
;;; prelude-mode.el --- Emacs Prelude: minor mode
|
|
|
|
;;
|
2018-05-06 09:21:24 +03:00
|
|
|
;; Copyright © 2011-2018 Bozhidar Batsov
|
2012-02-23 18:02:34 +02:00
|
|
|
;;
|
2012-04-17 17:35:21 +03:00
|
|
|
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
2013-03-07 09:57:33 +02:00
|
|
|
;; URL: https://github.com/bbatsov/prelude
|
2012-02-23 18:02:34 +02:00
|
|
|
;; Version: 1.0.0
|
|
|
|
;; Keywords: convenience
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; A minor mode defining a local keymap, plus a menu.
|
|
|
|
|
|
|
|
;;; License:
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
;; modify it under the terms of the GNU General Public License
|
|
|
|
;; as published by the Free Software Foundation; either version 3
|
|
|
|
;; of the License, or (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
2013-03-07 13:09:13 +02:00
|
|
|
(require 'easymenu)
|
2016-01-30 12:44:16 +02:00
|
|
|
(require 'imenu-anywhere)
|
2016-04-29 04:42:14 +03:00
|
|
|
(require 'crux)
|
2012-02-23 18:02:34 +02:00
|
|
|
|
|
|
|
(defvar prelude-mode-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map (kbd "C-c o") 'crux-open-with)
|
2012-03-09 16:24:25 +02:00
|
|
|
(define-key map (kbd "C-c g") 'prelude-google)
|
2013-09-15 08:53:08 +03:00
|
|
|
(define-key map (kbd "C-c G") 'prelude-github)
|
2013-08-26 17:58:02 +03:00
|
|
|
(define-key map (kbd "C-c y") 'prelude-youtube)
|
2014-01-11 20:19:59 +02:00
|
|
|
(define-key map (kbd "C-c U") 'prelude-duckduckgo)
|
2012-02-23 18:02:34 +02:00
|
|
|
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
|
2016-04-29 20:39:05 +03:00
|
|
|
(define-key map (kbd "C-a") 'crux-move-beginning-of-line)
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map [(shift return)] 'crux-smart-open-line)
|
|
|
|
(define-key map (kbd "M-o") 'crux-smart-open-line)
|
|
|
|
(define-key map [(control shift return)] 'crux-smart-open-line-above)
|
2013-09-17 13:24:03 +03:00
|
|
|
(define-key map [(control shift up)] 'move-text-up)
|
|
|
|
(define-key map [(control shift down)] 'move-text-down)
|
|
|
|
(define-key map [(meta shift up)] 'move-text-up)
|
|
|
|
(define-key map [(meta shift down)] 'move-text-down)
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map (kbd "C-c n") 'crux-cleanup-buffer-or-region)
|
2018-09-17 17:46:02 +03:00
|
|
|
(define-key map (kbd "C-c f") 'crux-recentf-find-file)
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map (kbd "C-M-z") 'crux-indent-defun)
|
|
|
|
(define-key map (kbd "C-c u") 'crux-view-url)
|
|
|
|
(define-key map (kbd "C-c e") 'crux-eval-and-replace)
|
|
|
|
(define-key map (kbd "C-c s") 'crux-swap-windows)
|
|
|
|
(define-key map (kbd "C-c D") 'crux-delete-file-and-buffer)
|
|
|
|
(define-key map (kbd "C-c d") 'crux-duplicate-current-line-or-region)
|
|
|
|
(define-key map (kbd "C-c M-d") 'crux-duplicate-and-comment-current-line-or-region)
|
|
|
|
(define-key map (kbd "C-c r") 'crux-rename-buffer-and-file)
|
|
|
|
(define-key map (kbd "C-c t") 'crux-visit-term-buffer)
|
|
|
|
(define-key map (kbd "C-c k") 'crux-kill-other-buffers)
|
|
|
|
(define-key map (kbd "C-c TAB") 'crux-indent-rigidly-and-copy-to-clipboard)
|
|
|
|
(define-key map (kbd "C-c I") 'crux-find-user-init-file)
|
|
|
|
(define-key map (kbd "C-c S") 'crux-find-shell-init-file)
|
2016-01-30 12:44:16 +02:00
|
|
|
(define-key map (kbd "C-c i") 'imenu-anywhere)
|
2014-07-14 17:50:45 +03:00
|
|
|
;; extra prefix for projectile
|
|
|
|
(define-key map (kbd "s-p") 'projectile-command-map)
|
2018-08-08 15:32:52 +03:00
|
|
|
(define-key map (kbd "C-c p") 'projectile-command-map)
|
2013-07-23 15:18:50 +03:00
|
|
|
;; make some use of the Super key
|
2018-09-17 17:46:02 +03:00
|
|
|
(define-key map (kbd "s-r") 'crux-recentf-find-file)
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map (kbd "s-j") 'crux-top-join-line)
|
|
|
|
(define-key map (kbd "s-k") 'crux-kill-whole-line)
|
2013-09-18 16:31:39 +03:00
|
|
|
(define-key map (kbd "s-m m") 'magit-status)
|
|
|
|
(define-key map (kbd "s-m l") 'magit-log)
|
2015-07-11 15:25:41 +03:00
|
|
|
(define-key map (kbd "s-m f") 'magit-log-buffer-file)
|
2015-07-12 00:07:39 +03:00
|
|
|
(define-key map (kbd "s-m b") 'magit-blame)
|
2016-04-29 04:42:14 +03:00
|
|
|
(define-key map (kbd "s-o") 'crux-smart-open-line-above)
|
2018-09-28 09:13:55 +03:00
|
|
|
(easy-menu-define prelude-mode-menu map
|
|
|
|
"Prelude's menu."
|
|
|
|
'("Prelude"
|
|
|
|
("Files"
|
|
|
|
["Open with..." crux-open-with]
|
|
|
|
["Re-open as root" crux-reopen-as-root]
|
|
|
|
["Delete file and buffer" crux-delete-file-and-buffer]
|
|
|
|
["Rename buffer and file" crux-rename-buffer-and-file]
|
|
|
|
["Find init file" crux-find-user-init-file]
|
|
|
|
["Find custom file" crux-find-user-custom-file]
|
|
|
|
["Find shell config file" crux-find-shell-init-file])
|
|
|
|
("Buffers"
|
|
|
|
["Clean up buffer or region" crux-cleanup-buffer-or-region]
|
|
|
|
["Kill other buffers" crux-kill-other-buffers])
|
|
|
|
("Editing"
|
|
|
|
["Go to beginning of line" crux-move-beginning-of-line]
|
|
|
|
["Kill line" crux-smart-kill-line]
|
|
|
|
["Kill whole line" crux-kill-whole-line]
|
|
|
|
["Insert empty line below" crux-smart-open-line]
|
|
|
|
["insert empty line above" crux-smart-open-line-above]
|
|
|
|
["Move up" move-text-up]
|
|
|
|
["Move down" move-text-down]
|
|
|
|
["Duplicate line or region" crux-duplicate-current-line-or-region]
|
|
|
|
["Indent rigidly and copy to clipboard" crux-indent-rigidly-and-copy-to-clipboard]
|
|
|
|
["Indent defun" crux-indent-defun]
|
|
|
|
["Insert date" crux-insert-date]
|
|
|
|
["Eval and replace" crux-eval-and-replace])
|
|
|
|
("Windows"
|
|
|
|
["Swap windows" crux-swap-windows])
|
|
|
|
("General"
|
|
|
|
["Visit term buffer" crux-visit-term-buffer]
|
|
|
|
["Search in Google" prelude-google]
|
2018-09-28 17:34:53 +03:00
|
|
|
["View URL" crux-view-url])))
|
2012-02-23 18:02:34 +02:00
|
|
|
map)
|
|
|
|
"Keymap for Prelude mode.")
|
|
|
|
|
|
|
|
;; define minor mode
|
|
|
|
(define-minor-mode prelude-mode
|
2013-01-01 21:27:22 +02:00
|
|
|
"Minor mode to consolidate Emacs Prelude extensions.
|
|
|
|
|
|
|
|
\\{prelude-mode-map}"
|
2013-03-06 21:43:59 +02:00
|
|
|
:lighter " Pre"
|
2012-02-23 18:02:34 +02:00
|
|
|
:keymap prelude-mode-map
|
2018-09-28 09:13:55 +03:00
|
|
|
:global t)
|
2013-03-07 13:09:13 +02:00
|
|
|
|
2012-02-23 18:02:34 +02:00
|
|
|
(provide 'prelude-mode)
|
|
|
|
;;; prelude-mode.el ends here
|