Giter Site home page Giter Site logo

emacs-plsense's Introduction

Japanese

What's this?

This is a extension of Emacs that provide interface for PlSense.

PlSense is a development tool for Perl using the type inference by analyzing source code.
For detail, see https://github.com/aki2o/plsense/blob/master/README.md

Using this extension, you can do coding Perl on Emacs like the following.

Feature

Omni completion by auto-complete.el

When you are on Perl buffer, provide the optimized completion for context using auto-complete.el.
It's Omni completion what is called.
Provide omni completion on the following position of the buffer.

  • Variable
  • Method
  • Module
  • Initializer of Class
  • LIST of Use/Require statement
  • Key of Hash

demo1

Smart help by doing popup or displaying buffer

demo2

Sub signature by eldoc.el

demo3

Jump to definition

Use perl-completion.el as supplements

use perl-completion.el for compeltion if fail the type inference.

Demo

demo

Here is a long version -> https://www.youtube.com/watch?v=qurNSQjOyK4

Requirement

  • Unix Shell ( If Windows, e.g. Cygwin )
  • Perl
  • PlSense

Install

If use package.el

2013/09/10 It's available by using melpa.

If use el-get.el

2013/07/26 Not yet available.
2013/09/08 It's available. But, master branch only.

If use auto-install.el

(auto-install-from-url "https://raw.github.com/aki2o/emacs-plsense/master/plsense.el")

* Installing each the following dependency is required in this case.

Manually

Download plsense.el and put on your load-path.

* Installing each the following dependency is required in this case.

Dependency

Configuration

