emacs-php / php-suite

Emacs is a powerful IDE for PHP
GNU General Public License v3.0
16 stars 1 forks source link

'live preview' like Brackets #4

Open Taariqq opened 6 years ago

Taariqq commented 6 years ago

Guys, this is wonderful to see. I would much rather use Emacs than VS Code ... but there is one thing holding me back from leaving Brackets. It is the absolutely fantastic 'live preview' where the browser would automatically switch to the file that you are editing and would auto-update upon save.

I see impatient-mode as part option but it is for html/css only. Is there any way to implement Brackets-like live preview?

Taariqq commented 6 years ago

All I need is, with PHP, 'refresh browser on save' and 'switch browser to the file that is being edited in emacs'. If I have these two features, I will be happy.

ejmr commented 6 years ago

Is there any way to implement Brackets-like live preview?

Years ago when I used Conkeror as my browser I had some code hacked together which did those things, albeit in a rough and ugly way, and that wasn't exactly error-proof either. So yes, it is possible to implement; I suspect a browser-agnostic approach would be more difficult though, which is what I am assuming Brackets does. There are other modes for GNU Emacs which provide live preview support for their respective content---I apologize for not being able to think of any off the top of my head. But examining those could possibly serve as a model or example for PHP Mode to follow, or ideally someone awesome has written a mode which already does exactly this and I'm just unaware of it.

But anyways, yes, those two features are technically possible. Thank you for bringing them up for discussion.

--ejmr

Taariqq commented 6 years ago

@ejmr That part about perhaps someone has already implemented it -- that would just be ideal. Good to know that you had something similar implemented, so at least I have reached out to the correct people. Adam Taylor from Boston Emacs Meetup group pointed me to you guys. Also, someone on reddit responded with something that might be a good starting point.

One way or the other, I'd like to see this implemented. Brackets' Git integration sucks and VS Code ... well, that is Microsoft!

ejmr commented 6 years ago

One way of the other, I'd like to see this implemented.

If you have never done any Emacs Lisp programming---or even if you have---this would be a great way to start. The overwhelming majority of functionality in PHP Mode was implemented by the users who wanted that specific functionality. And in my experience that process accounts for most features in every open-source project.

Do not be dissuaded if you have little to no experience with Emacs Lisp. Instead embrace this as a fantastic learning opporotunity. Even if you cannot completely implement this functionality on your own, attempting to implement it anyway would...

  1. Be greatly appreciated by the the maintainer (@zonuexe). I try not to speak for other people but I feel very confident in saying that in this situation.

  2. Teach you a number of important concepts and techniques in GNU Emacs, all of which will empower you as a GNU Emacs user.

  3. Earn you valuable lessons and advice from the many, many friendly contributors to this project, who would be happy to help you in your study of Emacs Lisp.

I no longer actively contribute to or maintain this project. However, if you attempt to implement this functionality yourself, I will personally do what I can to mentor and advise you along the way, time and health permitting.

--ejmr

cyrialize commented 6 years ago

@Taariqq I've been planning on contributing to php-mode and php-suite for some time now. As someone just getting started in emacs-lisp I find creating my own tiny functions in my config files a great way to learn. For example, https://github.com/jonnycyr/.emacs.d/blob/master/code/jonny-php.el. I work with legacy code a lot and most of the time I don't want Emacs automatically deleting whitespace - so I wrote a function that made it so Emacs didn't do that.

Also, http://ergoemacs.org/emacs/elisp.html - Xah's tutorial is pretty great. I find it to be right to the point, I'd suggest looking through it if you want to get hacking immediately.

Taariqq commented 6 years ago

Eric and Jonny,

It is very heartening to read your posts, especially Eric's. Even though I have been exposed to emacs and the world of programming since the 90's, when it comes to the practicality of the things, I am just a newbie to both. Meaning I have not done anything significant in either.

Currently, I have gone on a learning path to PHP. If I decide to do this, it would mean that I learn Emacs well, first, and then take a crack at Elisp ... and then try to break down the problem and implement a solution. Sounds like a great little experiment that will give me a real life like experience. The flip side is if I can't break down the problem I would have lost a lot of time from my PHP path.

On a side note, I do remember RMS mentioning that you should learn Emacs and Lisp and that will teach you the principles of how to program a computer. That could be an incentive!

I am still undecided about diving into this, as even after it is implemented, next target is WordPress development. I am not sure how suited Emacs would be for that kind of work. Not sure. I am 50/50. And then I just saw some PHP7mode, kind of abandoned. I am hoping that the functionality is ported into the main PHP-mode, but if not, that would be another disaster. Lots to think before I jump in.

For starters I am watching this Elisp video for now and will decide later, God willing.

Thank you very so much for helping motive me. I will keep you guys posted either way.

taariqq