]> git.eshelyaron.com Git - emacs.git/commitdiff
New command: project-switch-to-buffer
authorTheodor Thornhill <theo@thornhill.no>
Wed, 17 Jun 2020 23:09:41 +0000 (02:09 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 17 Jun 2020 23:09:41 +0000 (02:09 +0300)
* lisp/progmodes/project.el (project-switch-to-buffer): New command.

lisp/progmodes/project.el

index 14aafdf28996a8d0360e8bf03d4f4b0c1f6df17f..d8f56acedf379907ef82f672c82b01eee723e1c0 100644 (file)
@@ -768,6 +768,19 @@ Arguments the same as in `compile'."
          (default-directory (project-root pr)))
     (compile command comint)))
 
+;;;###autoload
+(defun project-switch-to-buffer ()
+  "Switch to a buffer in the current project."
+  (interactive)
+  (let ((root (project-root (project-current t))))
+    (switch-to-buffer
+     (read-buffer
+      "Switch to buffer: " nil t
+      (lambda (buffer)
+        ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
+        (when-let ((file (buffer-file-name (cdr buffer))))
+          (file-in-directory-p file root)))))))
+
 \f
 ;;; Project list