all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: 62543@debbugs.gnu.org
Cc: Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#62543: [PATCH] bs support for project.el
Date: Thu, 30 Mar 2023 12:27:33 +0000	[thread overview]
Message-ID: <87355mh1ai.fsf@posteo.net> (raw)

[-- 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

                 reply	other threads:[~2023-03-30 12:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87355mh1ai.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=62543@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.