Merge branch 'master' of github.com:bbatsov/prelude

This commit is contained in:
Bozhidar Batsov 2014-08-28 18:41:05 +03:00
commit 5b4b911b02
3 changed files with 58 additions and 11 deletions

View file

@ -249,7 +249,6 @@ extensions to keybindings.
Keybinding | Description Keybinding | Description
-------------------|------------------------------------------------------------ -------------------|------------------------------------------------------------
<kbd>C-M-h</kbd> | Kill the previous word(`backward-kill-word`). (as in Bash/Zsh)
<kbd>C-x \\</kbd> | `align-regexp` <kbd>C-x \\</kbd> | `align-regexp`
<kbd>C-+</kbd> | Increase font size(`text-scale-increase`). <kbd>C-+</kbd> | Increase font size(`text-scale-increase`).
<kbd>C--</kbd> | Decrease font size(`text-scale-decrease`). <kbd>C--</kbd> | Decrease font size(`text-scale-decrease`).
@ -259,6 +258,7 @@ Keybinding | Description
<kbd>C-x m</kbd> | Start `eshell`. <kbd>C-x m</kbd> | Start `eshell`.
<kbd>C-x M-m</kbd> | Start your default shell. <kbd>C-x M-m</kbd> | Start your default shell.
<kbd>C-x C-m</kbd> | Alias for `M-x`. <kbd>C-x C-m</kbd> | Alias for `M-x`.
<kbd>M-X</kbd> | Like `M-x` but limited to commands that are relevant to the active major mode.
<kbd>C-h A</kbd> | Run `apropos` (search in all Emacs symbols). <kbd>C-h A</kbd> | Run `apropos` (search in all Emacs symbols).
<kbd>C-h C-m</kbd> | Display key bindings of current major mode and descriptions of every binding. <kbd>C-h C-m</kbd> | Display key bindings of current major mode and descriptions of every binding.
<kbd>M-/</kbd> | Run `hippie-expand` (a replacement for the default `dabbrev-expand`). <kbd>M-/</kbd> | Run `hippie-expand` (a replacement for the default `dabbrev-expand`).
@ -303,15 +303,15 @@ Keybinding | Description
<kbd>C-c . -</kbd> | Decrement integer at point. Default is -1. <kbd>C-c . -</kbd> | Decrement integer at point. Default is -1.
<kbd>C-c . *</kbd> | Multiply integer at point. Default is *2. <kbd>C-c . *</kbd> | Multiply integer at point. Default is *2.
<kbd>C-c . /</kbd> | Divide integer at point. Default is /2. <kbd>C-c . /</kbd> | Divide integer at point. Default is /2.
<kbd>C-c . \</kbd> | Modulo integer at point. Default is modulo 2. <kbd>C-c . \\</kbd> | Modulo integer at point. Default is modulo 2.
<kbd>C-c . ^</kbd> | Power to the integer at point. Default is ^2. <kbd>C-c . ^</kbd> | Power to the integer at point. Default is ^2.
<kbd>C-c . <</kbd> | Left-shift integer at point. Default is 1 position to the left. <kbd>C-c . <</kbd> | Left-shift integer at point. Default is 1 position to the left.
<kbd>C-c . ></kbd> | Right-shift integer at point. Default is 1 position to the right. <kbd>C-c . ></kbd> | Right-shift integer at point. Default is 1 position to the right.
<kbd>C-c . #</kbd> | Convert integer at point to specified base. Default is 10. <kbd>C-c . #</kbd> | Convert integer at point to specified base. Default is 10.
<kbd>C-c . %</kbd> | Replace integer at point with another specified integer. <kbd>C-c . %</kbd> | Replace integer at point with another specified integer.
<kbd>C-c . '</kbd> | Perform arithmetic operations on integer at point. User specifies the operator. <kbd>C-c . '</kbd> | Perform arithmetic operations on integer at point. User specifies the operator.
<kbd>Super-g</kbd> | Toggle between God mode and non-God mode
<kbd>Super-r</kbd> | Recent files <kbd>Super-r</kbd> | Recent files
<kbd>Super-x</kbd> | Expand region
<kbd>Super-j</kbd> | Join lines <kbd>Super-j</kbd> | Join lines
<kbd>Super-k</kbd> | Kill whole line <kbd>Super-k</kbd> | Kill whole line
<kbd>Super-m m</kbd> | Magit status <kbd>Super-m m</kbd> | Magit status
@ -344,7 +344,8 @@ Keybinding | Description
<kbd>C-c p f</kbd> | Display a list of all files in the project. With a prefix argument it will clear the cache first. <kbd>C-c p f</kbd> | Display a list of all files in the project. With a prefix argument it will clear the cache first.
<kbd>C-c p d</kbd> | Display a list of all directories in the project. With a prefix argument it will clear the cache first. <kbd>C-c p d</kbd> | Display a list of all directories in the project. With a prefix argument it will clear the cache first.
<kbd>C-c p T</kbd> | Display a list of all test files(specs, features, etc) in the project. <kbd>C-c p T</kbd> | Display a list of all test files(specs, features, etc) in the project.
<kbd>C-c p g</kbd> | Run grep on the files in the project. <kbd>C-c p s g</kbd> | Run grep on the files in the project.
<kbd>M-- C-c p s g</kbd> | Run grep on `projectile-grep-default-files` in the project.
<kbd>C-c p b</kbd> | Display a list of all project buffers currently open. <kbd>C-c p b</kbd> | Display a list of all project buffers currently open.
<kbd>C-c p o</kbd> | Runs `multi-occur` on all project buffers currently open. <kbd>C-c p o</kbd> | Runs `multi-occur` on all project buffers currently open.
<kbd>C-c p r</kbd> | Runs interactive query-replace on all files in the projects. <kbd>C-c p r</kbd> | Runs interactive query-replace on all files in the projects.
@ -353,11 +354,13 @@ Keybinding | Description
<kbd>C-c p k</kbd> | Kills all project buffers. <kbd>C-c p k</kbd> | Kills all project buffers.
<kbd>C-c p D</kbd> | Opens the root of the project in `dired`. <kbd>C-c p D</kbd> | Opens the root of the project in `dired`.
<kbd>C-c p e</kbd> | Shows a list of recently visited project files. <kbd>C-c p e</kbd> | Shows a list of recently visited project files.
<kbd>C-c p s a</kbd> | Runs `ack` on the project. Requires the presence of `ack-and-a-half`.
<kbd>C-c p s s</kbd> | Runs `ag` on the project. Requires the presence of `ag.el`.
<kbd>C-c p a</kbd> | Runs `ack` on the project. Requires the presence of `ack-and-a-half`. <kbd>C-c p a</kbd> | Runs `ack` on the project. Requires the presence of `ack-and-a-half`.
<kbd>C-c p c</kbd> | Runs a standard compilation command for your type of project. <kbd>C-c p c</kbd> | Runs a standard compilation command for your type of project.
<kbd>C-c p p</kbd> | Runs a standard test command for your type of project. <kbd>C-c p p</kbd> | Runs a standard test command for your type of project.
<kbd>C-c p z</kbd> | Adds the currently visited to the cache. <kbd>C-c p z</kbd> | Adds the currently visited to the cache.
<kbd>C-c p s</kbd> | Display a list of known projects you can switch to. <kbd>C-c p p</kbd> | Display a list of known projects you can switch to.
Prelude adds an extra keymap prefix `S-p` (`S` stands for Prelude adds an extra keymap prefix `S-p` (`S` stands for
`Super`), so you can use `S-p` instead of `C-c p`. `Super`), so you can use `S-p` instead of `C-c p`.

