Skip to content

Commit

Permalink
Draft of calling php-auto-yasnippets on auto-completion
Browse files Browse the repository at this point in the history
It turned out to be surprisingly simple.

...though it does need a lot of cleanup and polishing before it's
suitable for sharing with the world.
  • Loading branch information
NateEag committed Dec 2, 2013
1 parent 8725311 commit f8c1130
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions php-mode-init.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
;; Emacs config for editing PHP.

;; GRIPE Should I get this working, it probably doesn't belong here.
(defun insert-func-and-auto-yasnippet ()
"Insert the selected function name then insert its auto-snippet."
(ac-expand)
;; DEBUG Do we need to handle classes? For the moment, I don't think it's
;; necessary.
(yas/create-php-snippet nil))

(ac-define-source php-auto-yasnippets
;; DEBUG not sure what 'depends' does - it's used in the yasnippet ac source,
;; though, so I just mirrored it blindly.
'((depends yasnippet)
(depends php-auto-yasnippets)
;; DEBUG This will need to change - people will want to customize their
;; list of PHP callables.
(candidates . ac-buffer-dictionary)
(action . insert-func-and-auto-yasnippet)
;; Since these trigger yasnippet, I think it makes sense to use the
;; yasnippet face.
(candidate-face . ac-yasnippet-candidate-face)
(selection-face . ac-yasnippet-selection-face)
;; For 'PHP', and to distinguish from regular yasnippet functions.
(symbol . "p")))

(require 'mmm-auto)
(setq mmm-global-mode 'maybe)

Expand Down Expand Up @@ -47,6 +71,7 @@
(auto-complete-init)
(add-to-list 'ac-sources 'ac-source-dictionary)
(add-to-list 'ac-sources 'ac-source-yasnippet)
(add-to-list 'ac-sources 'ac-source-php-auto-yasnippets)

(require 'php-auto-yasnippets)
(define-key php-mode-map (kbd "C-c C-y") 'yas/create-php-snippet)
Expand Down
6 changes: 3 additions & 3 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
-Fix yasnippet not expanding fields on the first snippet insertion in a PHP
buffer. Only seems to happen on Windows box...

-Get ejmr's php-auto-snippets package working, to save me many lookups of
which order PHP thinks *this* array function's args go in. For this to be
useful, I need to solve its conflict with my existing php-mode snippets.
-Talk to ejmr about how best to provide my php-auto-yasnippets ac-source to the
world at large. I think a lot of people might appreciate it. Maybe just bundle
it in php-auto-yasnippets?

-Teach php-auto-snippets about third-party code. It's pretty feasible to
support an option for requiring files, and maybe setting that per-project via
Expand Down

0 comments on commit f8c1130

Please sign in to comment.