Skip to content

Commit

Permalink
Change the prefix for the Projectile mode commands to C-c C-p
Browse files Browse the repository at this point in the history
This brings the default keymap in line with the established Emacs
conventions.

If someone misses the old keybinding:

```
(setq projectile-keymap-prefix (kbd "C-c p"))
```
  • Loading branch information
bbatsov committed Jul 21, 2018
1 parent ebdde77 commit b90b950
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Changes

* **(Breaking)** Change the prefix for the Projectile mode commands to `C-c C-p`.

## 1.0.0 (2018-07-21)

### New Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ simply `apt-get install elpa-projectile`.

### Basic Usage

Enable `projectile-mode`, open a file in one of your projects and type a command such as <kbd>C-c p f</kbd>.
Enable `projectile-mode`, open a file in one of your projects and type a command such as <kbd>C-c C-p f</kbd>.

See the user manual for more details.

Expand Down
10 changes: 5 additions & 5 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ To enable caching unconditionally use this snippet of code:
(setq projectile-enable-caching t)
```

At this point you can try out a Projectile command such as <kbd>C-c p f</kbd> (<kbd>M-x projectile-find-file RET</kbd>).
At this point you can try out a Projectile command such as <kbd>C-c C-p f</kbd> (<kbd>M-x projectile-find-file RET</kbd>).

Running <kbd>C-u C-c p f</kbd> will invalidate the cache prior to
Running <kbd>C-u C-c C-p f</kbd> will invalidate the cache prior to
prompting you for a file to jump to.

Pressing <kbd>C-c p z</kbd> will add the currently visited file to the
Pressing <kbd>C-c C-p z</kbd> will add the currently visited file to the
cache for current project. Generally files created outside Emacs will
be added to the cache automatically the first time you open them.

Expand Down Expand Up @@ -101,7 +101,7 @@ This might not be a great idea if you start Projectile in your home folder for i

## Switching projects

When running `projectile-switch-project` (<kbd>C-c p p</kbd>) Projectile invokes
When running `projectile-switch-project` (<kbd>C-c C-p p</kbd>) Projectile invokes
the command specified in `projectile-switch-project-action` (by default it is
`projectile-find-file`).

Expand Down Expand Up @@ -317,7 +317,7 @@ function. It could also be used to e.g. add such a function to a key
map.

You can also quickly visit or create the `dir-locals-file` with
<kbd>C-c p E</kbd> (<kbd>M-x projectile-edit-dir-locals RET</kbd>).
<kbd>C-c C-p E</kbd> (<kbd>M-x projectile-edit-dir-locals RET</kbd>).

Here are a few examples of how to use this feature with Projectile.

Expand Down
106 changes: 55 additions & 51 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,69 @@ Here's a list of the interactive Emacs Lisp functions, provided by Projectile:

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 all known projects.
<kbd>C-c p g</kbd> | Display a list of all files at point in the project. With a prefix argument it will clear the cache first.
<kbd>C-c p 4 f</kbd> | Jump to a project's file using completion and show it in another window.
<kbd>C-c p 4 g</kbd> | Jump to a project's file based on context at point and show it in another window.
<kbd>C-c p 5 f</kbd> | Jump to a project's file using completion and show it in another frame.
<kbd>C-c p 5 g</kbd> | Jump to a project's file based on context at point and show it in another frame.
<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 4 d</kbd> | Switch to a project directory and show it in another window.
<kbd>C-c p 5 d</kbd> | Switch to a project directory and show it in another frame.
<kbd>C-c p T</kbd> | Display a list of all test files(specs, features, etc) in the project.
<kbd>C-c p l</kbd> | Display a list of all files in a directory (that's not necessarily a 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 v</kbd> | Run `vc-dir` on the root directory of the project.
<kbd>C-c p V</kbd> | Browse dirty version controlled projects.
<kbd>C-c p b</kbd> | Display a list of all project buffers currently open.
<kbd>C-c p 4 b</kbd> | Switch to a project buffer and show it in another window.
<kbd>C-c p 5 b</kbd> | Switch to a project buffer and show it in another frame.
<kbd>C-c p 4 C-o</kbd> | Display a project buffer in another window without selecting it.
<kbd>C-c p a</kbd> | Switch between files with the same name but different extensions.
<kbd>C-c p 4 a</kbd> | Switch between files with the same name but different extensions in other window.
<kbd>C-c p 5 a</kbd> | Switch between files with the same name but different extensions in other frame.
<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 i</kbd> | Invalidates the project cache (if existing).
<kbd>C-c p R</kbd> | Regenerates the projects `TAGS` file.
<kbd>C-c p j</kbd> | Find tag in project's `TAGS` file.
<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 4 D</kbd> | Opens the root of the project in `dired` in another window.
<kbd>C-c p 5 D</kbd> | Opens the root of the project in `dired` in another frame.
<kbd>C-c p e</kbd> | Shows a list of recently visited project files.
<kbd>C-c p E</kbd> | Opens the root `dir-locals-file` of the project.
<kbd>C-c p s s</kbd> | Runs `ag` on the project. Requires the presence of `ag.el`.
<kbd>C-c p !</kbd> | Runs `shell-command` in the root directory of the project.
<kbd>C-c p &</kbd> | Runs `async-shell-command` in the root directory of the project.
<kbd>C-c p C</kbd> | Runs a standard configure 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 t</kbd> | Toggle between an implementation file and its test file.
<kbd>C-c p 4 t</kbd> | Jump to implementation or test file in other window.
<kbd>C-c p 5 t</kbd> | Jump to implementation or test file in other frame.
<kbd>C-c p z</kbd> | Adds the currently visited file to the cache.
<kbd>C-c p p</kbd> | Display a list of known projects you can switch to.
<kbd>C-c p S</kbd> | Save all project buffers.
<kbd>C-c p m</kbd> | Run the commander (an interface to run commands with a single key).
<kbd>C-c p ESC</kbd> | Switch to the most recently selected Projectile buffer.
<kbd>C-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 C-p F</kbd> | Display a list of all files in all known projects.
<kbd>C-c C-p g</kbd> | Display a list of all files at point in the project. With a prefix argument it will clear the cache first.
<kbd>C-c C-p 4 f</kbd> | Jump to a project's file using completion and show it in another window.
<kbd>C-c C-p 4 g</kbd> | Jump to a project's file based on context at point and show it in another window.
<kbd>C-c C-p 5 f</kbd> | Jump to a project's file using completion and show it in another frame.
<kbd>C-c C-p 5 g</kbd> | Jump to a project's file based on context at point and show it in another frame.
<kbd>C-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 C-p 4 d</kbd> | Switch to a project directory and show it in another window.
<kbd>C-c C-p 5 d</kbd> | Switch to a project directory and show it in another frame.
<kbd>C-c C-p T</kbd> | Display a list of all test files(specs, features, etc) in the project.
<kbd>C-c C-p l</kbd> | Display a list of all files in a directory (that's not necessarily a project)
<kbd>C-c C-p s g</kbd> | Run grep on the files in the project.
<kbd>M-- C-c C-p s g</kbd> | Run grep on `projectile-grep-default-files` in the project.
<kbd>C-c C-p v</kbd> | Run `vc-dir` on the root directory of the project.
<kbd>C-c C-p V</kbd> | Browse dirty version controlled projects.
<kbd>C-c C-p b</kbd> | Display a list of all project buffers currently open.
<kbd>C-c C-p 4 b</kbd> | Switch to a project buffer and show it in another window.
<kbd>C-c C-p 5 b</kbd> | Switch to a project buffer and show it in another frame.
<kbd>C-c C-p 4 C-o</kbd> | Display a project buffer in another window without selecting it.
<kbd>C-c C-p a</kbd> | Switch between files with the same name but different extensions.
<kbd>C-c C-p 4 a</kbd> | Switch between files with the same name but different extensions in other window.
<kbd>C-c C-p 5 a</kbd> | Switch between files with the same name but different extensions in other frame.
<kbd>C-c C-p o</kbd> | Runs `multi-occur` on all project buffers currently open.
<kbd>C-c C-p r</kbd> | Runs interactive query-replace on all files in the projects.
<kbd>C-c C-p i</kbd> | Invalidates the project cache (if existing).
<kbd>C-c C-p R</kbd> | Regenerates the projects `TAGS` file.
<kbd>C-c C-p j</kbd> | Find tag in project's `TAGS` file.
<kbd>C-c C-p k</kbd> | Kills all project buffers.
<kbd>C-c C-p D</kbd> | Opens the root of the project in `dired`.
<kbd>C-c C-p 4 D</kbd> | Opens the root of the project in `dired` in another window.
<kbd>C-c C-p 5 D</kbd> | Opens the root of the project in `dired` in another frame.
<kbd>C-c C-p e</kbd> | Shows a list of recently visited project files.
<kbd>C-c C-p E</kbd> | Opens the root `dir-locals-file` of the project.
<kbd>C-c C-p s s</kbd> | Runs `ag` on the project. Requires the presence of `ag.el`.
<kbd>C-c C-p !</kbd> | Runs `shell-command` in the root directory of the project.
<kbd>C-c C-p &</kbd> | Runs `async-shell-command` in the root directory of the project.
<kbd>C-c C-p C</kbd> | Runs a standard configure command for your type of project.
<kbd>C-c C-p c</kbd> | Runs a standard compilation command for your type of project.
<kbd>C-c C-p P</kbd> | Runs a standard test command for your type of project.
<kbd>C-c C-p t</kbd> | Toggle between an implementation file and its test file.
<kbd>C-c C-p 4 t</kbd> | Jump to implementation or test file in other window.
<kbd>C-c C-p 5 t</kbd> | Jump to implementation or test file in other frame.
<kbd>C-c C-p z</kbd> | Adds the currently visited file to the cache.
<kbd>C-c C-p p</kbd> | Display a list of known projects you can switch to.
<kbd>C-c C-p S</kbd> | Save all project buffers.
<kbd>C-c C-p m</kbd> | Run the commander (an interface to run commands with a single key).
<kbd>C-c C-p ESC</kbd> | Switch to the most recently selected Projectile buffer.

If you ever forget any of Projectile's keybindings just do a:

<kbd>C-c p C-h</kbd>
<kbd>C-c C-p C-h</kbd>

You can change the default keymap prefix `C-c p` like this:
You can change the default keymap prefix `C-c C-p` like this:

```el
(setq projectile-keymap-prefix (kbd "C-c C-p"))
(setq projectile-keymap-prefix (kbd "C-c p"))
```

!!! Note

`C-c p` used to be the default prefix up to version 1.1.

It is also possible to add additional commands to
`projectile-command-map` referenced by the prefix key in
`projectile-mode-map`. You can even add an alternative prefix for all
Expand Down
2 changes: 1 addition & 1 deletion projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Otherwise consider the current directory the project root."
(const :tag "Default" default)
(function :tag "Custom function")))

(defcustom projectile-keymap-prefix (kbd "C-c p")
(defcustom projectile-keymap-prefix (kbd "C-c C-p")
"Projectile keymap prefix."
:group 'projectile
:type 'string)
Expand Down

6 comments on commit b90b950

@goodbobk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-c C-p prefix conflicts with Cider's cider-pprint-eval-last-sexp 8(

@bbatsov
Copy link
Owner Author

@bbatsov bbatsov commented on b90b950 Jul 22, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seagle0128
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of changing "C-c p" to "C-c C-p"?
It's conflicted with wgrep-ag. I know the workarounds, but don't know the reason.

@bbatsov
Copy link
Owner Author

@bbatsov bbatsov commented on b90b950 Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-c p is reserved user keybindings, it should not be used by minor modes. Obviously there's always some potential for conflicts between the keymaps in different minor modes. That's unavoidable, that's why Projectile makes it easy to change the prefix.

@bbatsov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html

Don't define C-c letter as a key in Lisp programs. Sequences consisting of C-c and a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them.

@seagle0128
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the information!

Please sign in to comment.