sshaw / build-status

Emacs minor mode that monitors and shows a buffer's build status in the mode line.
27 stars 2 forks source link

Build mode from arbitrary magit status page? #7

Closed jskulski closed 5 years ago

jskulski commented 5 years ago

Hello, thank you for the great module. This is more out of curiosity but I was wondering if it is possible to (and how you can approach) have the build-mode status badge in my magit buffer. It is where i generally am thinking about if the build is done or not.

I see in code, build-status looks at buffer-file-name, which is nil for magit (and shells, etc). So I assuming one way is for me to redefine that method. But I was wondering if:

1) there were other ways you would suggest to accomplish 2) if it would make sense to support a customizable map that users could point to. I'm new to emacs-lisp so this is more psuedo-code but something like

(defun project-from-map (buffer-name)
(("magit: web" "/Users/jskulski/Code/web/") 
  (/.*e-shell.*/ " (ask-eshell-for-cwd) ;; This is above my head now, but maybe we could functions or regular expressions 
)

I am using projectile if that changes any suggestions. Thanks again!

sshaw commented 5 years ago

Hi,

I see two approaches: 1) a one-off way or 2) a supported way. Though they both are similar.

For the one-off way I would set a callback via run-at-time that would inspect build-status--project-status-alist and update a magit buffer as needed. Of course in the package's current form one would not be able to take advantage of the existing status and font mapping. This would also require you to use internal variables which may cause it to break in the future.

This is where the supported way comes in: it would provider well-defined methods for retrieving a project's build status and maybe even replacing the mode line updating with a function where one can do custom updates.

(defun project-from-map (buffer-name)

Would this control where the status would be displayed? Modeline or Magit?

I think it's best to solve the general case and then worry about configuring it externally afterwards.

jskulski commented 5 years ago

Sorry, I wasn't clear when I said 'have it in my magit buffer'. I meant to have the build-status badge appear (as it does, in the modeline) when I switched to my magit. After thinking about it, I would want that to happen with any projectile buffer.

That was the thinking behind project-from-map was to allow some control over how build-status chooses finds the project. I was thinking a little too small in implementation, perhaps. What I am seeing is that build-status keys off buffer-file-name, but for magit buffers and some other modes, their filenames are nil, so build-status. Conceptually they are the same project and I'd like to see the build status mode.

All that said, I unexpectedly solved this problem another way: I installed the package magithub (https://github.com/vermiculus/magithub) which shows the build status through github and that is enough for my needs. Thanks again for the module, I'll close this out.

Thanks!

sshaw commented 5 years ago

I meant to have the build-status badge appear (as it does, in the modeline) when I switched to my magit.

Ah yes, this is needed. I think I have a local branch that attempts to do this.

I installed the package magithub which shows the build status through github

Nice, I didn't know Magithub did that.