Giter Club home page Giter Club logo

php-auto-yasnippets's People

Contributors

amcorreia avatar bystrano avatar ejmr avatar glynnforrest avatar martango avatar nateeag avatar yasuyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-auto-yasnippets's Issues

Add support for end-user code? [idea]

I was thinking it might be useful to add support for snippets for end-user functions/methods.

Maybe something like:

  • Add a --require_once option to Create-PHP-Yasnippet.php that calls require_once for the passed path. It could be specified multiple times.
  • Add a list php-auto-yasnippet-requires (or something along those lines) to the elisp package, defaulting it to the empty list. Every path in it is passed to the PHP script via the new --require_once option.

Users could use .dir-locals (or other mechanisms) to set the php-auto-yasnippet-requires list for a given project.

A lot of modern PHP projects rely on autoloads, and even the ones that don't usually have some "include all the things" option, so this should be fairly usable in practice.

I verified that adding a require_once does let the code work with user code.

Does this sound like a worthwhile addition? If I got this working, do you think you'd merge it?

Error with payas/ac-setup

When I add (payas/ac-setup) to my config, I get:

Debugger entered--Lisp error: (void-variable php-auto-yasnippets)
  payas/ac-setup()
  eval((payas/ac-setup) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

Is this working for others?

Restrict payas/remove-extra-whitespace to PHP Mode Snippets

Right now the package sets payas/remove-extra-whitespace as a hook to run after expanding any snippet. That can cause problems with snippets written for other modes since the function expects to only ever deal with PHP code. Instead of being a global hook payas/remove-extra-whitespace should be restricted only to PHP Mode snippets.

support ~ for php-auto-yasnippet-php-program

As of 2.1.0 and using php-mode 2.12 the variable php-auto-yasnippet-php-program does not seem expanded (the ~ [tidla] isn't replaced by $HOME).
That brings spurious "Cannot run the program ~/.emacs.d/php/Create-PHP-YASnippet.php"

`Wrong type argument: stringp, nil` while in class method

It looks like somehow, (thing-at-point 'sexp) is returning nil when I call (yas/create-php-snippet) inside a class method. If I bring the cursor out of the method, then the function works correctly.
Is this a problem with thing-at-point or php-auto-yasnippets? (Calling (thing-at-point 'string) is also returning nil).
I'm not sure.

Click for error.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("[ \f	\n
�]+" nil 0)
  split-string(nil)
  payas/create-template(nil)
  payas/define-template(nil)
  yas/create-php-snippet(nil)
  funcall-interactively(yas/create-php-snippet nil)
  call-interactively(yas/create-php-snippet nil nil)
  command-execute(yas/create-php-snippet)

integration with auto-complete

php-auto-yasnippets looks like an awesome package - I'm always forgetting the order of args to PHP's numerous array functions. Thanks very much for writing it.

I took some time this weekend to try it out. It seems to work very nicely, and this coming week at work I'll be trying it out in-depth.

Being a lazy sort, after playing with it a bit, I thought, "It must be possible to auto-trigger the auto-snippets after auto-completing a function name."

After reading some code and playing, I came up with a working prototype. It's just an auto-complete source, based strongly on the yasnippet source that ships with auto-complete.

I tossed a demo video on my webserver if you'd like to see what it looks like.

The prototype code is in my .emacs.d repo.

Is this something you'd be interested in adding to php-auto-yasnippets? If so, what cleanup/improvements would be necessary?

If not, do you have any thoughts on how to make it available to anyone else who's interested?

yas--all-parents: Lisp nesting exceeds `max-lisp-eval-depth'

When loading php-auto-yasnippets with my normal .emacs I get the above errors

  • "backtrace1" below if using M-x yas/create-php-snippet (I get wrong-type-argument stringp nil)
  • "backtrace2" below if using the keybinding (\C-C \C-Y)

But when running :
$ emacs -nw -D -Q --debug-init a.php
(load-file ~/.emacs.d/php-mode.el)
(load-file ~/.emacs.d/dropdown-list.el)
(load-file ~/.emacs.d/yasnippet.el)
(load-file ~/.emacs.d/php-auto-yasnippets.el)
M-: (setq php-auto-yasnippet-php-program "/tmp/Create-PHP-YASnippet.php")
M-: (define-key php-mode-map (kbd "C-c C-y") 'yas/create-php-snippet)

Then going on implode and for the example, putting my cursor after the "i" then M-x yas/create-php-snippet:

  • the status bar says : You can run the command yas/create-php-snippet' with C-c C-y`
  • a newline (nothing else) is inserted between the "i" and the "m"

My hypothesis is that it's not impossible that 2 bugs live here, one about the snippet builder itself (backtrace1) and another one about the interactive/non-interactive function call and empty argument (or something related).

  • backtrace 1 (using M-x yas/create-php-snippet)
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("[ \f    \n
]+" nil 0)
  split-string(nil)
  (let* ((input-chunks (split-string input)) (function-or-method-name (first input-chunks)) (class-name (or (second input-chunks) "")) (args (list php-executable nil (current-buffer) nil php-auto-yasnippet-php-program))) (setq command-args (list function-or-method-name class-name)) (progn (let ((--dolist-tail-- php-auto-yasnippet-required-files) elt) (while --dolist-tail-- (setq elt (car --dolist-tail--)) (setq command-args (cons elt command-args)) (setq command-args (cons "--require-once" command-args)) (setq --dolist-tail-- (cdr --dolist-tail--))) (setq elt nil) command-args)) (setq args (append args command-args)) (apply (quote call-process) args))
  (progn (let* ((input-chunks (split-string input)) (function-or-method-name (first input-chunks)) (class-name (or (second input-chunks) "")) (args (list php-executable nil (current-buffer) nil php-auto-yasnippet-php-program))) (setq command-args (list function-or-method-name class-name)) (progn (let ((--dolist-tail-- php-auto-yasnippet-required-files) elt) (while --dolist-tail-- (setq elt (car --dolist-tail--)) (setq command-args (cons elt command-args)) (setq command-args (cons "--require-once" command-args)) (setq --dolist-tail-- (cdr --dolist-tail--))) (setq elt nil) command-args)) (setq args (append args command-args)) (apply (quote call-process) args)))
  (unwind-protect (progn (let* ((input-chunks (split-string input)) (function-or-method-name (first input-chunks)) (class-name (or (second input-chunks) "")) (args (list php-executable nil (current-buffer) nil php-auto-yasnippet-php-program))) (setq command-args (list function-or-method-name class-name)) (progn (let ((--dolist-tail-- php-auto-yasnippet-required-files) elt) (while --dolist-tail-- (setq elt (car --dolist-tail--)) (setq command-args (cons elt command-args)) (setq command-args (cons "--require-once" command-args)) (setq --dolist-tail-- (cdr --dolist-tail--))) (setq elt nil) command-args)) (setq args (append args command-args)) (apply (quote call-process) args))) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let* ((input-chunks (split-string input)) (function-or-method-name (first input-chunks)) (class-name (or (second input-chunks) "")) (args (list php-executable nil (current-buffer) nil php-auto-yasnippet-php-program))) (setq command-args (list function-or-method-name class-name)) (progn (let ((--dolist-tail-- php-auto-yasnippet-required-files) elt) (while --dolist-tail-- (setq elt ...) (setq command-args ...) (setq command-args ...) (setq --dolist-tail-- ...)) (setq elt nil) command-args)) (setq args (append args command-args)) (apply (quote call-process) args))) (set-match-data save-match-data-internal (quote evaporate))))
  payas/create-template(nil)
  (let ((exit-code (payas/create-template input))) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list (yas--parse-template))))
  (progn (let ((exit-code (payas/create-template input))) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list (yas--parse-template)))))
  (unwind-protect (progn (let ((exit-code (payas/create-template input))) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list (yas--parse-template))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((exit-code (payas/create-template input))) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list (yas--parse-template))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((exit-code (payas/create-template input))) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list (yas--parse-template))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (if (yas--get-template-by-uuid (quote php-mode) input) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((exit-code ...)) (if (/= exit-code 0) (payas/report-error exit-code input)) (yas-define-snippets (quote php-mode) (list ...)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
  payas/define-template(nil)
  (if class (payas/define-template (concat function " " class)) (payas/define-template function))
  (let ((function (thing-at-point (quote symbol))) (class (if prefix (read-from-minibuffer "Class: ")))) (if class (payas/define-template (concat function " " class)) (payas/define-template function)) (setq php-auto-yasnippet-executing t) (yas-expand))
  yas/create-php-snippet(nil)
  call-interactively(yas/create-php-snippet record nil)
  command-execute(yas/create-php-snippet record)
  execute-extended-command(nil "yas/create-php-snippet")
  call-interactively(execute-extended-command nil nil)

Error while configuring user-defined function (composer)

Following the guide for getting user-defined functions via Composer to work. I have created a .dir-locals.el file at the root of the project with the following content.

((php-mode . ((php-auto-yasnippet-required-files (list "~/project/vendor/autoload.php")))))

When I do a M-x yas/create-php-snippet I get the following error.
Wrong type argument: stringp, (list "~/project/vendor/autoload.php")

Probably a syntax error, any ideas?

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.