(require 'plsense)

;; Key binding
(setq plsense-popup-help-key "C-:")
(setq plsense-display-help-buffer-key "M-:")
(setq plsense-jump-to-definition-key "C->")

;; Make config suit for you. About the config item, eval the following sexp.
;; (customize-group "plsense")

;; Do setting recommemded configuration
(plsense-config-default)

Usage

Show version

  • plsense-version ... show version of PlSense.

* Double as a verification of install.

Start/Stop server

  • plsense-server-start ... start process of PlSense server.
  • plsense-server-stop ... stop process of PlSense server.

* You must finish configuration of PlSense on ahead.
* You must do plsense-server-start on Emacs regardless of whether PlSense server process exist.
* Executing the above command redundantly is OK.
* Maybe show ... is failed despite the success of the above command along of timeout.
* In the case, verify status of PlSense server by seeing 'Information of server' section below.
* You can do plsense-server-start automatically by configuration.

Information of server

  • plsense-server-status ... show status of PlSense server.
  • plsense-server-task ... show the running tasks on PlSense server.

Kind of server

  • Main Server ... provide completion/help.
  • Work Server ... manage task for searching library and analyzing File/Module.
  • Resolve Server ... gather result of analyzing File/Module.

Status of server

  • Running ... can accept client.
  • Busy ... can not accept client.
  • Not Running ... not yet started.

Task of server

  • build File/Module ... Analyzing the File/Module.
  • find String ... Searching library about the String.

Active/Inactive provision of completion/help

The above command in 'Start/Stop of server' section, double as a switching active/inactive.
If you have executed plsense-server-start, provision of completion/help is active when open buffer.
But, not start provision of completion/help until finish analyzing the buffer.
When start provision of completion/help, show ... is ready..

  • plsense-buffer-is-ready ... show status about analyzing current buffer.
  • plsense-reopen-current-buffer ... restart analyzing current buffer.

* Not activate automatically on the buffer that opened before executing plsense-server-start.
* In the case, execute plsense-reopen-current-buffer for activate.
* Not activate automatically if the buffer file is not exists.
* When execute find-file, save the buffer.
* Not activate on the buffer of the mode not included in plsense-enable-modes.

Status about analyzing buffer

  • Yes ... finished.
  • Now Loading ... do analyzing now.
  • No ... not start analyzing.
  • Not Found ... PlSense server can't identify the buffer file.

* If status is 'No', the buffer maybe not activate. execute plsense-reopen-current-buffer.
* If status is 'Not Found', check syntax error. PlSense can not analyze when syntax error.
* If status is 'Not Found' other than above case, see 'Sync server' section below.
* Otherwise, status maybe 'No' or 'Not Found' despite the finish of analyzing.

Sync server

For a optimized completion/help, it's required that synchronization of context between Emacs and PlSense server.
Normally, it's finished by this extension automatically.
But, it maybe happen that synchronization is failed by some reason and it isn't recovered automatically.
If not show completion/help and show error message continuously, execute the following command.

  • plsense-update-location ... inform Plsense server of current context forcibly.

* If not recovered by the above command, restart PlSense server.

Refresh server

The result of analyzing is gathered on PlSense server with edit buffer on Emacs.
Then, the following maybe happen by running PlSense server over a long time.

  • Increase of quantity of expending memory by PlSense server.
  • If you edit same point in many times, the result of completion/help differ from expectation.

In the case, execute the following command.

  • plsense-server-refresh ... initialize PlSense server and start analyzing the newest source code.

* Restart PlSense server is also OK. But if running task exists, the result is lost.

Restriction

Syntax error

PlSense can not analyze the file that has syntax error.
It means the following.

  • The buffer is not active when open the file that has syntax error.
  • The result of completion/help is not updated when save the file that has syntax error.

* For checking syntax error, execute perl -c /path/to/file on shell.

Development in project tree

If you develop in project tree which has particular library for the project, need to make ProjectInfoFile.

Type inference

PlSense do the type inference by analyzing a source code of Perl.
But, it maybe happen the type inference is failed because Perl has a lot of grammar.
In the above case, a optimized completion/help is not provided.
For detail, see https://github.com/aki2o/plsense/wiki/TypeInference.

* If perl-completion.el is available, Instead provides a completion using perl-completion.el.

Optimize completion/help

Analyzing is started from current buffer recursively in sequence.
It like the following.

CurrentBuffer A => A's UseModule B => B's UseModule C ...

Provision of completion/help is started when finished analyze current buffer.
But, analyzing continue in the background like the above.
It means that a few minutes is required for the result of completion/help is optimized.
It apply when you open/edit/save buffer.

The result of analyzing is saved and used until the file is changed.
So, If finish the all analyzing, provision of a optimized completion/help is started soon.

About the time required for the all analyzing is finished, see https://github.com/aki2o/plsense/wiki/Resource.

I guess that the Emacs action become sluggish while a many tasks is running.
If you notice it, you can show the task by plsense-server-task.

Reflect the result of editing buffer

I think the best way is that analyzing is done for latest content of buffer when user require completion/help.
But, the way is high cost.
So, do analyzing at the other timing for high-performance.
If you use plsense-config-default, the timing is when the following command is executed.

  • save-buffer
  • newline
  • newline-and-indent
  • yank
  • yas/commit-snippet

* There are two type of Analyzing, simplified/complete.
* In the above case, Analyzing is simplified at the timing other than save-buffer.

About analyzing in editing buffer

  • A simplified analyzing is low cost. But the following item is not reflect.
    • imported method/variable by use statement
  • You can do a complete analyzing by executing plsense-update-current-buffer.
  • You can do a simplified analyzing by executing plsense--add-pointed-source.
  • You can add the timing of a simplified analyzing by using plsense-server-sync-trigger-ize.
  • If you want to change the analyzing timing, see help of them and definition of plsense-config-default.

Content of help

Picking up the Variable/Method help from PerlDoc maybe failed.
In the case, show the help of module that the Variable/Method belong to.

Tested On

  • Emacs ... GNU Emacs 23.3.1 (i386-mingw-nt5.1.2600) of 2011-08-15 on GNUPACK
  • auto-complete.el ... 1.4.0
  • log4e.el ... 0.1
  • yaxception.el ... 0.1

Enjoy!!!

emacs-plsense's People

Contributors

aki2o avatar

Stargazers

Viacheslav K. avatar Edgar Gonzàlez i Pellicer avatar Thomas Jacob Trabue avatar Corwin avatar Yun Pan avatar chens avatar Alex Larsen avatar Ashton Wiersdorf avatar Alex Ghoth avatar Troy Hinckley avatar asthman avatar  avatar Christopher Ritsen avatar Angus H. avatar  avatar Elias Alves Moura avatar Ștefan Suciu avatar Håkon Hægland avatar Zak B. Elep avatar Itsuki Hayashi avatar Jack Killilea avatar ashizawa avatar L W avatar Will Jones avatar vividsnow avatar Naohiro Oogata avatar K-talo Miyazaki avatar Iku Iwasa avatar chinaxing avatar

Watchers

 avatar James Cloos avatar  avatar Chenggang Zhou avatar  avatar  avatar

emacs-plsense's Issues

Great Tool, but need help using it

I know your English is not good. But my emacs is not good. I need more help getting started. I can use it but not automatically. I have to manually start 'plsense-server-start' and 'plsense-setup-current-buffer'. How to automatically use it when opening a perl file?

P.S.

Do you play Go (igo) on kgs, igs, or ogs? I'm looking for friends to play igo with.

chmod +x bin/*

The tests fail on unix systems, because only on windows the binaries can be executed without the x permission bit.

Documentation is not displayed more than one time

If the auto-complete pops up and the documentation for the symbol is shown everything works fine. But if I move to another off of the symbol the "w" disappears and the documentation will not be shown again if I move again on it.

I traced the source of this issue to this line (l. 753)

        (set-text-properties 0 (string-width selected) nil selected) 

If commented out everything is working okay. I am not quite sure why this line is needed.

plsense-buffer-is-ready returns "Not Found"

with some buffers (and not with others) when I run plsense-setup-current-buffer I will see that it is loading. But then we I try to check if it is ready by calling plsense-buffer-is-ready it just echo's Not Found with no other information. plsense-reopen-current-buffer and plsense-update-current-buffer don't fix the problem. The server is running and the tasks are fine. How can I find the source of this issue?

Emacs hangs after typing M-x plsense-server-start

Hello,

After typing M-x plsense-server-start, Emacs doesn't respond anymore: I tried to reset my iptables configuration but the same problem occurs always. This is the error message:

[PLSENSE] Start server ...
[PLSENSE] Start server is failed.
command-execute: Buffer is read-only: #<buffer Messages>

How to solve this issue?

Thanks in advance.

M-x plsense-server-start fails

Hi

M-x plsense-server-start 

fails and I get "Start server is failed"
(however, after launching plsense server manually from the terminal by executing plsense serverstart
M-x plsense-reopen-current-buffer succeeds, and seems like plsense is working properly)

Do I need any extra settings (such as appending an entry to exec-path) besides the setting on "Configuration" section on https://github.com/aki2o/emacs-plsense/blob/master/README.md

I greatly appreciate your response.

When popup completion by auto-complete.el, the candidate help is not shown

When I write some characters in perl buffer, completion is shown by auto-complete.el.
Then, I select the candidate moving up/down.
But the candidate help is not shown at the side of the candidate.

This issue happen in the following environment.

  • Ubuntu 12.04
  • GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2) of 2013-08-22 on chindi02, modified by Debian

Also, This issue don't happen in the following environment.

  • Windows XP SP3
  • Emacs 24.2.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.