Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment "would destroy a protection overlay" #784

Closed
ghost opened this issue Mar 2, 2017 · 3 comments
Closed

Comment "would destroy a protection overlay" #784

ghost opened this issue Mar 2, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 2, 2017

The way to reproduce this is by trying to create a comment (see configuration below).

  1. Create c-mode buffer
  2. type co
  3. Hit C-S-i
  4. Write anything with a space

You'll get an x instead of the space, and the message
[yas] Committing snippets. Action would destroy a protection overlay.

My configuration (running emacs -Q):
emacs GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
yasnippet 20170203.626
.emacs (init file)

(require 'package)
(package-initialize)
(require 'yasnippet)
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "C-i") nil)
(define-key yas-minor-mode-map (kbd "C-S-i") 'yas-expand)

(add-hook 'prog-mode-hook 'yas-minor-mode)

(require 'function-args)
(add-hook 'c-mode-common-hook (lambda ()
                                (function-args-mode) ; Find definitions in current buffer
                                (setq tab-width 4) ; set tab width to 4
                                (auto-fill-mode) ; break long lines
                                (yas-minor-mode) ; activate yasnippet
                                ))

I have been told that these are not this bug (but I must admit that my previous report was not great).
#537
#712

@npostavs
Copy link
Collaborator

npostavs commented Mar 2, 2017

The function-args-mode part seems unnecessary, it looks like a bad interaction with auto-fill mode. Hmm, I thought I fixed this in #643, but it seems there is another case.

(require 'yasnippet)
(c-mode)
(auto-fill-mode +1)
(setq debug-on-error t)
(insert "co")
(yas-expand)
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p (3 . #<marker in no buffer>))
  <((3 . #<marker in no buffer>) nil)
  (and fom (< (yas--fom-end fom) newend))
  (cond ((and fom (< (yas--fom-end fom) newend)) (set-marker (yas--fom-end fom) newend) (yas--advance-start-maybe (yas--fom-next fom) newend) (yas--advance-end-of-parents-maybe (yas--fom-parent-field fom) newend)) ((progn nil (and (vectorp fom) (>= (length fom) 3) (memq (aref fom 0) cl-struct-yas--exit-tags) t)) (yas--advance-start-maybe (yas--fom-next fom) newend)))
  yas--advance-end-maybe([cl-struct-yas--field 1 (3 . #<marker in no buffer>) (3 . #<marker in no buffer>) nil ([cl-struct-yas--mirror (3 . #<marker in no buffer>) (5 . #<marker in no buffer>) (unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end))) nil [cl-struct-yas--exit (5 . #<marker in no buffer>) nil] 0] [cl-struct-yas--mirror (1 . #<marker in no buffer>) (3 . #<marker in no buffer>) (yas-trimmed-comment-start) nil #0 0]) nil t [cl-struct-yas--mirror (3 . #<marker in no buffer>) (5 . #<marker in no buffer>) (unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end))) nil [cl-struct-yas--exit (5 . #<marker in no buffer>) nil] 0]] nil)
  (let* nil (when (yas--skip-and-clear-field-p field beg end length) (yas--skip-and-clear field end)) (setf (yas--field-modified-p field) t) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))
  eval((let* nil (when (yas--skip-and-clear-field-p field beg end length) (yas--skip-and-clear field end)) (setf (yas--field-modified-p field) t) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))
  (progn (eval (cons (quote let*) (cons (progn nil (or (progn nil (and ... ... ... t)) (signal (quote wrong-type-argument) (list ... snippet))) (aref snippet 1)) (quote ((when (yas--skip-and-clear-field-p field beg end length) (yas--skip-and-clear field end)) (setf (yas--field-modified-p field) t) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))))))
  (unwind-protect (progn (eval (cons (quote let*) (cons (progn nil (or (progn nil ...) (signal ... ...)) (aref snippet 1)) (quote ((when ... ...) (setf ... t) (yas--advance-end-maybe field ...) (save-excursion ...) (yas--update-mirrors snippet))))))) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn (eval (cons (quote let*) (cons (progn nil (or ... ...) (aref snippet 1)) (quote (... ... ... ... ...)))))) (set-match-data save-match-data-internal (quote evaporate))))
  (let* ((inhibit-modification-hooks t) (field (overlay-get overlay (quote yas--field))) (snippet (overlay-get yas--active-field-overlay (quote yas--snippet)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (eval (cons (quote let*) (cons (progn nil ... ...) (quote ...))))) (set-match-data save-match-data-internal (quote evaporate)))))
  (if (or (not after\?) yas--inhibit-overlay-hooks (not (overlayp yas--active-field-overlay)) (yas--undo-in-progress)) nil (let* ((inhibit-modification-hooks t) (field (overlay-get overlay (quote yas--field))) (snippet (overlay-get yas--active-field-overlay (quote yas--snippet)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (eval (cons (quote let*) (cons ... ...)))) (set-match-data save-match-data-internal (quote evaporate))))))
  yas--on-field-overlay-modification(#<overlay in no buffer> t 3 3 3)
  delete-and-extract-region(3 6)
  c-mask-paragraph(nil t do-auto-fill)
  c-do-auto-fill()
  self-insert-command(1)
  funcall-interactively(self-insert-command 1)
  call-interactively(self-insert-command nil nil)
  command-execute(self-insert-command)

@ghost
Copy link
Author

ghost commented Mar 3, 2017

I can confirm that there is no problem if I turn off auto-fill-mode

@npostavs
Copy link
Collaborator

Should be fixed by #789.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant