all repos — nixfiles @ d3981bdfb3ccd4603a1ea7f5d130a3b2e24ec714

System and user configuration, managed by nix and home-manager

Emacs: Fix counsel-switch-to-projectile-buffer

Fallback to `ivy-switch-buffer` if not in a project
Alan Pearce alan@alanpearce.co.uk
Sun, 16 Aug 2015 13:29:45 +0200
commit

d3981bdfb3ccd4603a1ea7f5d130a3b2e24ec714

parent

664e4c099d653fed46c0970328a70fdcaf89e581

1 files changed, 8 insertions(+), 5 deletions(-)

jump to
M tag-emacs/emacs.d/init.orgtag-emacs/emacs.d/init.org
@@ -1209,11 +1209,14 @@ ("C-x b" . counsel-switch-to-projectile-buffer))     :config (progn
               (defun counsel-switch-to-projectile-buffer (arg)
                 "Forward to `projectile-switch-to-buffer'."
-                (ivy-read (format "Switch to buffer [%s]: " (projectile-project-name))
-                          (projectile-project-buffer-names)
-                          :preselect (buffer-name (other-buffer (current-buffer)))
-                          :action #'ivy--switch-buffer-action
-                          :keymap ivy-switch-buffer-map))))
+                (interactive "P")
+                (if (projectile-project-p)
+                    (ivy-read (format "Switch to buffer [%s]: " (projectile-project-name))
+                              (projectile-project-buffer-names)
+                              :preselect (buffer-name (other-buffer (current-buffer)))
+                              :action #'ivy--switch-buffer-action
+                              :keymap ivy-switch-buffer-map)
+                  (call-interactively #'ivy-switch-buffer)))))
 #+END_SRC