Skip to content
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

Is the alpha release usable/testable? #113

Open
nalysius opened this issue Apr 12, 2019 · 11 comments
Open

Is the alpha release usable/testable? #113

nalysius opened this issue Apr 12, 2019 · 11 comments

Comments

@nalysius
Copy link

I am an Emacs beginner, I try to use phpactor.el to improve my PHP experience.
I installed phpactor by following the standalone way and it seems to be working. When I use it in my directory it works.
I've installed phpactor.el by using package-install in Emacs.
When I use Emacs to type code, automatically in the mini buffer I see an error.

Here is a code to reproduce it. My point is after the arrow (where I put a pipe) when I the an error.

<?php
class Stuff
{
    public function test()
    {
    }
}

$s = new Stuff();
$s->|

The error I get:

Phpactor: Unknown item "", known items: "", "", ""

Testing the Phpactor installation:

$ phpactor status
Version: 7db7a5c (il y a 4 semaines) updated-composer-749
Filesystems: git, simple, composer
Working directory: /var/www/html/work/libs/myrepo

Config files (missing is not bad):

  ✘ /home/john/.config/phpactor/phpactor.json
  ✘ /home/john/.config/phpactor/phpactor.yml
  ✘ /var/www/html/work/libs/myrepo/.phpactor.json
  ✘ /var/www/html/work/libs/myrepo/.phpactor.yml

Diagnostics:

  ✔ Composer detected - faster class location and more features!
  ✔ Git detected - enables faster refactorings in your repository scope!
  ✔ XDebug is disabled. XDebug has a negative effect on performance.

My .emacs about phpactor.el.

