Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

bbatsov/projectile/#279 #280

Closed
wants to merge 6 commits into from

2 participants

@dhaley

I am using the below functions to switch to the most recently selected buffer other than the current one for projectile buffers.

It would be great to see these added to projectile itself. Let me know what improvements you'd like to see to get this in.

projectile.el
@@ -639,6 +639,22 @@ Operates on filenames relative to the project root."
"Switch to buffer: "
(projectile-project-buffer-names))))
+ (defun projectile-project-buffers-other-buffer () "\
@bbatsov Owner
bbatsov added a note

The docstring should not start here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
projectile.el
@@ -639,6 +639,22 @@ Operates on filenames relative to the project root."
"Switch to buffer: "
(projectile-project-buffer-names))))
+ (defun projectile-project-buffers-other-buffer () "\
+Switch to the most recently selected projectile buffer other than the current one.
+Only buffers not visible in windows are returned."
+ (interactive)
+ (switch-to-buffer (car(projectile-project-buffers-non-visible))) nil t)
@bbatsov Owner
bbatsov added a note

There should a space after car.

@bbatsov Owner
bbatsov added a note

This definition is not correctly indented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
projectile.el
@@ -639,6 +639,22 @@ Operates on filenames relative to the project root."
"Switch to buffer: "
(projectile-project-buffer-names))))
+ (defun projectile-project-buffers-other-buffer () "\
+Switch to the most recently selected projectile buffer other than the current one.
+Only buffers not visible in windows are returned."
+ (interactive)
+ (switch-to-buffer (car(projectile-project-buffers-non-visible))) nil t)
+
+ (defun projectile-project-buffers-non-visible ()
@bbatsov Owner
bbatsov added a note

This function definition is not correctly indented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
projectile.el
@@ -639,6 +639,22 @@ Operates on filenames relative to the project root."
"Switch to buffer: "
(projectile-project-buffer-names))))
+ (defun projectile-project-buffers-other-buffer () "\
+Switch to the most recently selected projectile buffer other than the current one.
+Only buffers not visible in windows are returned."
+ (interactive)
+ (switch-to-buffer (car(projectile-project-buffers-non-visible))) nil t)
+
+ (defun projectile-project-buffers-non-visible ()
+ "Get a list of non visible project buffers."
+ (let ((project-root (projectile-project-root)))
+ (-filter (lambda (buffer)
+ (and
+ (projectile-project-buffer-p buffer project-root)
+ (not (get-buffer-window buffer 'visible))))
+ (buffer-list)
@bbatsov Owner
bbatsov added a note

All closing parens should be on the same line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bbatsov
Owner

Nice idea. I've mentioned a few stylistic problems with the code you'll have to fix. We'll also need a hotkey for this + an entry in the changelog and the readme.

@dhaley

OK, let me know if you see any more changes that should be made.

@bbatsov bbatsov closed this
@bbatsov
Owner

Rebased, squashed, cleaned-up and merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2014
  1. bbatsov/projectile/#279

    Damon Haley authored
Commits on Mar 7, 2014
  1. bbatsov/projectile#279 added projectile-project-buffers-other-buffer …

    Damon Haley authored
    …to changelog.
  2. bbatsov/projectile#279 added projectile-project-buffers-other-buffer …

    Damon Haley authored
    …to README.md.
  3. bbatsov/projectile#279 fixed formatting issues with projectile-projec…

    Damon Haley authored
    …t-buffers-other-buffer.
  4. bbatsov/projectile#279 removed projectile-commander-method for projec…

    Damon Haley authored
    …tile-project-buffers-other-buffer.
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +3 −0  CHANGELOG.md
  2. +1 −0  README.md
  3. +16 −1 projectile.el
View
3  CHANGELOG.md
@@ -4,6 +4,9 @@
### New features
+* Added new interacive function `projectile-project-buffers-other-buffer`
+ which runs new `projectile-project-buffers-non-visible` function, the former
+ is bound to C-c p ESC.
* New variable `projectile-enable-idle-timer` turns on an idle timer
which runs the hook `projectile-idle-timer-hook` every
`projectile-idle-timer-seconds` seconds when non-nil.
View
1  README.md
@@ -285,6 +285,7 @@ Keybinding | Description
<kbd>C-c p z</kbd> | Adds the currently visited file to the cache.
<kbd>C-c p s</kbd> | Display a list of known projects you can switch to.
<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.
If you ever forget any of Projectile's keybindings just do a:
View
17 projectile.el
@@ -639,6 +639,21 @@ Operates on filenames relative to the project root."
"Switch to buffer: "
(projectile-project-buffer-names))))
+ (defun projectile-project-buffers-other-buffer ()
+ "Switch to the most recently selected projectile buffer other than the
+current one. Only buffers not visible in windows are returned."
+ (interactive)
+ (switch-to-buffer (car (projectile-project-buffers-non-visible))) nil t)
+
+ (defun projectile-project-buffers-non-visible ()
+ "Get a list of non visible project buffers."
+ (let ((project-root (projectile-project-root)))
+ (-filter (lambda (buffer)
+ (and
+ (projectile-project-buffer-p buffer project-root)
+ (not (get-buffer-window buffer 'visible))))
+ (buffer-list))))
+
(defun projectile-multi-occur ()
"Do a `multi-occur' in the project's buffers."
(interactive)
@@ -1530,7 +1545,6 @@ is chosen."
(def-projectile-commander-method ?e
"Find recently visited file in project."
(projectile-recentf))
-
;;; Minor mode
(defvar projectile-mode-map
@@ -1562,6 +1576,7 @@ is chosen."
(define-key prefix-map (kbd "T") 'projectile-find-test-file)
(define-key prefix-map (kbd "v") 'projectile-vc)
(define-key prefix-map (kbd "z") 'projectile-cache-current-file)
+ (define-key prefix-map (kbd "ESC") 'projectile-project-buffers-other-buffer)
(define-key map projectile-keymap-prefix prefix-map))
map)
"Keymap for Projectile mode.")
Something went wrong with that request. Please try again.