emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master eb3b03c 2/3: New command: project-switch-to-buffer


From: Dmitry Gutov
Subject: master eb3b03c 2/3: New command: project-switch-to-buffer
Date: Wed, 17 Jun 2020 19:12:14 -0400 (EDT)

branch: master
commit eb3b03c1c686e20c55eeaa21652b318251e16458
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    New command: project-switch-to-buffer
    
    * lisp/progmodes/project.el (project-switch-to-buffer): New command.
---
 lisp/progmodes/project.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 14aafdf..d8f56ac 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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)))))))
+
 
 ;;; Project list
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]