Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom prodigy columns #121

Closed
wants to merge 1 commit into from
Closed

custom prodigy columns #121

wants to merge 1 commit into from

Conversation

FrancescElies
Copy link
Collaborator

Context

Problem: Sometimes I need to checkout different branches for certain processes
running under prodigy. In that situation I would like to see which branches I
checked out.

Description

This pull request adds a new column that could be activated via defcustom.

Todos

  • Add prodigy-list-columns joining prodigy column functions and formats
  • Add prodigy-branch-col
    • Shows current branch
    • If any file is modified show pencil symbol

Would you eventually interested in something like this?
At the moment looks as follows

screen shot 2018-03-16 at 20 50 35

@Fuco1
Copy link
Collaborator

Fuco1 commented Mar 16, 2018

I think it's pretty neat idea, I often run multiple versions of the same service as well. But for me a docker tag would be more useful :D

@rejeep
Copy link
Owner

rejeep commented Mar 16, 2018

Would be great if this could be done as a plugin instead. Git is too specific.

@FrancescElies
Copy link
Collaborator Author

I think it's pretty neat idea, I often run multiple versions of the same service as well. But for me a docker tag would be more useful :D

For running docker containers I use docker.el, how do you run them in prodigy, could you link me to an example? :)

@FrancescElies
Copy link
Collaborator Author

Would be great if this could be done as a plugin instead. Git is too specific.

As a plugin, do you mean, that the user could configure it's own columns via defcustom? Basically getting prodigy-branch-col related code out of the repo. Then adding that code to a custom column via defcustom?

@Fuco1
Copy link
Collaborator

Fuco1 commented Mar 16, 2018

@FrancescElies docker.el is not very great with compose so I use prodigy to start compose stacks. I also use ssh serverXYZ docker logs -f container to run a "service" that just prints the logs so that I can quickly jump to that in Emacs. Seeing what image the container is using would be neat there.

I think this is "pluggable" enough but maybe rename "branch" to "git" or something to make it clear this is only git related, after all, mercurial or svn has branches too. [edit: or use vc instead of magit and make it work with everything]

I'm not sure starting a separate repository for this is worth it. Flycheck bundles a lot of checkers and it works fine for them, I think we can ship "additional columns" in this project similarly.

@rejeep
Copy link
Owner

rejeep commented Mar 17, 2018

I agree that git is better than branch. Creating a plugin only for git might be a bit excessive, but at the same time, I don't like assuming that everyone uses Git. One alternative would be to create a prodigy-scm.el package that can support any SCM system.

@FrancescElies
Copy link
Collaborator Author

I removed magit specific code from this pull request.
I left prodigy-default-list-columns which contains the current columns and their formats together.
Added a defcustom prodigy-custom-list-columns which would allow the user to pass custom columns.

In my specific use case looks like this:
screen shot 2018-03-18 at 16 20 44

This way you would have some time to think if you want to have this additional column definitions inside the repository or if that should be moved to something like prodigy-scm.el, in the meanwhile one could use prodigy-custom-list-columns to plug-in custom columns.

What do you think?

