Closed suyashbire1 closed 6 years ago
Oh hey, sorry, I missed this: You can do this, it's just not in any of the default segments. A few other users have this sorta setup, if you want I could probably throw something together that does this (or find someone else's, lol).
One thing to keep in mind, though, is that all-the-icons can have some trouble with matching the vertical height of your font, so you might want to manually set telephone-line-height
to a higher number to prevent... weird stuff.
A few other users have this sorta setup, if you want I could probably throw something together that does this (or find someone else's, lol).
I could not find anyone else's setup using icons. It would be great to have links to these setups in the readme. If you could put something together, that would be awesome! Thank you so much.
One thing to keep in mind, though, is that all-the-icons can have some trouble with matching the vertical height of your font, so you might want to manually set telephone-line-height to a higher number to prevent... weird stuff.
I would prefer a simple unicode symbol instead of any icon package to keep everything light and simple. Is there a simple unicode for git or version-control? I couldn't find anything here: https://unicode-table.com/en/
There are no git/version control symbols in standard unicode; the powerline symbols you're probably familiar with are written to an explicitly unused area. (if you're using a powerline font, though, you can just use that symbol without a package or anything).
As for an example, there's one in issue #22 that I just confirmed to probably work. There have been some package changes since then, so here's a slightly updated version that I used successfully:
(telephone-line-defsegment* shackra-vc-info ()
(when vc-mode
(cond ((string-match "Git[:-]" vc-mode)
(let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
(concat
(propertize (format " %s" (all-the-icons-alltheicon "git")) 'face `(:foreground "orange" :height 1.3) 'display '(raise -0.1))
" · "
(propertize (format "%s" (all-the-icons-octicon "git-branch"))
'face `(:foreground "yellow" :height 1.3 :family ,(all-the-icons-octicon-family))
'display '(raise -0.1))
(propertize (format " %s" branch) 'face `(:foreground "yellow" :height 0.9)))))
((string-match "SVN-" vc-mode)
(let ((revision (cadr (split-string vc-mode "-"))))
(concat
(propertize (format " %s" (all-the-icons-faicon "cloud")) 'face `(:height 1.3) 'display '(raise -0.1))
(propertize (format " · %s" revision) 'face `(:height 0.9)))))
(t (format "%s" vc-mode)))))
it looks so nice, in fact, that i think i need to consider adding it to the package... although i don't really like adding a dependency on all-the-icons
since that requires particular fonts to be installed IIRC?
@dbordak Hi, Ive settled down on telephone line for my emacs after trying many alternatives. I would like the icons thing to work as well. I tried copy pasting your code snippet above, but that doesnt seem to have an effect on the telephone line shown at the bottom. I dont see any icons.
Help?
@ShashankaNataraj that snippet requires all-the-icons
to be installed and set up (IIRC that package has some extra setup instructions?). You have more options if you're using a powerline font, again.
@dbordak Ive installed all-the-icons already and have followed the instructions to install the patched fonts as well. Anything else Im missing?
EDIT: BTW, if I M-x "all-the-icons" -> "insert-icon" -> "alarm" in any buffer, Im able to get the respective icon in the buffer as in below screenshot. I think this means the respective font is installed, no?
Oh, I'm sorry, you also need to add the segment into your config. You should read over the readme and configuration.org, but here's a config that'll just add that in place of the built-in one:
(setq telephone-line-lhs
'((evil . (telephone-line-evil-tag-segment))
(accent . (shackra-vc-info
telephone-line-erc-modified-channels-segment
telephone-line-process-segment))
(nil . (telephone-line-projectile-segment
telephone-line-buffer-segment))))
You'll probably also want to play around with higher values for telephone-line-height
-- normally, the height is however high your font requires, but the icons in all-the-icons
aren't the same height so you'll need to set it manually (I haven't figured out any way of doing this automatically, yet). That's in pixels, so the right number will vary depending upon your screen resolution (as well as font size, obviously). I set mine to 40
, personally.
Thanks for that! Im now able to get the icon in my telephone line!
I will try to tweak this more!
It is possible to find all the ligatures that your font supports by running $xfd -fa "Font Name"
. Any ligature can be then inserted in emacs by C-x 8 RET
and entering the ligature's hex code. I was able to create vim-powerline like setup using Source Code Pro and powerline-fonts.
LHS:
RHS:
The hex code for git ligature was 00e0a0 and for LN ligature was 00e0a1.
(telephone-line-defsegment* my-vc-info ()
(when vc-mode
(cond
((string-match "Git[:-]" vc-mode)
(let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
(concat (propertize (format "")
'face `(:foreground "yellow" :height 1.3)
'display '(raise -0.1))
(propertize (format " %s" branch)
'face `(:foreground "yellow" :height 0.9)))))
((string-match "SVN-" vc-mode)
(let ((revision (cadr (split-string vc-mode "-"))))
(concat (propertize (format "")
'face `(:height 1.3)
'display '(raise -0.1))
(propertize (format " %s" revision)
'face `(:height 0.9)))))
(t (format "%s" vc-mode)))))
(telephone-line-defsegment* my-airline-position-segment (&optional lines columns)
(let* ((l (number-to-string (if lines lines 1)))
(c (number-to-string (if columns columns 2))))
(if (eq major-mode 'paradox-menu-mode)
(telephone-line-raw mode-line-front-space t)
`((-3 "%p") ,(concat " " "%" l "l:%" c "c")))))
Thank you for your help @dbordak!
@suyashbire1 you can see the separators there aren't quite filling the entire height of the modeline -- there's a gap at the bottom. You can fix that with telephone-line-height
, or with scaling factors as you used in that snippet.
@dbordak Thank you for the tips. Yes, I just got rid of all the scaling factors. I realized I did not need them as I was using unicode symbols provided by the font. The code looks cleaner too.
(telephone-line-defsegment* my-vc-info ()
(when vc-mode
(cond
((string-match "Git[:-]" vc-mode)
(let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
(concat "" (format " %s" branch))))
((string-match "SVN-" vc-mode)
(let ((revision (cadr (split-string vc-mode "-"))))
(concat "" (format "SVN-%s" revision))))
(t (format "%s" vc-mode)))))
This segment that I posted a couple of posts ago has stopped working after the latest update. It is virtually the same as telephone-line-airline-position-segment
, which still works. @dbordak please help.
(telephone-line-defsegment* my-airline-position-segment (&optional lines columns)
(let* ((l (number-to-string (if lines lines 1)))
(c (number-to-string (if columns columns 2))))
(if (eq major-mode 'paradox-menu-mode)
(telephone-line-raw mode-line-front-space t)
`((-3 "%p") ,(concat " " "%" l "l:%" c "c")))))
@suyashbire1 That config works just fine for me. Here's exactly what I used:
(use-package telephone-line
:config
(telephone-line-defsegment* my-airline-position-segment (&optional lines columns)
(let* ((l (number-to-string (if lines lines 1)))
(c (number-to-string (if columns columns 2))))
(if (eq major-mode 'paradox-menu-mode)
(telephone-line-raw mode-line-front-space t)
`((-3 "%p") ,(concat " " "%" l "l:%" c "c")))))
(setq telephone-line-rhs
'((nil . (telephone-line-flycheck-segment
telephone-line-misc-info-segment))
(accent . (telephone-line-major-mode-segment))
(evil . (my-airline-position-segment))))
(telephone-line-mode 1))
In what way has it stopped working? Could it just be your font?
Here's the RHS of the mode-line. As you can see, that segment just does not show up. It's not a problem with my font because the my-vcinfo segment appears correctly.
I'm on emacs 26.1. Here's a minimal init file to reproduce this.
;;; init.el --- Initialization file for Emacs
;;; Commentary: Emacs Startup File --- initialization for Emacs;;; Package --- Summary
;;; Code:
(eval-and-compile
(setq load-prefer-newer t
package-user-dir "~/.emacs.d/elpa"
package--init-file-ensured t
package-enable-at-startup nil)
(unless (file-directory-p package-user-dir)
(make-directory package-user-dir t))
(setq load-path (append load-path (directory-files package-user-dir t "^[^.]" t))))
(eval-when-compile
(require 'package)
;; tells emacs not to load any packages before starting up
;; the following lines tell emacs where on the internet to look up
;; for new packages.
(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("repo-org" . "https://orgmode.org/elpa/")))
;; (package-initialize)
(unless package--initialized (package-initialize t))
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package) ; unless it is already installed
(package-refresh-contents) ; updage packages archive
(package-install 'use-package)) ; and install the most recent version of use-package
(require 'use-package)
(setq use-package-always-ensure t))
(use-package evil
:demand t
:config
(evil-mode 1)
(evil-set-initial-state 'shell-mode 'normal)
(evil-set-initial-state 'doc-view-mode 'normal)
(setq doc-view-continuous t))
(use-package telephone-line
:demand t
:config
(setq telephone-line-primary-left-separator 'telephone-line-abs-left
telephone-line-primary-right-separator 'telephone-line-abs-right)
(telephone-line-defsegment my-vc-info ()
(when vc-mode
(cond
((string-match "Git[:-]" vc-mode)
(let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
(concat "" (format " %s" branch))))
((string-match "SVN-" vc-mode)
(let ((revision (cadr (split-string vc-mode "-"))))
(concat "" (format "SVN-%s" revision))))
(t (format "%s" vc-mode)))))
(telephone-line-defsegment* my-airline-position-segment (&optional lines columns)
(let* ((l (number-to-string (if lines lines 1)))
(c (number-to-string (if columns columns 2))))
(if (eq major-mode 'paradox-menu-mode)
(telephone-line-raw mode-line-front-space t)
`((-3 "%p") ,(concat " " "%" l "l:%" c "c")))))
(setq telephone-line-rhs
'((nil . (telephone-line-flycheck-segment
telephone-line-misc-info-segment))
(accent . (telephone-line-major-mode-segment))
(evil . (my-airline-position-segment))))
(setq telephone-line-lhs
'((evil . (telephone-line-evil-tag-segment))
(accent . (my-vc-info
telephone-line-process-segment))
(nil . (telephone-line-buffer-segment
telephone-line-projectile-segment))))
(telephone-line-mode 1))
(provide 'init)
;;; init ends here
That config works fine for me. Check your message buffer?
Here's the error in message buffer.
Error during redisplay: (eval (telephone-line-add-subseparators (quote ((lambda (face) (let* ((l (number-to-string (if lines lines 1))) (c (number-to-string (if columns columns 2)))) (if (eq major-mode (quote paradox-menu-mode)) (telephone-line-raw mode-line-front-space t) (list (quote (-3 "%p")) (concat " " "%" l "l:%" c "c"))))))) telephone-line-abs-hollow-right (quote evil))) signaled (void-variable lines) [2 times]
Apparently lines is void. Why is this happening?
Enabling lexical binding in the init file fixed this. Thank you for your help @dbordak.
Going to close this for now; feel free to reopen if either of you need more help.
Also, I'm probably going to add some kind of variant on these configs as a default; I believe it should sorta be assumed that a good portion of my userbase is already using powerline fonts ;)
@dbordak Or, having some snippets of commonly used patterns in the readme or on the wiki would also help!
@dbordak Maybe it's possible to move all-the-icons related code to another package?
I want to replace the "git" in telephone-line's vc segment with git's icon like in vim's powerline (shown below). Is it possible to use icons (e.g. from all-the-icons) in telephone-line? Sorry, it wasn't clear to me after reading the docs.
telephone-line:
vim-powerline: