emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/sesman 665721c52f 066/100: Move context faces to sesman.el


From: ELPA Syncer
Subject: [nongnu] elpa/sesman 665721c52f 066/100: Move context faces to sesman.el and use for info display
Date: Tue, 28 Dec 2021 14:06:03 -0500 (EST)

branch: elpa/sesman
commit 665721c52f205b5b8e26d8f26109d0c026c7477b
Author: Vitalie Spinu <spinuvit@gmail.com>
Commit: Vitalie Spinu <spinuvit@gmail.com>

    Move context faces to sesman.el and use for info display
---
 sesman-browser.el | 41 +++++++----------------------------------
 sesman.el         | 41 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/sesman-browser.el b/sesman-browser.el
index 5e2e1898f6..efd084f8aa 100644
--- a/sesman-browser.el
+++ b/sesman-browser.el
@@ -50,26 +50,6 @@
   "Face used to highlight currently selected object."
   :group 'sesman-browser)
 
-(defface sesman-browser-project-face
-  '((default (:inherit font-lock-comment-face)))
-  "Face used to mark projects."
-  :group 'sesman-browser)
-
-(defface sesman-browser-directory-face
-  '((default (:inherit font-lock-constant-face)))
-  "Face used to mark directories."
-  :group 'sesman-browser)
-
-(defface sesman-browser-buffer-face
-  '((default (:inherit font-lock-keyword-face)))
-  "Face used to mark buffers."
-  :group 'sesman-browser)
-
-(defface sesman-browser-project-face
-  '((default (:inherit font-lock-comment-face)))
-  "Face used to mark projects."
-  :group 'sesman-browser)
-
 (defvar-local sesman-browser--sort-types '(name relevance))
 (defcustom sesman-browser-sort-type 'name
   "Default sorting type in sesman browser buffers.
@@ -392,23 +372,13 @@ on a session object."
     (let ((link-groups (sesman-grouped-links system ses))
           (vert-stop))
       (dolist (grp link-groups)
-        (let* ((type (car grp))
-               (face (intern (format "sesman-browser-%s-face" type)))
-               (short-type (propertize (or (plist-get sesman--cxt-abbrevs type)
-                                           (symbol-value type))
-                                       'face (list (if (facep face)
-                                                       face
-                                                     
'font-lock-function-name-face)
-                                                   'sesman-browser-button))))
+        (let* ((type (car grp)))
           (dolist (link (cdr grp))
             (when (> (current-column) fill-column)
               (insert "\n" (format head-template " "))
               (setq vert-stop nil))
-            (let ((link-spec (propertize (format "(%s)"
-                                                 (sesman--abbrev-path-maybe
-                                                  (sesman--lnk-value link)))
-                                         'face 'sesman-browser-button)))
-              (insert (propertize (concat short-type link-spec)
+            (let ((val (sesman--abbrev-path-maybe (sesman--lnk-value link))))
+              (insert (propertize (sesman--format-context type val 
'sesman-browser-button)
                                   :sesman-stop (car link)
                                   :sesman-vertical-stop (unless vert-stop 
(setq vert-stop t))
                                   :sesman-link link
@@ -475,7 +445,10 @@ See `sesman-browser-mode' for more details."
                         (_ (error "Invalid `sesman-browser-sort-type'"))))
             (i 0))
         (erase-buffer)
-        (insert (format "\n %s Sessions:\n\n" system))
+        (insert "\n ")
+        (insert (propertize (format "%s Sessions:" system)
+                            'face '(bold font-lock-keyword-face)))
+        (insert "\n\n")
         (dolist (ses sessions)
           (setq i (1+ i))
           (sesman-browser--insert-session system ses i))
diff --git a/sesman.el b/sesman.el
index f72f26c4b8..57d01845f9 100644
--- a/sesman.el
+++ b/sesman.el
@@ -49,6 +49,21 @@
   :group 'tools
   :link '(url-link :tag "GitHub" "https://github.com/vspinu/sesman";))
 
+(defface sesman-project-face
+  '((default (:inherit font-lock-doc-face)))
+  "Face used to mark projects."
+  :group 'sesman)
+
+(defface sesman-directory-face
+  '((default (:inherit font-lock-type-face)))
+  "Face used to mark directories."
+  :group 'sesman)
+
+(defface sesman-buffer-face
+  '((default (:inherit font-lock-keyword-face)))
+  "Face used to mark buffers."
+  :group 'sesman)
+
 ;; (defcustom sesman-disambiguate-by-relevance t
 ;;   "If t choose most relevant session in ambiguous situations, otherwise ask.
 ;; Ambiguity arises when multiple sessions are associated with current 
context.  By
@@ -228,7 +243,7 @@ If SORT is non-nil, sort in relevance order."
           (or prefix "")
           (propertize (car ses) 'face 'bold)
           (propertize (sesman--format-session-objects system ses ", ") 'face 
'italic)
-          (propertize (sesman-grouped-links system ses t t) 'face 'italic)))
+          (sesman-grouped-links system ses t t)))
 
 (defun sesman--format-link (link)
   (let* ((system (sesman--lnk-system-name link))
@@ -611,9 +626,22 @@ CXT-TYPES is as in `sesman-linked-sessions'."
       (user-error "No linked %s sessions" system)))
 
 (defvar sesman--cxt-abbrevs '(buffer "buf" project "proj" directory "dir"))
+(defun sesman--format-context (cxt-type cxt-val extra-face)
+  (let* ((face (intern (format "sesman-%s-face" cxt-type)))
+         (short-type (propertize (or (plist-get sesman--cxt-abbrevs cxt-type)
+                                     (symbol-value cxt-type))
+                                 'face (list (if (facep face)
+                                                 face
+                                               'font-lock-function-name-face)
+                                             extra-face))))
+    (concat short-type
+            (propertize (format "(%s)" cxt-val)
+                        'face extra-face))))
+
 (defun sesman-grouped-links (system session &optional current-first as-string)
   "Retrieve all links for SYSTEM's SESSION from the global 
`sesman-links-alist'.
 Return an alist of the form
+
    ((buffer buffers..)
     (directory directories...)
     (project projects...)).
@@ -645,17 +673,16 @@ AS-STRING is non-nil, return an equivalent string 
representation."
           (out-rel (delq nil (mapcar (lambda (el) (and (cdr el) el)) 
out-rel))))
       (if as-string
           (let ((fmt-fn (lambda (typed-links)
-                          (let* ((type (car typed-links))
-                                 (short-type (or (plist-get 
sesman--cxt-abbrevs type) type)))
+                          (let* ((type (car typed-links)))
                             (mapconcat (lambda (lnk)
-                                         (format "%s(%s)" short-type
-                                                 (sesman--abbrev-path-maybe
-                                                  (sesman--lnk-value lnk))))
+                                         (let ((val (sesman--abbrev-path-maybe
+                                                     (sesman--lnk-value lnk))))
+                                           (sesman--format-context type val 
'italic)))
                                        (cdr typed-links)
                                        ", ")))))
             (if out-rel
                 (concat (mapconcat fmt-fn out-rel ", ")
-                        (when out " | ")
+                        (when out " ")
                         (mapconcat fmt-fn out ", "))
               (mapconcat fmt-fn out ", ")))
         (if current-first



reply via email to

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