all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62543: [PATCH] bs support for project.el
@ 2023-03-30 12:27 Philip Kaludercic
  0 siblings, 0 replies; only message in thread
From: Philip Kaludercic @ 2023-03-30 12:27 UTC (permalink / raw)
  To: 62543; +Cc: Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

This is a quick attempt at adding support for project.el to bs.el.  It
works well when bs-show is invoked in a project directory, but if you
open it outside of a project all you get is the current
file/directory -- this doesn't make that much sense to me, but I don't
know what would be better?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Add a bs configuration for projects --]
[-- Type: text/x-patch, Size: 1790 bytes --]

From 5a47093cd41598db016007f1c35894a770b68017 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
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


[-- Attachment #3: Type: text/plain, Size: 23 bytes --]


-- 
Philip Kaludercic

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-30 12:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 12:27 bug#62543: [PATCH] bs support for project.el Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.