introduced prelude-mode

This commit is contained in:
Bozhidar Batsov 2012-02-23 18:02:34 +02:00
parent 6a1ca6b0dc
commit 605afde052
5 changed files with 118 additions and 42 deletions

View file

@ -64,6 +64,7 @@ by Prelude.")
(require 'prelude-packages) (require 'prelude-packages)
(require 'prelude-ui) (require 'prelude-ui)
(require 'prelude-core) (require 'prelude-core)
(require 'prelude-mode)
(require 'prelude-editor) (require 'prelude-editor)
(require 'prelude-global-keybindings) (require 'prelude-global-keybindings)

View file

@ -109,17 +109,12 @@ the curson at its beginning, according to the current mode."
(next-line 1) (next-line 1)
(indent-according-to-mode)) (indent-according-to-mode))
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
(global-set-key [(shift return)] 'prelude-insert-empty-line)
(defun prelude-move-line-up () (defun prelude-move-line-up ()
"Move up the current line." "Move up the current line."
(interactive) (interactive)
(transpose-lines 1) (transpose-lines 1)
(previous-line 2)) (previous-line 2))
(global-set-key [(control shift up)] 'prelude-move-line-up)
(defun prelude-move-line-down () (defun prelude-move-line-down ()
"Move down the current line." "Move down the current line."
(interactive) (interactive)
@ -127,8 +122,6 @@ the curson at its beginning, according to the current mode."
(transpose-lines 1) (transpose-lines 1)
(previous-line 1)) (previous-line 1))
(global-set-key [(control shift down)] 'prelude-move-line-down)
;; add the ability to copy and cut the current line, without marking it ;; add the ability to copy and cut the current line, without marking it
(defadvice kill-ring-save (before slick-copy activate compile) (defadvice kill-ring-save (before slick-copy activate compile)
"When called interactively with no active region, copy a single line instead." "When called interactively with no active region, copy a single line instead."

View file

@ -185,6 +185,9 @@
;; ediff - don't start another frame ;; ediff - don't start another frame
(setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; enable Prelude's keybindings
(prelude-global-mode t)
(provide 'prelude-editor) (provide 'prelude-editor)
;;; prelude-editor.el ends here ;;; prelude-editor.el ends here

View file

@ -38,18 +38,11 @@
;; Align your code in a pretty way. ;; Align your code in a pretty way.
(global-set-key (kbd "C-x \\") 'align-regexp) (global-set-key (kbd "C-x \\") 'align-regexp)
;; Perform general cleanup.
(global-set-key (kbd "C-c n") 'prelude-cleanup-buffer)
;; Font size ;; Font size
(define-key global-map (kbd "C-+") 'text-scale-increase) (define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease) (define-key global-map (kbd "C--") 'text-scale-decrease)
;; Jump to a definition in the current file. (This is awesome.)
(global-set-key (kbd "M-i") 'prelude-ido-goto-symbol)
;; File finding ;; File finding
(global-set-key (kbd "C-x f") 'prelude-recentf-ido-find-file)
(global-set-key (kbd "C-c r") 'bury-buffer) (global-set-key (kbd "C-c r") 'bury-buffer)
(global-set-key (kbd "M-`") 'file-cache-minibuffer-complete) (global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
@ -60,7 +53,6 @@
;; Indentation help ;; Indentation help
(global-set-key (kbd "C-x ^") 'join-line) (global-set-key (kbd "C-x ^") 'join-line)
(global-set-key (kbd "C-M-\\") 'prelude-indent-region-or-buffer)
;; Start proced in a similar manner to dired ;; Start proced in a similar manner to dired
(global-set-key (kbd "C-x p") 'proced) (global-set-key (kbd "C-x p") 'proced)
@ -77,15 +69,9 @@
;; If you want to be able to M-x without meta ;; If you want to be able to M-x without meta
(global-set-key (kbd "C-x C-m") 'execute-extended-command) (global-set-key (kbd "C-x C-m") 'execute-extended-command)
;; Fetch the contents at a URL, display it raw.
(global-set-key (kbd "C-x C-h") 'prelude-view-url)
;; A complementary binding to the apropos-command(C-h a) ;; A complementary binding to the apropos-command(C-h a)
(global-set-key (kbd "C-h A") 'apropos) (global-set-key (kbd "C-h A") 'apropos)
;; Should be able to eval-and-replace anywhere.
(global-set-key (kbd "C-c e") 'prelude-eval-and-replace)
;; Activate occur easily inside isearch ;; Activate occur easily inside isearch
(define-key isearch-mode-map (kbd "C-o") (define-key isearch-mode-map (kbd "C-o")
(lambda () (interactive) (lambda () (interactive)
@ -103,27 +89,6 @@
;; replace buffer-menu with ibuffer ;; replace buffer-menu with ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer) (global-set-key (kbd "C-x C-b") 'ibuffer)
;; swap windows
(global-set-key (kbd "C-c s") 'prelude-swap-windows)
;; duplicate the current line or region
(global-set-key (kbd "C-c d") 'prelude-duplicate-current-line-or-region)
;; rename buffer & visited file
(global-set-key (kbd "C-c r") 'prelude-rename-file-and-buffer)
;; open an ansi-term buffer
(global-set-key (kbd "C-x t") 'prelude-visit-term-buffer)
;; kill other buffers
(global-set-key (kbd "C-c k o") 'prelude-kill-other-buffers)
;; search with google
(global-set-key (kbd "C-c g") 'prelude-google)
;; open in external application
(global-set-key (kbd "C-c o") 'prelude-open-with)
;; toggle menu-bar visibility ;; toggle menu-bar visibility
(global-set-key (kbd "<f12>") 'menu-bar-mode) (global-set-key (kbd "<f12>") 'menu-bar-mode)

114
modules/prelude-mode.el Normal file
View file

@ -0,0 +1,114 @@
;;; prelude-mode.el --- Emacs Prelude: minor mode
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
;; 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:
(defvar prelude-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-p o") 'prelude-open-with)
(define-key map (kbd "C-c C-p g") 'prelude-google)
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
(define-key map [(shift return)] 'prelude-insert-empty-line)
(define-key map [(control shift up)] 'prelude-move-line-up)
(define-key map [(control shift down)] 'prelude-move-line-down)
(define-key map (kbd "C-c C-p n") 'prelude-cleanup-buffer)
(define-key map (kbd "C-c C-p f") 'prelude-recentf-ido-find-file)
(define-key map (kbd "C-c C-p i") 'prelude-ido-goto-symbol)
(define-key map (kbd "C-M-\\") 'prelude-indent-region-or-buffer)
(define-key map (kbd "C-c C-p h") 'prelude-view-url)
(define-key map (kbd "C-c C-p e") 'prelude-eval-and-replace)
(define-key map (kbd "C-c C-p s") 'prelude-swap-windows)
(define-key map (kbd "C-c C-p d") 'prelude-duplicate-current-line-or-region)
(define-key map (kbd "C-c C-p r") 'prelude-rename-file-and-buffer)
(define-key map (kbd "C-c C-p t") 'prelude-visit-term-buffer)
(define-key map (kbd "C-c C-p k") 'prelude-kill-other-buffers)
map)
"Keymap for Prelude mode.")
(easy-menu-define prelude-mode-menu prelude-mode-map
"Menu for Prelude mode"
'("Prelude"
("Files"
["Open with..." prelude-open-with]
["Delete file and buffer" prelude-delete-file-and-buffer]
["Rename file and buffer" prelude-rename-file-and-buffer]
["Copy file name to clipboard" prelude-copy-file-name-to-clipboard])
("Buffers"
["Clean up buffer" prelude-cleanup-buffer]
["Kill other buffers" prelude-kill-other-buffers])
("Editing"
["Insert empty line" prelude-insert-empty-line]
["Move line up" prelude-move-line-up]
["Move line down" prelude-move-line-down]
["Indent buffer" prelude-indent-buffer]
["Indent buffer or region" prelude-indent-buffer-or-region]
["Duplicate line or region" prelude-duplicate-current-line-or-region]
["Copy to clipboard as blockquote" prelude-indent-blockquote-and-copy-to-clipboard]
["Copy to clipboard as nested blockqoute" prelude-indent-nested-blockquote-and-copy-to-clipboard]
["Insert date" prelude-insert-date]
["Eval and replace" prelude-eval-and-replace])
("Navigation"
["Enable arrow keys" prelude-restore-arrow-keys]
["Go to symbol" prelude-ido-goto-symbol])
("Windows"
["Swap windows" prelude-swap-windows])
("General"
["Visit term buffer" prelude-visit-term-buffer]
["Search in Google" prelude-google]
["View URL" prelude-view-url])))
;; define minor mode
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
(defun prelude-on ()
(prelude-mode t))
(defun prelude-off ()
(easy-menu-remove))
(define-minor-mode prelude-mode
"Minor mode to consolidate Emacs Prelude extensions."
:lighter "Prelude"
:keymap prelude-mode-map
(if prelude-mode
;; on start
(easy-menu-add prelude-mode-menu prelude-mode-map)
;; on stop
(prelude-off)))
(provide 'prelude-mode)
;;; prelude-mode.el ends here