prodigy.el Outdated
("Tags" 25 nil)]
"List format.")
(defconst prodigy-default-list-columns
'((func prodigy-marked-col format ("Marked" 6 t :right-align t))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's generally better to use :keywords over 'symbols in plists

@Fuco1
Copy link
Collaborator

Fuco1 commented Mar 19, 2018

I like this setup.

I still think that we should keep the extra stuff in this repository. I don't particularly like the situations where there is 5 million trivial packages as "plugins" for a package, it does not feel very Emacs-y.

We can have a file prodigy-columns.el with all the extra column functions/formats.

@FrancescElies
Copy link
Collaborator Author

FrancescElies commented Mar 21, 2018

I like this setup.

I still think that we should keep the extra stuff in this repository. I don't particularly like the situations where there is 5 million trivial packages as "plugins" for a package, it does not feel very Emacs-y.

We can have a file prodigy-columns.el with all the extra column functions/formats.

I moved columns' related code to prodigy-columns.el and replaced 'symbols' with :keywords.

CI failing though, I seem not to understand the loading process in emacs :/, I believe I need to modify the load-path, at the moment I'm having a look how other packages do this, but I could not get my head around this yet.

How can I make prodigy.el load prodigy-columns.el properly? Help much appreciated, thanks in advance

@Fuco1
Copy link
Collaborator

Fuco1 commented Mar 21, 2018

You should put (require '...) into the main file and also edit the Cask file because that declares that the package file is only the prodigy.el file so probably cask initializes emacs only loading that? (not sure here)

Copy link
Owner

@rejeep rejeep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a note about this in the README?

@@ -0,0 +1,102 @@
;;; prodigy.el --- Manage external services from within Emacs -*- lexical-binding: t; -*-
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy paste mistake, my bad. Added 7c9e9e4


(defun prodigy-columns ()
"Join default, additional and custom defined `prodigy' columns"
(append prodigy-default-list-columns prodigy-additional-list-columns prodigy-custom-list-columns))
Copy link
Owner

@rejeep rejeep Mar 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is prodigy-additional-list-columns prodigy-custom-list-columns defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having a look at this.

I am not sure if I understand the question.

In the previous lines in this file one finds defined:

  • defconst prodigy-default-list-columns: default columns, always shown (marked, name, status & tags).
  • defcustom prodigy-additional-list-columns: user can tick a checkbox to activate them (at the moment only prodigy-git-branch-col available).
  • defcustom prodigy-custom-list-columns: user could add it's own defined column functions (not sure if useful, but it made sense to me).

I broke test though, I could not manage to make (require 'prodigy-columns) play nicely inside in prodigy.el and configure cask properly.

I am open to change/delete anything that does not make sense here, please let me know.

All best

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I understand the question

I think Github played me a prank by not showing me the entire diff, never mind.

README.md Outdated
In the `*prodigy*` buffer, you will always see a table with the following columns.
- **Marked**: Services that you want to perform an action on.
- **Name**: Service name.
- **Status**: Service status
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing dot

@rejeep
Copy link
Owner

rejeep commented Mar 25, 2018

I removed magit specific code from this pull request.

No?

@FrancescElies
Copy link
Collaborator Author

No?

I did, but after #121 (comment) if I understood correctly, we might want to have an extra file for that kind of column specific code, that's why I brought it back.

I added c5c3962 which deletes that code and prodigy-additional-list-columns.

So currentlyprodigy-default-list-columns holds the default prodigy columns and the user could use prodigy-custom-list-columns to add new ones.

I see travis failing with

The command "curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh" failed and exited with 1 during .

@FrancescElies FrancescElies changed the title [magit] show current branch prodigy columns Mar 25, 2018
@FrancescElies FrancescElies changed the title prodigy columns custom prodigy columns Mar 25, 2018
@FrancescElies
Copy link
Collaborator Author

Tests passing now, I squashed all changes on a single commit

@shevchuk
Copy link

shevchuk commented Jan 2, 2020

This is a handy feature, is there any chance to see it merged? @rejeep

@rejeep
Copy link
Owner

rejeep commented Jan 2, 2020

Sure! @FrancescElies I added you as a collaborator, feel free to merge when rebased.

Allows to add user custom defined new columns
@FrancescElies
Copy link
Collaborator Author

ℹ️ Maybe useful to someone else, currently I am using something like

(setq prodigy-custom-list-columns
   (quote
    ((:function prodigy-git-branch-col :format
                ("Git" 25 t)))))

(defun prodigy-git-branch-col (service)
  "Return SERVICE git branch.

  - Prepend ✏ if something any file in the repository has been modified.
  - Prepend ∦ if remote branch and current branch are not in sync."
  (-if-let (default-directory (prodigy-service-cwd service))
      (my/magit-repolist-branch-status)
    ""))

(defun my/magit-repolist-branch-status (&optional _id)
  (if (magit-git-repo-p default-directory)
      (s-trim (s-join " "
                      `(,(if (magit-anything-modified-p)
                             "")
                        ,(if (not (magit-rev-eq (magit-get-current-branch)
                                                (magit-get-push-branch)))
                             "")
                        ,(or (magit-get-current-branch)
                             (magit-rev-name "HEAD")))))
    "n.a.")
  )

Previous code would give you a new git column
Screenshot 2020-01-06 at 21 22 56

@FrancescElies
Copy link
Collaborator Author

FrancescElies commented Jan 6, 2020

Travis fails for emacs 26
image

I believe this is not related to changes introduced by this pr.

Update: This Issue was reported at rejeep/evm#134

@DamienCassou
Copy link
Collaborator

I'm closing all old PRs. If you still care, please rebase your branch and reopen the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants