Closed saintaugustinus closed 11 years ago
I can't help you with such a description. Please read https://github.com/capitaomorte/yasnippet#important-note-regarding-bug-reporting and post a better description. I'll reopen the issue when I can reproduce it.
I have do my best to describe the problem perspective, Please take a look! Thank You!
Thanks, nice description, and I've just reproduced it! Will reply back when I have a fix.
I have the same problem. I have Emacs 24.3.1 installed on my fedora 19 x86_64. This really annoys me a lot recently. Please fix it. Thank you
I have had the same problem for a long time. Looking forward to fixing it. Thanks.
I have the same problem now. I am using ac-source-yasnippet in auto-complete.
I also have similar problems for c/c++ mode; and it seems the problem of the major mode?
FYI, the *Backtrace*
displays the messages below when such error occurs with debug turned on:
Debugger entered--Lisp error: (args-out-of-range 1 2)
remove-text-properties(#<marker at 1 in test.cpp> 2 (category nil))
c-invalidate-state-cache(22)
c-before-change(22 22)
yas-expand-snippet("int main(void) {\n $0\n return 0;\n}\n" 22 26 nil)
yas--expand-or-prompt-for-template((("int main(void) { ... }" . [cl-struct-yas--template "main" "int main(void) {\n $0\n return 0;\n}\n" "int main(void) { ... }" nil nil "/home/$
ad-Orig-yas-expand(nil)
yas/expand()
ac-complete-1(#("main" 0 4 (selection-face ac-yasnippet-selection-face popup-face ac-yasnippet-candidate-face symbol "a" action yas/expand)))
ac-complete()
ad-Orig-call-interactively(ac-complete nil nil)
call-interactively(ac-complete nil nil)
@capitaomorte I guess this is a workaround which doesn't solve the problem itself.
Setting inhibit-modification-hooks
to nil invalids before-change-functions
and after-change-functions
, whose values are
(c-before-change t syntax-ppss-flush-cache) and (c-after-change jit-lock-after-change t) respectively for my C/C++-mode. Although AFAIK they are mostly doing some trivial font-lock changes, I'd prefer to keep them work as usual since it MIGHT be useful for other modes.
Sorry that I only know it is c-invalidate-state-cache
that causes the problem but I don't know the exact root cause.
Maybe there is a need to report this bug to Emacs core developers.
What about avoiding the narrowing instead? As in 51e9e8e.
This is tricky, indeed and @HongxuChen is quite right, this is a workaround.
@npostavs: maybe that commit fixes it, and if you make a pull request with tests for middle-of-the-buffer snippet insertion, I will merge it.
The preferred solution, though, is to completely change the way yasnippet parses the template content at expansion time. To this effect, there is a new branch "snippet-engine" where I am distilling the yasnippet expansion engine into a new snippet.el, which might possibly make it into emacs proper. The new engine has many developer-friendly features like the capability to edebug the resulting snippet-insertion function.
Yasnippet should rather use those macros. Naturally, this isn't a trivial effort, but is clearly the way to to solve most of the problems associated with escaping, indentation, narrowing. Have a look at it when you find the time.
I updated my previous comment, which I posted inadvertently before I meant to do so.
Same problems and Same *Backtrace*
as @HongxuChen .
The second time I try to expand main
snippet in c/c++ mode, it goes quite well. Weird problem.
@xiaohanyu: which version are you running?
Emacs version: GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4) of 2013-10-03 on louvi, modified by Debian.
Yasnippet: 32ee5cbde5313985c889d1e4bfd6d7d836f4ca3d
Yasnippet: 32ee5cb
Hmm, I can definitely reproduce back at d963c41, but not at current master (32ee5cb). Is it possible you have stale elc files?
Hi, @npostavs
I use the following .emacs
with a vanilla Emacs to install yasnippet via el-get, and I reproduce the same problem:
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch
el-get-install-skip-emacswiki-recipes)
(goto-char (point-max))
(eval-print-last-sexp))))
;; enable git shallow clone to save time and bandwidth
(setq el-get-git-shallow-clone t)
(defun ome-install (el-get-package)
"Add EL-GET-PACKAGE to `el-get-sources'.
This package will be installed when `ome-load'. Users can make
his own customization by providing a \"ome-package-name-setup\"
function."
(let ((ome-package-setup-func
(intern
(concat "ome-"
(el-get-as-string el-get-package)
"-setup"))))
(if (fboundp ome-package-setup-func)
(add-to-list 'el-get-sources
`(:name ,el-get-package
:after (progn
(,ome-package-setup-func))))
(add-to-list 'el-get-sources
`(:name ,el-get-package)))))
(setq debug-on-error t)
(defun ome-yasnippet-setup ()
(yas-reload-all)
(add-hook 'prog-mode-hook
'(lambda ()
(yas-minor-mode))))
(ome-install 'yasnippet)
(el-get 'sync (mapcar 'el-get-source-name el-get-sources))
The Backtrace buffer:
Debugger entered--Lisp error: (args-out-of-range 1 2)
remove-text-properties(#<marker at 1 in cc5.c> 2 (category nil))
c-invalidate-state-cache(60)
c-before-change(60 62)
delete-region(60 #<marker at 62 in cc5.c>)
(lambda (reg) (delete-region (car reg) (cdr reg)))((60 . #<marker at 62 in cc5.c>))
mapc((lambda (reg) (delete-region (car reg) (cdr reg))) ((60 . #<marker at 62 in cc5.c>)))
yas--delete-regions(((60 . #<marker at 62 in cc5.c>)))
(let ((parse-start (point))) (setq yas--dollar-regions nil) (yas--protect-escapes nil (quote (96))) (goto-char parse-start) (yas--save-backquotes) (yas--protect-escapes) (goto-char parse-start) (yas--field-parse-create snippet) (goto-char parse-start) (yas--simple-mirror-parse-create snippet) (goto-char parse-start) (yas--transform-mirror-parse-create snippet) (yas--calculate-adjacencies snippet) (yas--delete-regions yas--dollar-regions) (yas--restore-backquotes) (goto-char parse-start) (yas--restore-escapes) (yas--update-mirrors snippet) (goto-char parse-start) (yas--indent snippet))
yas--snippet-parse-create([cl-struct-yas--snippet nil [cl-struct-yas--exit #<marker at 62 in cc5.c> nil] 1 nil nil nil nil])
(let ((snippet (progn (vector (quote cl-struct-yas--snippet) (quote nil) nil (yas--snippet-next-id) nil nil nil nil)))) (goto-char begin) (yas--snippet-parse-create snippet) (yas--snippet-sort-fields snippet) (progn (or (and (vectorp snippet) (>= (length snippet) 8) (memq (aref snippet 0) cl-struct-yas--snippet-tags)) (error "%s accessing a non-%s" (quote yas--snippet-control-overlay) (quote yas--snippet))) (let* ((v snippet)) (aset v 4 (yas--make-control-overlay snippet (point-min) (point-max))))) (goto-char (point-max)) snippet)
(save-restriction (narrow-to-region begin end) (let ((snippet (progn (vector (quote cl-struct-yas--snippet) (quote nil) nil (yas--snippet-next-id) nil nil nil nil)))) (goto-char begin) (yas--snippet-parse-create snippet) (yas--snippet-sort-fields snippet) (progn (or (and (vectorp snippet) (>= (length snippet) 8) (memq (aref snippet 0) cl-struct-yas--snippet-tags)) (error "%s accessing a non-%s" (quote yas--snippet-control-overlay) (quote yas--snippet))) (let* ((v snippet)) (aset v 4 (yas--make-control-overlay snippet (point-min) (point-max))))) (goto-char (point-max)) snippet))
yas--snippet-create(21 78)
(if expand-env (eval (cons (quote let*) (cons expand-env (quote ((insert content) (yas--snippet-create start (point))))))) (insert content) (yas--snippet-create start (point)))
(setq snippet (if expand-env (eval (cons (quote let*) (cons expand-env (quote ((insert content) (yas--snippet-create start ...)))))) (insert content) (yas--snippet-create start (point))))
(let ((yas--inhibit-overlay-hooks t)) (setq snippet (if expand-env (eval (cons (quote let*) (cons expand-env (quote (... ...))))) (insert content) (yas--snippet-create start (point)))))
(let ((buffer-undo-list t)) (setq yas--start-column (current-column)) (let ((yas--inhibit-overlay-hooks t)) (setq snippet (if expand-env (eval (cons (quote let*) (cons expand-env (quote ...)))) (insert content) (yas--snippet-create start (point))))))
(cond ((listp content) (yas--eval-lisp-no-saves content)) (t (let ((buffer-undo-list t)) (setq yas--start-column (current-column)) (let ((yas--inhibit-overlay-hooks t)) (setq snippet (if expand-env (eval (cons ... ...)) (insert content) (yas--snippet-create start (point)))))) (let ((existing-field (and yas--active-field-overlay (overlay-buffer yas--active-field-overlay) (overlay-get yas--active-field-overlay (quote yas--field))))) (if existing-field (progn (progn (or (and ... ... ...) (error "%s accessing a non-%s" ... ...)) (let* (...) (aset v 6 existing-field))) (yas--advance-end-maybe existing-field (overlay-end yas--active-field-overlay))))) (if (progn (or (and (vectorp snippet) (>= (length snippet) 8) (memq (aref snippet 0) cl-struct-yas--snippet-tags)) (error "%s accessing a non-%s" (quote yas--snippet-fields) (quote yas--snippet))) (aref snippet 1)) nil (yas-exit-snippet snippet)) (let ((newstart (overlay-start (progn (or ... ...) (aref snippet 4)))) (end (overlay-end (progn (or ... ...) (aref snippet 4))))) (if (< newstart start) (progn (setq buffer-undo-list (cons (cons ... newstart) buffer-undo-list)))) (setq buffer-undo-list (cons (cons newstart end) buffer-undo-list)) (setq buffer-undo-list (cons (list (quote apply) (quote yas--take-care-of-redo) start end snippet) buffer-undo-list))) (let ((first-field (car (progn (or ... ...) (aref snippet 1))))) (if first-field (progn (sit-for 0) (yas--move-to-field snippet first-field)))) (yas--message 3 "snippet expanded.") t))
(let* ((yas-selected-text (or yas-selected-text (and (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end))))) (start (or start (and (region-active-p) (region-beginning)) (point))) (end (or end (and (region-active-p) (region-end)) (point))) (to-delete (and start end (buffer-substring-no-properties start end))) snippet) (goto-char start) (setq yas--indent-original-column (current-column)) (if (and to-delete (> end start)) (progn (delete-region start end))) (cond ((listp content) (yas--eval-lisp-no-saves content)) (t (let ((buffer-undo-list t)) (setq yas--start-column (current-column)) (let ((yas--inhibit-overlay-hooks t)) (setq snippet (if expand-env (eval ...) (insert content) (yas--snippet-create start ...))))) (let ((existing-field (and yas--active-field-overlay (overlay-buffer yas--active-field-overlay) (overlay-get yas--active-field-overlay ...)))) (if existing-field (progn (progn (or ... ...) (let* ... ...)) (yas--advance-end-maybe existing-field (overlay-end yas--active-field-overlay))))) (if (progn (or (and (vectorp snippet) (>= ... 8) (memq ... cl-struct-yas--snippet-tags)) (error "%s accessing a non-%s" (quote yas--snippet-fields) (quote yas--snippet))) (aref snippet 1)) nil (yas-exit-snippet snippet)) (let ((newstart (overlay-start (progn ... ...))) (end (overlay-end (progn ... ...)))) (if (< newstart start) (progn (setq buffer-undo-list (cons ... buffer-undo-list)))) (setq buffer-undo-list (cons (cons newstart end) buffer-undo-list)) (setq buffer-undo-list (cons (list (quote apply) (quote yas--take-care-of-redo) start end snippet) buffer-undo-list))) (let ((first-field (car (progn ... ...)))) (if first-field (progn (sit-for 0) (yas--move-to-field snippet first-field)))) (yas--message 3 "snippet expanded.") t)))
yas-expand-snippet("int main(int argc, char *argv[])\n{\n $0\n return 0;\n}" 21 25 nil)
(progn (yas-expand-snippet (progn (or (and (vectorp yas--current-template) (>= (length yas--current-template) 13) (memq (aref yas--current-template 0) cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-content) (quote yas--template))) (aref yas--current-template 2)) start end (progn (or (and (vectorp yas--current-template) (>= (length yas--current-template) 13) (memq (aref yas--current-template 0) cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-expand-env) (quote yas--template))) (aref yas--current-template 5))))
(if yas--current-template (progn (yas-expand-snippet (progn (or (and (vectorp yas--current-template) (>= (length yas--current-template) 13) (memq (aref yas--current-template 0) cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-content) (quote yas--template))) (aref yas--current-template 2)) start end (progn (or (and (vectorp yas--current-template) (>= (length yas--current-template) 13) (memq (aref yas--current-template 0) cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-expand-env) (quote yas--template))) (aref yas--current-template 5)))))
(let ((yas--current-template (or (and (rest templates) (yas--prompt-for-template (mapcar (function cdr) templates))) (cdar templates)))) (if yas--current-template (progn (yas-expand-snippet (progn (or (and (vectorp yas--current-template) (>= ... 13) (memq ... cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-content) (quote yas--template))) (aref yas--current-template 2)) start end (progn (or (and (vectorp yas--current-template) (>= ... 13) (memq ... cl-struct-yas--template-tags)) (error "%s accessing a non-%s" (quote yas--template-expand-env) (quote yas--template))) (aref yas--current-template 5))))))
yas--expand-or-prompt-for-template((("int main(argc, argv) { ... }" . [cl-struct-yas--template "main" "int main(int argc, char *argv[])\n{\n $0\n return 0;\n}" "int main(argc, argv) { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/main" nil "int main(argc, argv) { ... }" ((menu-item "int main(argc, argv) { ... }" (lambda nil (interactive) (yas--expand-or-visit-from-menu (quote cc-mode) "int main(argc, argv) { ... }")) :keys "main =>")) nil nil [cl-struct-yas--table "cc-mode" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("struct" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("struct ... { ... }" [cl-struct-yas--template "struct" "struct ${1:name}\n{\n $0\n};" "struct ... { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/struct" nil "struct ... { ... }" (...) nil nil #3] ...)) "once" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("#ifndef XXX; #define XXX; #endif" [cl-struct-yas--template "once" "#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}\n#define $1\n\n$0\n\n#endif /* $1 */" "#ifndef XXX; #define XXX; #endif" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/once" nil "#ifndef XXX; #define XXX; #endif" (...) nil nil #3] ...)) "main" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("int main(argc, argv) { ... }" #2 ...)) "inc" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("#include <...>" [cl-struct-yas--template "inc" "#include <$1>" "#include <...>" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/inc.1" nil "#include <...>" (...) nil nil #3] "#include \"...\"" [cl-struct-yas--template "inc" "#include \"$1\"" "#include \"...\"" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/inc" nil "#include \"...\"" (...) nil nil #3] ...)) "if" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("if (...) { ... }" [cl-struct-yas--template "if" "if (${1:condition})\n{\n $0\n}" "if (...) { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/if" nil "if (...) { ... }" (...) nil nil #3] ...)) "for" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("for (...; ...; ...) { ... }" [cl-struct-yas--template "for" "for (${1:int i = 0}; ${2:i < N}; ${3:++i})\n{\n $0\n}" "for (...; ...; ...) { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/for" nil "for (...; ...; ...) { ... }" (...) nil nil #3] ...)) "do" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("do { ... } while (...)" [cl-struct-yas--template "do" "do\n{\n $0\n} while (${1:condition});" "do { ... } while (...)" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/do" nil "do { ... } while (...)" (...) nil nil #3] ...)) ...)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("struct ... { ... }" [cl-struct-yas--template "struct" "struct ${1:name}\n{\n $0\n};" "struct ... { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/struct" nil "struct ... { ... }" ((menu-item "struct ... { ... }" ... :keys "struct =>")) nil nil #3] "#ifndef XXX; #define XXX; #endif" [cl-struct-yas--template "once" "#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}\n#define $1\n\n$0\n\n#endif /* $1 */" "#ifndef XXX; #define XXX; #endif" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/once" nil "#ifndef XXX; #define XXX; #endif" ((menu-item "#ifndef XXX; #define XXX; #endif" ... :keys "once =>")) nil nil #3] "int main(argc, argv) { ... }" #2 "#include <...>" [cl-struct-yas--template "inc" "#include <$1>" "#include <...>" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/inc.1" nil "#include <...>" ((menu-item "#include <...>" ... :keys "inc =>")) nil nil #3] "#include \"...\"" [cl-struct-yas--template "inc" "#include \"$1\"" "#include \"...\"" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/inc" nil "#include \"...\"" ((menu-item "#include \"...\"" ... :keys "inc =>")) nil nil #3] "if (...) { ... }" [cl-struct-yas--template "if" "if (${1:condition})\n{\n $0\n}" "if (...) { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/if" nil "if (...) { ... }" ((menu-item "if (...) { ... }" ... :keys "if =>")) nil nil #3] "for (...; ...; ...) { ... }" [cl-struct-yas--template "for" "for (${1:int i = 0}; ${2:i < N}; ${3:++i})\n{\n $0\n}" "for (...; ...; ...) { ... }" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/for" nil "for (...; ...; ...) { ... }" ((menu-item "for (...; ...; ...) { ... }" ... :keys "for =>")) nil nil #3] "do { ... } while (...)" [cl-struct-yas--template "do" "do\n{\n $0\n} while (${1:condition});" "do { ... } while (...)" nil nil "/home/test/.emacs.d/el-get/yasnippet/snippets/cc-mode/do" nil "do { ... } while (...)" ((menu-item "do { ... } while (...)" ... :keys "do =>")) nil nil #3] ...)) nil (keymap)]])) 21 25)
(if (and templates-and-pos (first templates-and-pos)) (yas--expand-or-prompt-for-template (first templates-and-pos) (second templates-and-pos) (car (cdr (cdr templates-and-pos)))) (yas--fallback))
(let (templates-and-pos) (if (and yas-expand-only-for-last-commands (not (member last-command yas-expand-only-for-last-commands))) nil (setq templates-and-pos (if field (save-restriction (narrow-to-region (yas--field-start field) (yas--field-end field)) (yas--current-key)) (yas--current-key)))) (if (and templates-and-pos (first templates-and-pos)) (yas--expand-or-prompt-for-template (first templates-and-pos) (second templates-and-pos) (car (cdr (cdr templates-and-pos)))) (yas--fallback)))
yas-expand()
call-interactively(yas-expand nil nil)
My Emacs version is GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4), I'm using Linux Mint 15. And yasnippet version is https://github.com/capitaomorte/yasnippet/commit/84b7e694136f92c5a3d7213294154ade4282ea6d.
Emacs snapshot version "GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4)" has this problems too, in my laptop.
@xiaohanyu, when you install yasnippet via el-get, it not only might fetch an old yasnippet version, but it also caches a version of the elc files. Reproduction recipes based on external tools like el-get (as useful as they are) are therefore ambiguous unless you take special precautions to remove ambiguity.
So make sure, as @npostavs requested, that no stale elc files are present. One way to do this is to clear ~/.emacs.d/el-get/yasnippet/
completely. Then, repeat your process, making sure el-get fetches a new yasnippet version and compiles it. Thirdly, provide also the output of the git log -1
command when run this command in the newly-recreated ~/.emacs.d/el-get/yasnippet
directory.
It would be nicer though, to provide a reproduction recipe when yasnippet is manually cloned from its official upstream, compiled, added to the load-path
, and require
d.
Hi, @capitaomorte
Thanks for your advice. But I'm sure I've removed the old elc files, even use el-get
.
And I also try another method as your said:
First, I cloned yasnippet to $HOME
, then removes the old .emacs
and .emacs.d
. Finally I put the following code in the new .emacs
:
(setq debug-on-error t)
(add-to-list 'load-path
"~/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
But it still has the same problem. weird.
Some of my working environment:
test@xiao-pad:~ > ls -lh .emacs
-rw-rw-r-- 1 test test 119 Oct 29 17:45 .emacs
test@xiao-pad:~ > cat .emacs
(setq debug-on-error t)
(add-to-list 'load-path
"~/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
test@xiao-pad:~ > ls -lh .emacs.d
total 4.0K
drwx------ 2 test test 4.0K Oct 29 17:46 auto-save-list
test@xiao-pad:~ > cd yasnippet/
test@xiao-pad:~/yasnippet > ls
doc extras Rakefile README.mdown snippets yasnippet-debug.el yasnippet.el yasnippet-tests.el
test@xiao-pad:~/yasnippet > git log -1
commit 84b7e694136f92c5a3d7213294154ade4282ea6d
Merge: 32ee5cb 33dff9a
Author: João Távora <joaotavora@gmail.com>
Date: Sat Oct 26 16:37:17 2013 -0700
Merge pull request #423 from npostavs/load-snippet-ui
Improve load snippet ui
test@xiao-pad:~/yasnippet > cd ../
test@xiao-pad:~ > uname -a
Linux xiao-pad 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
test@xiao-pad:~ >
I'll try this in other linux distributions.
I'm testing this under a new virtualbox os and it still has this problem.
vagrant@vagrant-ubuntu-saucy-64:~$ uname -a
Linux vagrant-ubuntu-saucy-64 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
vagrant@vagrant-ubuntu-saucy-64:~$ ls
yasnippet
vagrant@vagrant-ubuntu-saucy-64:~$ ls
yasnippet
vagrant@vagrant-ubuntu-saucy-64:~$ uname -a
Linux vagrant-ubuntu-saucy-64 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
vagrant@vagrant-ubuntu-saucy-64:~$ ls -lh yasnippet/
total 244K
drwxrwxr-x 4 vagrant vagrant 4.0K Oct 29 11:48 doc
drwxrwxr-x 4 vagrant vagrant 4.0K Oct 29 11:48 extras
-rw-rw-r-- 1 vagrant vagrant 2.7K Oct 29 11:48 Rakefile
-rw-rw-r-- 1 vagrant vagrant 6.9K Oct 29 11:48 README.mdown
drwxrwxr-x 25 vagrant vagrant 4.0K Oct 29 11:48 snippets
-rw-rw-r-- 1 vagrant vagrant 5.7K Oct 29 11:48 yasnippet-debug.el
-rw-rw-r-- 1 vagrant vagrant 181K Oct 29 11:48 yasnippet.el
-rw-rw-r-- 1 vagrant vagrant 27K Oct 29 11:48 yasnippet-tests.el
vagrant@vagrant-ubuntu-saucy-64:~$ cd yasnippet/
vagrant@vagrant-ubuntu-saucy-64:~/yasnippet$ git log -1
commit 84b7e694136f92c5a3d7213294154ade4282ea6d
Merge: 32ee5cb 33dff9a
Author: João Távora <joaotavora@gmail.com>
Date: Sat Oct 26 16:37:17 2013 -0700
Merge pull request #423 from npostavs/load-snippet-ui
Improve load snippet ui
vagrant@vagrant-ubuntu-saucy-64:~/yasnippet$ cd ..
vagrant@vagrant-ubuntu-saucy-64:~$ cat .emacs
(setq debug-on-error t)
(add-to-list 'load-path
"~/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
vagrant@vagrant-ubuntu-saucy-64:~$ ls -lh .emacs.d/
total 0
vagrant@vagrant-ubuntu-saucy-64:~$
I managed to reproduce it, this happens in a buffer that is visiting a file, but not in a temp buffer.
this happens in a buffer that is visiting a file, but not in a temp buffer.
Scratch that, it's actually c-mode
vs c++-mode
.
I can reproduce with
emacs -Q -l yasnippet.el -f yas-global-mode --eval '(switch-to-buffer "foo.c")' -f c-mode --eval '(insert "#include <iostream>\nmain")' -f yas-expand
@capitaomorte: I'm not managing to turn this into an ert
test.
@xiaohanyu: try d7b2b89 (the widen branch), passes the above test.
Hi, @npostavs
Thanks for you patch https://github.com/capitaomorte/yasnippet/commit/d7b2b89, it passed on my machine.
I can reproduce with
emacs -Q -l yasnippet.el -f yas-global-mode --eval '(switch-to-buffer "foo.c")' -f c-mode --eval '(insert "#include <iostream>\nmain")' -f yas-expand
@capitaomorte: I'm not managing to turn this into anert
test.
I added an "external" test to yasnippet-tests.el, have a look. Stragely it doesn't fail when "--batch" is passed to the external emacs.
@xiaohanyu: try d7b2b89 (the [widen branch][widen]), passes the above test.
Thanks. I've tried this and merged it onto the mainline.
It works! Thanks!
OK, As your request I try to describe the question as perspective as I can. I tried to start emacs with a clean .emacs.
Here is my .emacs: (add-to-list 'load-path "~/.emacs.d/site-lisp/site/yasnippet/") (require 'yasnippet) (yas-global-mode 1)
Now I try to create a new buffer to write C++ code. The buffer is empty! First I type 'inc' at the beginning of the buffer and use yasnippet to expand it, yas works well! Second I try to use expand the word 'main' in the next line(There is nothing else bettwen two lines), the word 'main' disappears and a mesg "Args out of range: 1, 2" shows in the mini-buffer. Thirdly I try to use yasnippet to expand 'main' again, it works again! And after that Yasnippet do not have unexpectable effects anymore!
Here is the snapshots: Before pressing 'TAB': After pressing 'TAB':
What's more if I do not use yasnippet at the beginning of the buffer, yasnippet works well and the problem won't come out!
As far as I know the problem just come out in C/C++-mode.Other mode such as text-mode do not have this problem!
Here is my emacs version and what git log -1 shows:
GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.2) of 2013-08-07 on -mnt-storage-buildroots-staging-x86_64-eric
commit 78c52fdf5cc049b8e40c8d693058017de8a53b6f Author: João Távora joaotavora@gmail.com Date: Mon Sep 2 12:01:24 2013 +0100
Thanks!