From 5a47093cd41598db016007f1c35894a770b68017 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 30 Mar 2023 14:24:10 +0200 Subject: [PATCH] Add a bs configuration for projects * lisp/bs.el (bs-configurations): Add "project" configuration. (bs-visits-current-project): Add a predicate function for 'bs-configurations'. --- lisp/bs.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisp/bs.el b/lisp/bs.el index 70868591196..65dd4d10431 100644 --- a/lisp/bs.el +++ b/lisp/bs.el @@ -126,6 +126,8 @@ ;; Globals for customization ;; ---------------------------------------------------------------------- +(require 'project) + (defgroup bs nil "Buffer Selection: Maintaining buffers by buffer menu." :version "21.1" @@ -255,6 +257,7 @@ bs-header-lines-length (defcustom bs-configurations '(("all" nil nil nil nil nil) ("files" nil nil nil bs-visits-non-file bs-sort-buffer-interns-are-last) + ("project" nil nil nil bs-visits-current-project bs-sort-buffer-interns-are-last) ("files-and-scratch" "^\\*scratch\\*$" nil nil bs-visits-non-file bs-sort-buffer-interns-are-last) ("all-intern-last" nil nil nil nil bs-sort-buffer-interns-are-last)) @@ -1039,6 +1042,12 @@ bs-visits-non-file A value of nil means BUFFER belongs to a file." (not (buffer-file-name buffer))) +(defun bs-visits-current-project (buffer) + "Return whether BUFFER is in the current project." + (not (and-let* ((project (project-current)) + (file (buffer-file-name buffer))) + (file-in-directory-p file (project-root project))))) + (defun bs-sort-buffer-interns-are-last (_b1 b2) "Function for sorting internal buffers at the end of all buffers." (string-match-p "^\\*" (buffer-name b2))) -- 2.30.2