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

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

[nongnu] elpa/telephone-line 8ebe99796c 1/2: Add a combined project/buff


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 8ebe99796c 1/2: Add a combined project/buffer name segment for project.el
Date: Tue, 9 Jan 2024 16:01:07 -0500 (EST)

branch: elpa/telephone-line
commit 8ebe99796c6af84ac4c496323d61215c8e60d2f2
Author: Samuel W. Flint <swflint@flintfam.org>
Commit: Samuel W. Flint <swflint@flintfam.org>

    Add a combined project/buffer name segment for project.el
    
    This improves support for `project.el` users
---
 telephone-line-segments.el | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/telephone-line-segments.el b/telephone-line-segments.el
index 35eefbe221..25e96aa285 100644
--- a/telephone-line-segments.el
+++ b/telephone-line-segments.el
@@ -269,6 +269,35 @@ Inspired by doom-modeline."
              'help-echo (buffer-file-name)))
     (telephone-line-raw mode-line-buffer-identification t)))
 
+(telephone-line-defsegment* telephone-line-project-buffer-segment (&optional 
truncate-until show-project-path)
+  "Combined project.el project and filename with abbreviated filepath.
+
+TRUNCATE-UNTIL sets when to stop truncating; -1 for all but
+one (i.e. filename), 0 for everything, etc.  If SHOW-PROJECT-PATH
+is non-nil, shows the abbreviated path leading up to the project
+dir. Value works the same as TRUNCATE-UNTIL Inspired by
+doom-modeline."
+  (if-let ((buffer-file (buffer-file-name))
+           (project (project-current))
+           (project-directory (project-root project)))
+      (list ""
+            (if show-project-path
+                (propertize
+                 (telephone-line--truncate-path
+                  (abbreviate-file-name
+                   (file-name-directory (directory-file-name 
project-directory)))
+                  show-project-path)
+                 'face 'telephone-line-unimportant
+                 'help-echo buffer-file))
+            (funcall (telephone-line-project-segment) face)
+            (propertize
+             (concat "/"
+                     (if-let ((rel-path (file-relative-name (file-truename 
buffer-file)
+                                                            
project-directory)))
+                         (telephone-line--truncate-path rel-path (or 
truncate-until -1))))
+             'help-echo (buffer-file-name)))
+    (telephone-line-raw mode-line-buffer-identification t)))
+
 (telephone-line-defsegment* telephone-line-evil-tag-segment ()
   "Displays current evil mode.
 Configure the face group telephone-line-evil to change the colors per-mode."



reply via email to

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