alphapapa / frame-purpose.el

Purpose-specific frames for Emacs
GNU General Public License v3.0
52 stars 4 forks source link

Call a function after the frame is created and focused? #14

Open john2x opened 6 years ago

john2x commented 6 years ago

One use-case I'd like to have is to define a function called launch-erc-frame, and this would launch a frame dedicated for ERC buffers, with ERC immediately started. I want to do the same for launch-mu4e-frame, etc. as well.

Is something like this possible?

akirak commented 6 years ago

My frame-workflow package supports such a feature. For example, your erc workspace could be configured in the following way:

(frame-workflow-define-subject "erc"
  :make-frame '(frame-purpose-make-mode-frame 'erc-mode)
  :layout '(progn
             (erc)
             (delete-other-windows)))

Then you can create a frame for the subject with (frame-workflow-switch-frame "erc").

akirak commented 6 years ago

Or maybe you can do it without frame-workflow:

(let ((frame (frame-purpose-make-mode-frame 'erc-mode)))
  (with-selected-frame frame
    (erc)))

The advantage of using frame-workflow is that you can switch to the frame by (frame-workflow-switch-frame "erc"). frame-workflow-switch-frame is a function that selects an existing frame for the subject if any or otherwise creates a new one.

alphapapa commented 6 years ago

You should definitely see if Akira's frame-workflow package does what you need. He's putting a lot of work into it, and he seems to be a really good programmer.

Otherwise, well, I'd probably suggest doing a function like:

(defun my-erc ()
  (erc)
  (frame-purpose-make-mode-frame 'erc-mode))

Because generally I don't think you would need to launch ERC before opening the frame. In fact, doing the frame before there are any ERC buffers would probably then require you to manually select an ERC buffer.

akirak commented 6 years ago

Thanks for your compliment, but I don't think I am a good programmer. I am neither a professional programmer nor a CS graduate. I belong to a CS graduate school, but I didn't finish it. I don't want to talk about that in detail now.

alphapapa commented 6 years ago

Well, if you aren't a good programmer, then I certainly am not, either. :) And you're not the only amateur Emacs package developer, that's for sure!

akirak commented 6 years ago

More precisely, I am about to start working as a programmer/developer, thanks to activities on GitHub! I am (re)starting my track now. My interest was mostly in application design and not in technical challenges, which I meant by "being not a good programmer", but I have to build better skills.

alphapapa commented 6 years ago

That's very interesting! I'd love to talk with you about that story sometime. Do you use Matrix by any chance?

akirak commented 6 years ago

I don't use any messaging app to communicate with people in the FLOSS world, but if there is any popular option, I don't mind installing it.

alphapapa commented 6 years ago

Well, if you're interested in Matrix, you can use the http://riot.im web client, as well as several FOSS clients like Quaternion, nheko, and https://github.com/jgkamat/matrix-client-el. Feel free to message me: @alphapapa:matrix.org