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

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

[nongnu] elpa/telephone-line 6016418a5e 2/2: Merge pull request #139 fro


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 6016418a5e 2/2: Merge pull request #139 from swflint/combined-project-and-buffer
Date: Tue, 9 Jan 2024 16:01:07 -0500 (EST)

branch: elpa/telephone-line
commit 6016418a5e1e8e006cc202eff50ff28b594eeca4
Merge: 202f9c94f7 8ebe99796c
Author: Daniel Bordak <daniel.bordak@dbordak.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #139 from swflint/combined-project-and-buffer
    
    Add a combined project/buffer name segment for project.el
---
 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]