(add-hook 'php-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function
                  'phpactor-hover)))

Since phpactor is under development and phpactor.el is in alpha version, is it usable/testable? Is the error from me/my install, or the plugin isn't usable?
As a side note I'll add that I'm already using phpactor in Vim (in Vim it's not using the standalone install I think though).

@kermorgant
Copy link
Contributor

Hi @anthonybocci !

I've been using phpactor for many monthes now and it has definitely been a game changer for my daily php development workflow (no more random completion candidates, common refactorings with a few keystrokes).

There has been work to improve the usability, but it's been on develop branch for a long time and we have just recently merged it into master. So I would say we are quite close to a beta quality release that should be usable without too much hassle. And in that regards, it's good to have feedback like yours :-)

That said, let's look at your error. I would guess it comes from the following

(add-hook 'php-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function
                  'phpactor-hover)))

(that's my guess as you get the error without running anything related to phpactor explicitely).

I'd suggest starting by commenting that part and then try to get phpactor working.

Then, have you run the phpactor-install-or-update command within emacs ?

You could look at my configuration here if you want to try by using the source (not recommended, but worth trying as a last resort).

@nalysius
Copy link
Author

Hi @kermorgant,

Thank your for your answer!
I'm using Vim for about one year, and phpactor for one week. I discovered phpactor when beginning with Emacs since the default experience in Emacs with PHP is really bad. By default, without php-mode and with the default theme it's quite ugly. With php-mode it's a little bit better, but since the experience in PHP seems to be better in Vim that Emacs, I think a tool like phpactor may do the difference.

By removing the lines in my .emacs I no longer have the errors! I copied it from the README but I probably didn't understand what it's used for.

Yes I ran phpactor-install-or-update, and I just ran it again to be sure. It works, Composer exits with success.

-*- mode: compilation; default-directory: "~/.emacs.d/phpactor/" -*-                                                                 
Compilation started at Sat Apr 13 14:16:50                                                                                           
                                                                                                                                     
composer install --no-interaction --no-ansi --no-dev                                                                                 
Loading composer repositories with package information                                                                               
Installing dependencies from lock file                                                                                               
Nothing to install or update                                                                                                         
Generating optimized autoload files                                                                                                  
ocramius/package-versions:  Generating version class...                                                                              
ocramius/package-versions: ...done generating version class                                                                          
                                                                                                                                     
Compilation finished at Sat Apr 13 14:16:54

I'm really glad to learn the project is near of a beta relase! :)
I no longer have the errors, but how do I get it working so? Is there a default key mapping like in the Vim plugin, or am I supposed to set them manually? I didn't find this information in the README and there is no INSTALL file.

I'd be glad to contribute to the project, at least as a user/tester.

@kermorgant
Copy link
Contributor

Hi,

Thanks, indeed, some feedback would be very welcome :-) (I'm not using melpa myself as I'm working on sources, so I'm crossing my fingers that it just works as it should)

I guess the first useful thing you would like to get working is the completion, but before that, you could execute phpactor-status within emacs to see if phpactor's executable is called.

if that does not work, could you look at the value of phpactor-executable (C-h v phpactor-executable) ?

@nalysius
Copy link
Author

Since I'm using the included package manager I'll see if everything works as it should :).

I typed M-x and phpactor-status and I confirm that phpactor is called. I got the stuffs about the config files, Git and Composer. This part seems good.
Phpactor is somewhere on my disk but is in the $PATH, so it should be found everywhere.

I checked the value of phpactor-executable anyways, and its value is nil. I guess when the path to the executable is nil it's tried as global.

@kermorgant
Copy link
Contributor

kermorgant commented Apr 13, 2019

hmm, I did not expect that (phpactor-executable being nil and getting something from phpactor-status).

But phpactor-executable being nil is not fine. Have you tried restarting emacs and check after ?
if not, it might be worth removing the folder ~/.emacs.d/elpa/phpactor-2019xxx and restart emacs after that

@nalysius
Copy link
Author

That seems strange. I'll list all steps I do and explain the state.

  1. Emacs is closed, I just open my first Terminal on my machine.
  2. C-h v and phpactor-executable, here is the output.
phpactor-executable is a variable defined in ‘phpactor-autoloads.el’.                                                                
Its value is nil                                                                                                                     
                                                                                                                                     
  Automatically becomes buffer-local when set.                                                                                       
  This variable is safe as a file local variable if its value                                                                        
  satisfies the predicate ‘(lambda (v) (if (consp v) (and (eq (quote root) (car v)) (stringp (cdr v))) (or (null v) (stringp v))))’. 
                                                                                                                                     
Documentation:                                                                                                                       
Path to ‘phpactor’ executable file.

As you can see, with a fresh Emacs instance the value seems to be nil. In the file ~/.emacs.d/elpa/phpactor-20190403.216/phpactor-autoloads.php I can see the following:

(defvar phpactor-executable nil "\
Path to `phpactor' executable file.")

(make-variable-buffer-local 'phpactor-executable)

(put 'phpactor-executable 'safe-local-variable #'(lambda (v) (if (consp v) (and (eq 'root (car v)) (stringp (cdr v))) (or (null v) (stringp v)))))

I absolutely don't know Lisp. I guess the variable is set as nill to declare it first, and then we try to set it.

  1. I just deleted the directory ~/.emacs.d/elpa/phpactor-20190403.216/, closed and restarted Emacs.
  2. C-h v and phpactor-executable. I got [No match]. The variable is no longer defined.
  3. M-x and phpactor-status. I got [No match].

The plugin is no longer installed so I understand why it no longer work. The problem would be with the expression that defines the variable, right?

@kermorgant
Copy link
Contributor

kermorgant commented Apr 13, 2019 via email

@nalysius
Copy link
Author

It wasn't reinstalled indeed, I didn't expect it to be reinstalled. I tried to install manually the package (let's be crazy) so I cloned your repository to try to hack the part of code that doesn't work, ran composer install, and I ran M-x, load-file and the path to the package. I got the error Wrong type argument: stringp, nil. So, I reinstall the package using M-x and package-install.

The variable php-executable is still nil.

If I can help in some way, I'm open to suggestions.

@kermorgant
Copy link
Contributor

kermorgant commented Apr 13, 2019

Oh damned, phpactor-executable being nil on the master branch is in fact fine, sorry :-(

This is something I've changed in a branch I'm using currently, but that's another story,,,

So in fact, it does not look that bad. You might want to try something like phpactor-goto-definition to see if it works.

By the way, if you want to hack the code, you would still be better running phpactor-install-or-update (instead of running composer install) as it puts a version of phpactor inside ~/.emacs.d/phpactor (it copies composer files and runs composer install there).

And no, this package does not introduce any keybindings. It's up to every user to define his own.
You could have a look at my config, or look into the source to see all interactive functions available.

@nalysius
Copy link
Author

nalysius commented Apr 14, 2019

Haha ok so the installation was right :)

I tried M-x and phpactor-goto-definition and it works well!
I would really suggest to set some default keybindings, because not every users are able to play with ELisp and set the keybindings, mainly the beginners (like me). It seems useful for me to have at least default keybindings so the plugin is usable as soon as it's installed. Then, everybody would still be able to overwrite them in their own ~/.emacs.

I'll have a look to Lisp and I'll see then if I can play a bit with it.

Thank you for your help!
I can go to the definition, but I don't really know how to use the rest. For example I tried using a new instance of a class, calling phpactor-context-menu after a -> to get the methods/properties list but I haven't them. I have Property "": in the mini buffer, and whatever I type I get Bad string format: "doesn't start with \"'!".
Is there something else I have to do?

EDIT: As a note for myself here is a simple solution to set keybindings.

@kermorgant
Copy link
Contributor

Great !

I think you have a point about keybindings, but at the same time, it's a bit tricky to come up with something correct. But in order to be helpful on that side, I think the README could include configuration for some keybindings that the user is free to add, adapt or ignore.

Then, for your error : looks like an issue worth exploring at a later stage (by looking at Phpactor Output buffer for example, or by using phpactor's replay function). But right now, I believe you want to use company-phpactor in order to use phpactor's completion, right ? If so, you should enable company-phpactor backend (I've done it that way, maybe not the most appropriate but it works for me : https://github.com/kermorgant/.emacs.d/blob/5bb4de0575a05c756b17520b07e98de644bc6d9a/lang/mk-php.el#L5)

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

No branches or pull requests

2 participants