1

I have configured yasnippet and auto-complete bindings so it won't collide, auto complete uses <tab> and yasnippet uses <backtab>:

(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

;; Remove Yasnippet's default tab key binding
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
;; Set Yasnippet's key binding to shift+tab
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)

I also added yasnippet source like this to the ac-sources as recommended in this question.

(defun add-yasnippet-ac-sources ()
  (add-to-list 'ac-sources 'ac-source-yasnippet))
(add-hook 'web-mode-hook 'add-yasnippet-ac-sources)

I created two yasnippets one with the key lorem_dummy and the other with the key lorem_image, one of the examples:

# -*- mode: snippet; require-final-newline: nil -*-
# name: lorem_image
# key: lorem_image
# binding: direct-keybinding
# --
<img src="http://lorempixel.com/${1:width}/${2:height}/${3:$$(yas-choose-value '("abstract" "city" "animals" "food" "people" "transport" "business" "sports" "technics"))}/${4:text}" alt="$3">

After following the solution in the "duplicated question" link, everything seemed to work perfectly, but then after a few hours it started to behave strange, randomdly, sometimes it works sometimes it doesn't. I made a video showing the problem, it works, then I restart Emacs and stops working again.

VIDEO 1

>UPDATE<

ok, I found out something, it's not that it works randomly, it's just that it simply doesn't works. In that video the auto complete works with the yasnippet keys because they're opened in other buffers, and it's using that. If I close those buffers, they simply stop working. So, the problem is that with this init.el AC it simply doesn't works with yasnippet

VIDEO 2 UPDATE AND COMMENTS

Bae
  • 7,516
  • 5
  • 36
  • 42
Fabman
  • 333
  • 5
  • 20
  • Where did you put your snippet files? – ChrisGPT was on strike May 31 '15 at 19:28
  • I put them in the folders that you see I added in the init.el on the video, `.emacs.d/snippets/snippets` and `.emacs.d/snippets/textmate/snippets`, both they do work if I write manually the whole key, but autocomplete won't auto complete them... – Fabman May 31 '15 at 19:50
  • Like I suggested last time, please see if `ac-sources` actually includes `ac-source-yasnippet`, e.g. via `C-h v ac-sources RET`. – ChrisGPT was on strike May 31 '15 at 20:59
  • This is what I get -- ac-sources is a variable defined in `auto-complete.el'. Its value is (ac-source-yasnippet ac-source-words-in-same-mode-buffers) Local in buffer test_yasnippet.php; global value is (ac-source-words-in-same-mode-buffers) Automatically becomes buffer-local when set. Documentation: Sources for completion. – Fabman May 31 '15 at 21:33
  • [VIDEO WITH THE FULL INFO AND PROBLEM](https://www.youtube.com/watch?v=aB03S39BHro&hd=1) – Fabman Jun 01 '15 at 10:48
  • Fabman, there is no need for all-caps. Please try to put the information from your video into your question itself. Relevant information that is missing from the question is one of the reasons that questions get closed on SO. Nobody should have to leave the site to understand your problem. – ChrisGPT was on strike Jun 01 '15 at 12:18
  • You might also want to try submitting on https://emacs.stackexchange.com/, which might be a better fit for this question. – ChrisGPT was on strike Jun 01 '15 at 12:19

0 Answers0