View file

@ -379,10 +379,10 @@ Doesn't mess with special buffers."
(defvar prelude-tips (defvar prelude-tips
'("Press <C-c o> to open a file with external program." '("Press <C-c o> to open a file with external program."
"Press <C-c p f> or <s-f> to navigate a project's files with ido." "Press <C-c p f> to navigate a project's files with ido."
"Press <C-c p g> or <s-g> to run grep on a project." "Press <C-c p s g> to run grep on a project."
"Press <C-c p s> or <s-p> to switch between projects." "Press <C-c p p> to switch between projects."
"Press <C-=> or <s-x> to expand the selected region." "Press <C-=> to expand the selected region."
"Press <C-c g> to search in Google." "Press <C-c g> to search in Google."
"Press <C-c G> to search in GitHub." "Press <C-c G> to search in GitHub."
"Press <C-c y> to search in YouTube." "Press <C-c y> to search in YouTube."
@ -390,7 +390,7 @@ Doesn't mess with special buffers."
"Press <C-c r> to rename the current buffer and the file it's visiting if any." "Press <C-c r> to rename the current buffer and the file it's visiting if any."
"Press <C-c t> to open a terminal in Emacs." "Press <C-c t> to open a terminal in Emacs."
"Press <C-c k> to kill all the buffers, but the active one." "Press <C-c k> to kill all the buffers, but the active one."
"Press <C-x g> or <s-m> to run magit-status." "Press <C-x g> to run magit-status."
"Press <C-c D> to delete the current file and buffer." "Press <C-c D> to delete the current file and buffer."
"Press <C-c s> to swap two windows." "Press <C-c s> to swap two windows."
"Press <S-RET> or <M-o> to open a line beneath the current one." "Press <S-RET> or <M-o> to open a line beneath the current one."

View file

@ -35,10 +35,54 @@
(require 'prelude-programming) (require 'prelude-programming)
;; Copy pasted from ruby-mode.el
(defun prelude-python--encoding-comment-required-p ()
(re-search-forward "[^\0-\177]" nil t))
(defun prelude-python--detect-encoding ()
(let ((coding-system
(or save-buffer-coding-system
buffer-file-coding-system)))
(if coding-system
(symbol-name
(or (coding-system-get coding-system 'mime-charset)
(coding-system-change-eol-conversion coding-system nil)))
"ascii-8bit")))
(defun prelude-python--insert-coding-comment (encoding)
(let ((newlines (if (looking-at "^\\s *$") "\n" "\n\n")))
(insert (format "# coding: %s" encoding) newlines)))
(defun prelude-python-mode-set-encoding ()
"Insert a magic comment header with the proper encoding if necessary."
(save-excursion
(widen)
(goto-char (point-min))
(when (prelude-python--encoding-comment-required-p)
(goto-char (point-min))
(let ((coding-system (prelude-python--detect-encoding)))
(when coding-system
(if (looking-at "^#!") (beginning-of-line 2))
(cond ((looking-at "\\s *#\\s *.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)")
;; update existing encoding comment if necessary
(unless (string= (match-string 2) coding-system)
(goto-char (match-beginning 2))
(delete-region (point) (match-end 2))
(insert coding-system)))
((looking-at "\\s *#.*coding\\s *[:=]"))
(t (prelude-python--insert-coding-comment coding-system)))
(when (buffer-modified-p)
(basic-save-buffer-1)))))))
(defun prelude-python-mode-defaults () (defun prelude-python-mode-defaults ()
"Defaults for Python programming." "Defaults for Python programming."
(subword-mode +1) (subword-mode +1)
(electric-indent-mode -1)) (setq-local electric-layout-rules
'((?: . (lambda ()
(if (python-info-statement-starts-block-p)
'after)))))
(electric-layout-mode +1)
(add-hook 'after-save-hook 'prelude-python-mode-set-encoding nil 'local))
(setq prelude-python-mode-hook 'prelude-python-mode-defaults) (setq prelude-python-mode-hook 'prelude-python-mode-defaults)