[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sesman cf7997e279 035/100: Add sesman-project generic
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sesman cf7997e279 035/100: Add sesman-project generic |
Date: |
Tue, 28 Dec 2021 14:06:00 -0500 (EST) |
branch: elpa/sesman
commit cf7997e279a0af1877a6a809ea7fae500da52cce
Author: Vitalie Spinu <spinuvit@gmail.com>
Commit: Vitalie Spinu <spinuvit@gmail.com>
Add sesman-project generic
---
sesman.el | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/sesman.el b/sesman.el
index b71e9ed197..34dc1b1c91 100644
--- a/sesman.el
+++ b/sesman.el
@@ -40,7 +40,6 @@
;;; Code:
(require 'cl-generic)
-(require 'project)
(require 'seq)
(require 'subr-x)
@@ -152,19 +151,15 @@ Can be either a symbol, or a function returning a
symbol.")
system))))))
(defun sesman--expand-path-maybe (obj)
- (cond
- ((stringp obj) (expand-file-name obj))
- ((and (consp obj) (stringp (cdr obj)))
- (cons (car obj) (expand-file-name (cdr obj))))
- (t obj)))
+ (if (stringp obj)
+ (expand-file-name obj)
+ obj))
;; FIXME: incorporate `sesman-abbreviate-paths'
(defun sesman--abbrev-path-maybe (obj)
- (cond
- ((stringp obj) (abbreviate-file-name obj))
- ((and (consp obj) (stringp (cdr obj)))
- (cons (car obj) (abbreviate-file-name (cdr obj))))
- (t obj)))
+ (if (stringp obj)
+ (abbreviate-file-name obj)
+ obj))
(defun sesman--system ()
(if sesman-system
@@ -422,9 +417,11 @@ By default, calls `sesman-quit-session' and then
(cl-defgeneric sesman-session-info (_system session)
(cdr session))
-(cl-defgeneric sesman-context-types (_system)
- "Return a list of context types understood by SYSTEM."
- '(buffer directory project))
+(cl-defgeneric sesman-project (system)
+ "Retrieve project root for SYSTEM in directory DIR.
+DIR defaults to `default-directory'. Return a string or nil if no project has
+been found."
+ nil)
(cl-defgeneric sesman-more-relevant-p (_system session1 session2)
"Return non-nil if SESSION1 should be sorted before SESSION2.
@@ -433,6 +430,10 @@ provide a more meaningful ordering. If your system objects
are buffers you can
use `sesman-more-recent-p' utility in this method."
(not (string-greaterp (car session1) (car session2))))
+(cl-defgeneric sesman-context-types (_system)
+ "Return a list of context types understood by SYSTEM."
+ '(buffer directory project))
+
;;; System API
@@ -706,7 +707,11 @@ buffers."
default-directory)
(cl-defmethod sesman-context ((_cxt-type (eql project)))
"Return current project."
- (project-current))
+ (or
+ (sesman-project (sesman--system))
+ (progn
+ (require 'project)
+ (car (project-roots (project-current))))))
(cl-defgeneric sesman-relevant-context-p (_cxt-type cxt)
"Non-nil if context CXT is relevant to current context of type CXT-TYPE.")
@@ -720,7 +725,7 @@ buffers."
(cl-defmethod sesman-relevant-context-p ((_cxt-type (eql project)) proj)
"Non-nil if PROJ is the parent or equals the `default-directory'."
(when (and proj default-directory)
- (string-match-p (concat "^" (cdr proj))
+ (string-match-p (concat "^" proj)
(expand-file-name default-directory))))
- [nongnu] elpa/sesman 2b1b624e7a 074/100: Implement friendly session mechanism, (continued)
- [nongnu] elpa/sesman 2b1b624e7a 074/100: Implement friendly session mechanism, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 19151a8b60 065/100: Add colors for marking dir, proj and buf in listings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 1f5b2b2338 075/100: More consistent empty prefix in sesman-info, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 59f4a2442e 077/100: Simplify system API by subsuming sesman-linked/friendly-sessions into sesman-sessions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 4b2507d1ee 076/100: Optimize sesman-current-session, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman edee869c20 096/100: Sesman menu: Add Browser, Move Unlink, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 93123f6cef 093/100: Rename seman-menu-open -> sesman-menu-open, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 966c13812f 088/100: [Fix #14] Rewrite the usage of when-let*, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman b527f7a638 043/100: Make sesman-system permanent local, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 95f8354d1a 041/100: Add sesman-relevant-[link|session]-p functions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman cf7997e279 035/100: Add sesman-project generic,
ELPA Syncer <=
- [nongnu] elpa/sesman 0ea1d3e645 048/100: [Fix #7] Implement WHICH argument in `sesman-restart`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 0e38d4e427 057/100: Remove unnecessary autoloads, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman e4775a2e81 084/100: Remove sesman--expand-path-maybe, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 7bbd02be9e 083/100: Add sesman-follow-symlinks defcustom, ELPA Syncer, 2021/12/28