dbordak / telephone-line

A new implementation of Powerline for Emacs
GNU General Public License v3.0
556 stars 51 forks source link

Add support for project.el ? #124

Closed mrunhap closed 2 years ago

mrunhap commented 2 years ago

I see there is a projectile segment but didn't have project.el support.

mrunhap commented 2 years ago

I'm not good at emacs lisp, but this works for me, maybe I should send a PR

(defun +project-name ()
  (file-name-nondirectory (directory-file-name (project-root (project-current)))))

(telephone-line-defsegment my--project-segment ()
  (propertize (+project-name)
              'face 'telephone-line-projectile
              'display '(raise 0.0)
              'help-echo "Switch project"
              'local-map (make-mode-line-mouse-map
                          'mouse-1 (lambda ()
                                     (interactive)
                                     (project-switch-project)))))

(telephone-line-defsegment* my-project-buffer-segment ()
  ""
  (if (and (buffer-file-name)
           (project-current))
      (list ""
            (funcall (my--project-segment) 'telephone-line-unimportant)
            (propertize
             (if-let ((rel-path (file-relative-name (file-truename (buffer-file-name))
                                                    (+project-name))))
                 (telephone-line--truncate-path rel-path -1)) ;; TODO need my own version
             'help-echo (buffer-file-name)))
    (telephone-line-raw mode-line-buffer-identification t)))
trev-dev commented 2 years ago

Maybe you should! Thanks for sharing :)

trev-dev commented 2 years ago

I see there is a projectile segment but didn't have project.el support.

I'm not good at emacs lisp, but this works for me, maybe I should send a PR

I used your example as the baseline for my project.el segment, which I like quite a lot. Have you submitted your PR? If not, would you mind if I went ahead and submitted mine?

mrunhap commented 2 years ago

I see there is a projectile segment but didn't have project.el support.

I'm not good at emacs lisp, but this works for me, maybe I should send a PR

I used your example as the baseline for my project.el segment, which I like quite a lot. Have you submitted your PR? If not, would you mind if I went ahead and submitted mine?

Yes it's ok, just send your PR :)

trev-dev commented 2 years ago

https://github.com/dbordak/telephone-line/pull/127 Here it is.