Skip to content

Conversation

@zonuexe
Copy link
Member

@zonuexe zonuexe commented Jan 7, 2019

Changes

  • Rename phpactor-update to phpactor-install-or-update.
  • Install Phpactor in ~/.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).

@zonuexe zonuexe requested a review from kermorgant January 7, 2019 13:36
Copy link
Contributor

@kermorgant kermorgant left a 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)))
Copy link
Contributor

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 ()
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

@kermorgant kermorgant Jan 7, 2019

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
Copy link
Contributor

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
Copy link
Contributor

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 ?

@kermorgant
Copy link
Contributor

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 ?

@zonuexe
Copy link
Member Author

zonuexe commented Feb 5, 2019

@kermorgant I'm sorry, since this commit 2b2695a is not my intended code, I will delete it once in history.

@zonuexe zonuexe force-pushed the refactor/phpactor-update branch from 2b2695a to 14c3ea8 Compare February 5, 2019 17:39
@zonuexe
Copy link
Member Author

zonuexe commented Feb 5, 2019

@kermorgant
I reorganized commits. Please point out again points that you do not know the intention of change.
Thank you.

zonuexe and others added 12 commits February 8, 2019 23:41
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.
@zonuexe zonuexe force-pushed the refactor/phpactor-update branch from 4dce93b to 2c5f79b Compare February 8, 2019 14:41
@zonuexe zonuexe merged commit d180594 into develop Feb 8, 2019
@zonuexe zonuexe deleted the refactor/phpactor-update branch February 8, 2019 14:42
@zonuexe
Copy link
Member Author

zonuexe commented Feb 8, 2019

@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.

@kermorgant
Copy link
Contributor

@zonuexe I wonder, did you miss my pending comments about downloading composer.json etc. ?

@zonuexe
Copy link
Member Author

zonuexe commented Feb 8, 2019

@kermorgant Is it 2b2695a or anything else?

@kermorgant
Copy link
Contributor

kermorgant commented Feb 8, 2019

@zonuexe No, I meant those ones, about phpactor--lisp-directory

image

@zonuexe
Copy link
Member Author

zonuexe commented Feb 8, 2019

@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
Copy link
Contributor

Choose a reason for hiding this comment

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

@zonuexe I don't understand why we should download composer.json & composer.lock.

Sorry, I started reading + commenting chronologically and now I see your comment from commit e7a7773

Copy link
Contributor

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 ?

Copy link
Member Author

@zonuexe zonuexe Feb 8, 2019

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.

@zonuexe
Copy link
Member Author

zonuexe commented Feb 8, 2019

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.
Lisp files are not only installed by package.el, they can be introduced by other mechanisms, or the Lisp code can be executed directly from the buffer.
That means there are several cases where directories can not be specified in either byte-compiled-dir or locate-directory.
Or that may not have a directory at all in the first place. I would like to run it even under such circumstances.
In rare cases, it is possible that byte-compiled files are moved to other environments and the paths do not match.

Next, consider the case where it was installed by package.el or byte compiled normally.
In these cases we can assume that we can locate the appropriate composer.json and composer.lock.
However, since package.el contains the version number in the directory name, the user must set up Phpactor each time it is updated.
By install the files in a directory that is not dependent on the directory of the package, users can reduce the number of times to run phpactor-install-or-update frequently.

There are pros and cons in this implementation. By having users composer install in the same location as the Lisp file every time you update, users always get the version of Phpactor recommended by phpactor.el. In the current implementation, the user may continue to use the old Phpactor and cause trouble.

@kermorgant
Copy link
Contributor

@zonuexe Thanks for taking the time to explain your reasoning.

I'm fine with the last part, about reducing the number of times to run phpactor-install-or-update frequently. The risk about using an old version of Phpactor is something we should be able to cope with elegantly with Phpactor's RPC versioning.

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 ;-)
And I guess I insisted a bit on this because I might have an opposite view on such things : I'd personnally be more of a dictator and enforce a standard way of installing this package and by that avoid some corner cases. But again, it's not a problem, it's just to share a bit how I view things.

@zonuexe
Copy link
Member Author

zonuexe commented Feb 12, 2019

@kermorgant

And I guess I insisted a bit on this because I might have an opposite view on such things : I'd personnally be more of a dictator and enforce a standard way of installing this package and by that avoid some corner cases. But again, it's not a problem, it's just to share a bit how I view things.

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 phpactor-executable or phpactor-lisp-directory.”

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.

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.

3 participants