Skip to content

Commit

Permalink
Don't provide any default keymap prefix
Browse files Browse the repository at this point in the history
Turns out C-c C-p conflicted with many modes, so I think it's best
to just leave it to the users to select whatever works best for them.
  • Loading branch information
bbatsov committed Aug 8, 2018
1 parent 1d24594 commit 9c6e981
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 71 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
### Changes

* Handle files with special characters in `projectile-get-other-files`
* * [#1260](https://github.com/bbatsov/projectile/pull/1260): ignored-*-p: Now they match against regular expressions.
* **(Breaking)** Change the prefix for the Projectile mode commands to `C-c C-p`.
* [#1260](https://github.com/bbatsov/projectile/pull/1260): ignored-*-p: Now they match against regular expressions.
* **(Breaking)** Remove the default prefix key (`C-c p`) for Projectile. Users now have to pick one themselves.
* Deprecate `projectile-keymap-prefix`.
* Avoid "No projects needed to be removed." messages in global mode

## 1.0.0 (2018-07-21)
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,19 @@ You can install Projectile with the following command:
Alternatively, users of Debian 9 or later or Ubuntu 16.04 or later may
simply `apt-get install elpa-projectile`.

Finally add this to your Emacs config:

```el
(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
```

Those keymap prefixes are just a suggestion. Feel free to put there whatever works best for you.

### Basic Usage

Enable `projectile-mode`, open a file in one of your projects and type a command such as <kbd>C-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 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 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>s-p f</kbd> (<kbd>M-x projectile-find-file RET</kbd>).

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

Pressing <kbd>C-c C-p z</kbd> will add the currently visited file to the
Pressing <kbd>s-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 C-p p</kbd>) Projectile invokes
When running `projectile-switch-project` (<kbd>s-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 C-p E</kbd> (<kbd>M-x projectile-edit-dir-locals RET</kbd>).
<kbd>s-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
18 changes: 18 additions & 0 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ Stable by adding this to your Emacs initialization:
(add-to-list 'package-pinned-packages '(projectile . "melpa-stable") t)
```

Finally add this to your Emacs config:

```el
(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
```

Those keymap prefixes are just a suggestion. Feel free to put there whatever works best for you.

!!! Note

`C-c p` used to be the default prefix up to version 1.1, but
starting with version 1.1 you have to select prefix key(s)
yourself.

### Installation via use-package

`use-package` can be used to install Projectile via the `package.el`'s repositories
Expand All @@ -72,6 +88,7 @@ the `master` branch, declare the following in your Emacs initialization file
:ensure t
:config
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode +1))
```

Expand All @@ -84,6 +101,7 @@ releases of Projectile, you'd declare the following:
:pin melpa-stable
:config
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode +1))
```

Expand Down
117 changes: 56 additions & 61 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,77 +23,72 @@ more powerful alternative to `ido`'s built-in `flex` matching.

## Interactive Commands

!!! Note

Projectile doesn't have a default key prefix for its commands, but all the examples
in the manual assume you've opted for `s-p`.

This comment has been minimized.

Copy link
@mrcoles

mrcoles Aug 22, 2018

This is probably obvious, but what is s-p? How does someone type that?

C-c p makes sense: as [control] + [c] and then [p]

The README does suggest setting both:

(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

This comment has been minimized.

Copy link
@bbatsov

bbatsov Aug 23, 2018

Author Owner

s (super) is the Command key in macOS or the Windows key otherwise.

This comment has been minimized.

Copy link
@mrcoles

mrcoles Aug 23, 2018

thanks—that’s super helpful! 😜

Using the <super> key looks trickier on terminal-based Emacs vs Emacs GUI. Maybe that’s why it seemed foreign to me 🤔


Here's a list of the interactive Emacs Lisp functions, provided by Projectile:

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

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

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

!!! Note

`C-c p` used to be the default prefix up to version 1.1.
<kbd>s-p C-h</kbd>

It is also possible to add additional commands to
It is 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
commands. Here's an example that adds `super-p` as the extra prefix:
commands. Here's an example that adds `super-p` as a command prefix:

```el
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
Expand Down
7 changes: 5 additions & 2 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ Otherwise consider the current directory the project root."
(const :tag "Default" default)
(function :tag "Custom function")))

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

(make-obsolete-variable 'projectile-keymap-prefix "Use (define-key projectile-mode-map (kbd ...) 'projectile-command-map) instead." "1.1.0")

(defcustom projectile-cache-file
(expand-file-name "projectile.cache" user-emacs-directory)
"The name of Projectile's cache file."
Expand Down Expand Up @@ -3959,7 +3961,8 @@ is chosen."

(defvar projectile-mode-map
(let ((map (make-sparse-keymap)))
(define-key map projectile-keymap-prefix 'projectile-command-map)
(when projectile-keymap-prefix
(define-key map projectile-keymap-prefix 'projectile-command-map))
map)
"Keymap for Projectile mode.")

Expand Down

0 comments on commit 9c6e981

Please sign in to comment.