-
Notifications
You must be signed in to change notification settings - Fork 12
Refactor phpactor-update #86
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
Conversation
kermorgant
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zonuexe I've not had time to test but I've put some questions straight out of my head.
Not sure what is the rationale behind this change : was the previously installation folder for phpactor subject to frequent changes, requiring some useless call to phactor--install-or-upgrade or is it something else ?
phpactor.el
Outdated
| (call-process composer-executable nil (get-buffer-create phpactor--buffer-name) nil "install" "--no-dev"))) | ||
| (let* ((default-directory (phpactor--get-package-directory)) | ||
| (directory (or phpactor--base-directory | ||
| phpactor--remote-composer-file-url-dir))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why (or in which case) would you look into phpactor--remote-composer-file-url-dir ?
|
|
||
| (defun phpactor-update () | ||
| ;;;###autoload | ||
| (defun phpactor-install-or-update () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
phpactor.el
Outdated
| for code = (format "copy(%s, %s)" | ||
| (php-runtime-quote-string (concat directory file)) | ||
| (php-runtime-quote-string (concat phpactor-package-directory file))) | ||
| do (message code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that message some debug you forgot to remove ?
phpactor.el
Outdated
| :group 'php) | ||
|
|
||
| ;;;###autoload | ||
| (defcustom phpactor-package-directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I'm a bit confused by the package term. for me, package relates to phpactor.el, but it seems we're installing phpactor in this folder.
unless I'm wrong, maybe just phpactor--directory ?
phpactor.el
Outdated
| ;;; Constants | ||
| (defconst phpactor-command-name "phpactor") | ||
| (defconst phpactor--supported-rpc-version "1.0.0") | ||
| (defconst phpactor--base-directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be sure I understand, this looks like the folder previously returned by phpactor--get-package-directory (ie something like ~/.emacs.d/elpa/phpactor-date). Am I correct ?
phpactor.el
Outdated
| (defun phpactor--get-package-directory () | ||
| "Return the folder where phpactor.el is installed." | ||
| (file-name-directory(locate-library "phpactor.el"))) | ||
| (or phpactor-package-directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
following my previous comment about this function, maybe it is not needed ?
|
Hi @zonuexe I've just added a commit illustrating my view of the situation. It worked for me but maybe I miss some things you had in mind ? |
|
@kermorgant I'm sorry, since this commit 2b2695a is not my intended code, I will delete it once in history. |
2b2695a to
14c3ea8
Compare
|
@kermorgant |
5b3c3d5 to
4dce93b
Compare
Instead of the package's directory, copy the file to the user's .emacs.d directory and install it.
The term "Package" is ambiguous for both Lisp package (ELPA) and PHP package (Composer). Here we used Composer to try to set up Phpactor in a different directory with package.el, which meant Composer package.
Before the change, when phpactor-install-directory was NIL, it falls back to the directory of the Lisp package. However, there is no demand for that function, so we no longer have such an option.
The purpose of this change is to resolve the "package" ambiguity between Lisp and PHP.
4dce93b to
2c5f79b
Compare
|
@kermorgant Thank you for reviewing. I merged this branch into develop. I am not going to merge this commit for a while for a while, so please correct the incomprehensible places and naming incongruity. |
|
@zonuexe I wonder, did you miss my pending comments about downloading composer.json etc. ? |
|
@kermorgant Is it 2b2695a or anything else? |
|
@zonuexe No, I meant those ones, about |
|
@kermorgant I see, the comment is in "pending" state, I can not read it. |
| (eval-when-compile | ||
| (when (and (boundp 'byte-compile-current-file) byte-compile-current-file) | ||
| (file-name-directory byte-compile-current-file)))) | ||
| (defconst phpactor--remote-composer-file-url-dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this elisp code is still obscure to me, and beyond that, the use case that you support
I'm intrigued by the fact we have 2 different alternatives to find the path of phpactor.el, and that we also care for the case when those 2 fail (fallback to download composer.json+composer.lock).
And my misunderstanding starts with the first condition of the if : Under which circumstances would (and byte-compiled-dir (file-directory-p byte-compiled-dir)) fail ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kermorgant
Yes, we can not get byte-compiled-dir in the following cases:
- Lisp code was directly evaluated on the buffer.
- Not byte-compiled Lisp file was loaded
We do not see these symptoms when installing the Lisp package from package.el, but in that case occasionally.
Why not composer install in the same directory as Lisp?There are several reasons for this. In Emacs we can run Lisp files in several ways. Next, consider the case where it was installed by package.el or byte compiled normally. There are pros and cons in this implementation. By having users |
|
@zonuexe Thanks for taking the time to explain your reasoning. I'm fine with the last part, about reducing Then about the first part... First, I should stress once again I'm quite inexperienced with emacs so my view on this is necesserily narrowed. But from a practical perspective, I still can't see why a user would install a package differently than with package.el or cloning the git repo directly. This is not a big deal per se, I'm fine with this but as I was rewiewing this, I tried to get into the details ;-) |
That idea makes sense. Still do not force all users to install from the package. For example, this implementation could be replaced by a message saying “Please set The balance between "saving user's labor" and "keeping the code simple" is a difficult decision. In this implementation, I emphasized the user's convenience. When I need to maintain this code several times in the future, I agree to remove it. |

Changes
phpactor-updatetophpactor-install-or-update.~/.emacs.d/phpactor/instead of the directory where the package was installed (it is better to decouple those as package updates don't necessarily require an update of phpactor).