[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/telephone-line aa746faab1 149/195: Add doomy filename segm
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/telephone-line aa746faab1 149/195: Add doomy filename segment |
Date: |
Wed, 5 Jan 2022 02:59:41 -0500 (EST) |
branch: elpa/telephone-line
commit aa746faab16a67c2ac6179a5a720184c1952b33f
Author: Daniel Bordak <dbordak@fastmail.fm>
Commit: Daniel Bordak <dbordak@fastmail.fm>
Add doomy filename segment
---
telephone-line-segments.el | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/telephone-line-segments.el b/telephone-line-segments.el
index d7a96b49e5..8750b2e01a 100644
--- a/telephone-line-segments.el
+++ b/telephone-line-segments.el
@@ -56,6 +56,9 @@
mode-line-frame-identification
,(telephone-line-raw mode-line-buffer-identification t)))
+(telephone-line-defsegment* telephone-line-input-info-segment ()
+ '("" mode-line-mule-info mode-line-modified mode-line-client
mode-line-remote))
+
(telephone-line-defsegment* telephone-line-atom-eol-segment (&optional hide-lf)
"Displays the eol style of the buffer the same way Atom does.
Set HIDE-LF to display nothing for unix endings, as it can be an assumed
default.
@@ -139,6 +142,45 @@ mouse-3: Toggle minor modes"
(interactive)
(projectile-switch-project))))))
+(defun telephone-line--truncate-dir (dir)
+ "Truncate DIR, respecting word boundaries."
+ (if (string= dir "~")
+ dir
+ (string-join
+ (mapcar (lambda (x) (seq-take x 1))
+ (split-string dir "[^[:word:]]" t)))))
+
+(defun telephone-line--truncate-path (path truncate-until)
+ "Truncate PATH. TRUNCATE-UNTIL indicates how far to truncate; -1 means leave
the last element, 0 means truncate all, etc."
+ (let* ((dirs (split-string path "/"))
+ (take (+ truncate-until (length dirs)))
+ (trunc (seq-take dirs take))
+ (leave (seq-drop dirs take)))
+ (string-join (append (mapcar #'telephone-line--truncate-dir trunc) leave)
"/")))
+
+(telephone-line-defsegment* telephone-line-projectile-buffer-segment
(&optional truncate-until show-project-path)
+ "Combined projectile project segment and filename segment 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 (and (buffer-file-name)
+ (fboundp 'projectile-project-root)
+ (fboundp 'projectile-project-name))
+ (list ""
+ (if show-project-path
+ (propertize
+ (telephone-line--truncate-path
+ (abbreviate-file-name (file-name-directory
(directory-file-name (projectile-project-root)))) show-project-path)
+ 'face 'telephone-line-unimportant
+ 'help-echo (buffer-file-name)))
+ (funcall (telephone-line-projectile-segment) face)
+ (propertize
+ (concat "/"
+ (if-let ((rel-path (file-relative-name (buffer-file-name)
(projectile-project-root))))
+ (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 ()
(when (bound-and-true-p evil-mode)
(let ((tag (cond
- [nongnu] elpa/telephone-line 45d97b4021 127/195: Oops, that was markdown format., (continued)
- [nongnu] elpa/telephone-line 45d97b4021 127/195: Oops, that was markdown format., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 9fe198d82c 008/195: Remove autoloads carried over from names, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line d486eb3398 055/195: More indentation fixes, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line dd5a939edd 035/195: Fix error in erc segment when erc is not loaded, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 5638edc4fa 032/195: Fix title typo, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line b58e3d1e43 030/195: Probably improve Unicode separators., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 54850e413d 105/195: Switch to create-trig-axis all the timeNow that the algorithm works properly, we can assume a trig axis -- no rounding errors means it'll still be clear for everything else., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line a5c7225dad 088/195: Link to examples in readme, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 0b92b759f7 102/195: Added narrow segment, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 4adfbf02bb 092/195: Shorten readme, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line aa746faab1 149/195: Add doomy filename segment,
ELPA Syncer <=
- [nongnu] elpa/telephone-line 743614f372 128/195: Force nil's width to 0; fixes clipping issue., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 1cc28a7811 146/195: Forgot the else clause, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line dd1afefa00 152/195: Add telephone-line-error and warning faces., ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line dde8805867 142/195: Remove brackets from projectile segment, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line b3eaf4b825 134/195: Use center-lhs and center-rhs instead of keyword, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line f7014a0cc5 004/195: Add Readme, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 324da1bbb6 111/195: Add ryo-modal support, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 64a1f079f5 090/195: Update copyrights, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line c9aca6ce03 143/195: Add flycheck segment, ELPA Syncer, 2022/01/05
- [nongnu] elpa/telephone-line 6e1ecf51a2 147/195: Add doom/atom encoding segments, ELPA Syncer, 2022/01/05