* c-forward-sws: Is the code right?
@ 2018-03-27 14:44 zhang cc
2018-03-27 16:41 ` Alan Mackenzie
0 siblings, 1 reply; 12+ messages in thread
From: zhang cc @ 2018-03-27 14:44 UTC (permalink / raw)
To: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 12924 bytes --]
In functon c-forward-sws:
((and c-opt-cpp-prefix
(looking-at c-noise-macro-name-re))
;; Skip over a noise macro.
(goto-char (match-end 1))
(not (eobp)))))
c-noise-macro-name-re’ value is "\\<\\>”, which doesn’t have a group. Then (match-end 1) should always return nil. And (goto-char nil) will signal an error.
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) c-forward-sws() c-unfind-coalesced-tokens(87 92) c-before-change(87 92) delete-region(87 #<marker at 92 in c.cpp>) (if (= (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 2)) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 3))) nil (delete-region (or from (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 2))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 3)))) yas--skip-and-clear(#s(yas--field :number 1 :start #<marker at 86 in c.cpp> :end #<marker at 92 in c.cpp> :parent-field nil :mirrors nil :transform nil :modified-p t :next nil) 87) (progn (yas--skip-and-clear field end)) (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))() funcall((lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))) (let nil (funcall '(lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) eval((let nil (funcall '(lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))))) (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body))))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))) (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body))))))) (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate)) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay)) (let* ((inhibit-modification-hooks nil) (yas--inhibit-overlay-hooks t) (field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay))) (if (or (not after\?) yas--inhibit-overlay-hooks (not (overlayp yas--active-field-overlay)) (not (overlay-buffer overlay)) (yas--undo-in-progress)) nil (let* ((inhibit-modification-hooks nil) (yas--inhibit-overlay-hooks t) (field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay)))) yas--on-field-overlay-modification(#<overlay from 86 to 92 in c.cpp> t 86 87 0) self-insert-command(1) funcall-interactively(self-insert-command 1) call-interactively(self-insert-command nil nil) command-execute(self-insert-command)
[-- Attachment #2: Type: text/html, Size: 14357 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-27 14:44 c-forward-sws: Is the code right? zhang cc
@ 2018-03-27 16:41 ` Alan Mackenzie
2018-03-27 17:15 ` Stefan Monnier
2018-03-28 1:35 ` zhang cc
0 siblings, 2 replies; 12+ messages in thread
From: Alan Mackenzie @ 2018-03-27 16:41 UTC (permalink / raw)
To: zhang cc; +Cc: Emacs developers
Hello, zhang.
On Tue, Mar 27, 2018 at 14:44:43 +0000, zhang cc wrote:
> In functon c-forward-sws:
> ((and c-opt-cpp-prefix
> (looking-at c-noise-macro-name-re))
> ;; Skip over a noise macro.
> (goto-char (match-end 1))
> (not (eobp)))))
> c-noise-macro-name-re’ value is "\\<\\>”, which doesn’t have a group. Then (match-end 1) should always return nil. And (goto-char nil) will signal an error.
The intention is that "\\<\\>" will never match at all, hence that
match-end will never be executed. "\\<" means "beginning of word" and
"\\>" means "end of word". Could there be something in your environment
whereby an end of word might be at the same position as the beginning of
a word? If this is the case, then I will need to come up with an actual
regexp which can never match anything.
Possibly, the bug could lie somewhere else in c-forward-sws.
Is the bug reproducible? If so, could you possibly patch that bit of
code to add (not (equal c-opt-cpp-prefix "\\<\\>")) before the
(looking-at ...) form, and see if that stops the error.
> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) c-forward-sws() c-unfind-coalesced-tokens(87 92) c-before-change(87 92) delete-region(87 #<marker at 92 in c.cpp>) (if (= (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 2)) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 3))) nil (delete-region (or from (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 2))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (aref field 3)))) yas--skip-and-clear(#s(yas--field :number 1 :start #<marker at 86 in c.cpp> :end #<marker at 92 in c.cpp> :parent-field nil :mirrors nil :transform nil :modified-p t :next nil) 87) (progn (yas--skip-and-clear field end)) (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))() funcall((lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))) (let nil (funcall '(lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) eval((let nil (funcall '(lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet))))) (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body))))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))) (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body))))))) (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate)) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay)) (let* ((inhibit-modification-hooks nil) (yas--inhibit-overlay-hooks t) (field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay))) (if (or (not after\?) yas--inhibit-overlay-hooks (not (overlayp yas--active-field-overlay)) (not (overlay-buffer overlay)) (yas--undo-in-progress)) nil (let* ((inhibit-modification-hooks nil) (yas--inhibit-overlay-hooks t) (field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (if (yas--snippet-live-p snippet) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((envvar (progn (or (and (memq (type-of snippet) cl-struct-yas--snippet-tags) t) (signal 'wrong-type-argument (list 'yas--snippet snippet))) (aref snippet 1)))) (progn (let* ((syms (mapcar (function car) envvar)) (vals (mapcar (function (lambda (v-f) (eval (car (cdr v-f))))) envvar)) (body (function (lambda nil (if (yas--skip-and-clear-field-p field beg end length) (progn (yas--skip-and-clear field end))) (progn (or (and (memq (type-of field) cl-struct-yas--field-tags) t) (signal 'wrong-type-argument (list 'yas--field field))) (let* ((v field)) (aset v 7 t))) (yas--advance-end-maybe field (overlay-end overlay)) (save-excursion (yas--field-update-display field)) (yas--update-mirrors snippet)))) (binds nil)) (while syms (setq binds (cons (list (car-safe (prog1 syms (setq syms (cdr syms)))) (list 'quote (car-safe (prog1 vals (setq vals (cdr vals)))))) binds))) (eval (list 'let binds (list 'funcall (list 'quote body)))))))) (set-match-data save-match-data-internal 'evaporate))) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay)))) yas--on-field-overlay-modification(#<overlay from 86 to 92 in c.cpp> t 86 87 0) self-insert-command(1) funcall-interactively(self-insert-command 1) call-interactively(self-insert-command nil nil) command-execute(self-insert-command)
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-27 16:41 ` Alan Mackenzie
@ 2018-03-27 17:15 ` Stefan Monnier
2018-03-28 1:35 ` zhang cc
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2018-03-27 17:15 UTC (permalink / raw)
To: emacs-devel
> a word? If this is the case, then I will need to come up with an actual
> regexp which can never match anything.
I tend to use things like "a\\`" or "\\'a".
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-27 16:41 ` Alan Mackenzie
2018-03-27 17:15 ` Stefan Monnier
@ 2018-03-28 1:35 ` zhang cc
2018-03-28 1:56 ` Noam Postavsky
2018-03-28 19:05 ` Alan Mackenzie
1 sibling, 2 replies; 12+ messages in thread
From: zhang cc @ 2018-03-28 1:35 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 864 bytes --]
The intention is that "\\<\\>" will never match at all, hence that
match-end will never be executed. "\\<" means "beginning of word" and
"\\>" means "end of word". Could there be something in your environment
whereby an end of word might be at the same position as the beginning of
a word? If this is the case, then I will need to come up with an actual
regexp which can never match anything.
It matchs when cursor is between a Chinese char and an ASCII char like “你hao”( cursor before ‘h’).
Is the bug reproducible?
Yes. See https://github.com/joaotavora/yasnippet/issues/923#issuecomment-376569337
If so, could you possibly patch that bit of
code to add (not (equal c-opt-cpp-prefix "\\<\\>")) before the
(looking-at ...) form, and see if that stops the error.
No. the value of c-opt-cpp-prefix printed as "\s *#\s *”.
[-- Attachment #2: Type: text/html, Size: 1902 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-28 1:35 ` zhang cc
@ 2018-03-28 1:56 ` Noam Postavsky
2018-03-28 19:05 ` Alan Mackenzie
1 sibling, 0 replies; 12+ messages in thread
From: Noam Postavsky @ 2018-03-28 1:56 UTC (permalink / raw)
To: zhang cc; +Cc: Alan Mackenzie, Emacs developers
On 27 March 2018 at 21:35, zhang cc <ccsmile2008@outlook.com> wrote:
>
>> Is the bug reproducible?
>
> Yes. See
> https://github.com/joaotavora/yasnippet/issues/923#issuecomment-376569337
A simpler reproduction:
emacs -Q -f c-mode -f toggle-debug-on-error --eval '(insert "\u963Fa")'
DEL
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
c-forward-sws()
c-unfind-coalesced-tokens(147 148)
c-before-change(147 148)
delete-char(-1 nil)
delete-backward-char(1 nil)
backward-delete-char-untabify(1)
c-electric-backspace(nil)
funcall-interactively(c-electric-backspace nil)
call-interactively(c-electric-backspace nil nil)
command-execute(c-electric-backspace)
>> If so, could you possibly patch that bit of
>> code to add (not (equal c-opt-cpp-prefix "\\<\\>")) before the
>> (looking-at ...) form, and see if that stops the error.
>
>
> No. the value of c-opt-cpp-prefix printed as "\s *#\s *”.
I believe you mean: "\\s *#\\s *"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-28 1:35 ` zhang cc
2018-03-28 1:56 ` Noam Postavsky
@ 2018-03-28 19:05 ` Alan Mackenzie
2018-03-29 3:06 ` net june
2018-03-29 10:38 ` Eli Zaretskii
1 sibling, 2 replies; 12+ messages in thread
From: Alan Mackenzie @ 2018-03-28 19:05 UTC (permalink / raw)
To: zhang cc; +Cc: Emacs developers
Hello, Zhang.
On Wed, Mar 28, 2018 at 01:35:55 +0000, zhang cc wrote:
>> The intention is that "\\<\\>" will never match at all, hence that
>> match-end will never be executed. "\\<" means "beginning of word" and
>> "\\>" means "end of word". Could there be something in your environment
>> whereby an end of word might be at the same position as the beginning of
>> a word? If this is the case, then I will need to come up with an actual
>> regexp which can never match anything.
> It matchs when cursor is between a Chinese char and an ASCII char like “你hao”( cursor before ‘h’).
I've committed a fix to master which should fix this bug. Basically,
instead of "\\<\\>" CC Mode now uses Stefan's suggestion of "a\\`".
Unfortunately, it is too late to get this bug fix into Emacs 26.1.
If you are using any version but master, please tell me, and I will send
you a patch to fix the bug in your copy of that version.
Thanks for taking the trouble to report this bug.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-28 19:05 ` Alan Mackenzie
@ 2018-03-29 3:06 ` net june
2018-03-29 10:38 ` Eli Zaretskii
1 sibling, 0 replies; 12+ messages in thread
From: net june @ 2018-03-29 3:06 UTC (permalink / raw)
To: zhang cc, Alan Mackenzie; +Cc: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
I am using emacs 26 and have cherry-picked your commit on master. It seems be fixed.
?取 Outlook for Android<https://aka.ms/ghei36>
________________________________
From: Emacs-devel <emacs-devel-bounces+netjune=outlook.com@gnu.org> on behalf of Alan Mackenzie <acm@muc.de>
Sent: Thursday, March 29, 2018 3:05:18 AM
To: zhang cc
Cc: Emacs developers
Subject: Re: c-forward-sws: Is the code right?
Hello, Zhang.
On Wed, Mar 28, 2018 at 01:35:55 +0000, zhang cc wrote:
>> The intention is that "\\<\\>" will never match at all, hence that
>> match-end will never be executed. "\\<" means "beginning of word" and
>> "\\>" means "end of word". Could there be something in your environment
>> whereby an end of word might be at the same position as the beginning of
>> a word? If this is the case, then I will need to come up with an actual
>> regexp which can never match anything.
> It matchs when cursor is between a Chinese char and an ASCII char like “你hao”( cursor before ‘h’).
I've committed a fix to master which should fix this bug. Basically,
instead of "\\<\\>" CC Mode now uses Stefan's suggestion of "a\\`".
Unfortunately, it is too late to get this bug fix into Emacs 26.1.
If you are using any version but master, please tell me, and I will send
you a patch to fix the bug in your copy of that version.
Thanks for taking the trouble to report this bug.
--
Alan Mackenzie (Nuremberg, Germany).
[-- Attachment #2: Type: text/html, Size: 2761 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-28 19:05 ` Alan Mackenzie
2018-03-29 3:06 ` net june
@ 2018-03-29 10:38 ` Eli Zaretskii
2018-04-02 19:58 ` Alan Mackenzie
1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2018-03-29 10:38 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel, ccsmile2008
> Date: Wed, 28 Mar 2018 19:05:18 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: Emacs developers <emacs-devel@gnu.org>
>
> > It matchs when cursor is between a Chinese char and an ASCII char like “你hao”( cursor before ‘h’).
>
> I've committed a fix to master which should fix this bug. Basically,
> instead of "\\<\\>" CC Mode now uses Stefan's suggestion of "a\\`".
Please comment the use of this everywhere. AFAICS, you have a comment
only in some places. (Maybe it's better to have a (pair of)
defconst(s) with these regexps with some descriptive names, in which
case we need only comment them in one place.)
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-03-29 10:38 ` Eli Zaretskii
@ 2018-04-02 19:58 ` Alan Mackenzie
2018-04-02 23:58 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Alan Mackenzie @ 2018-04-02 19:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel, ccsmile2008
Hello, Eli.
On Thu, Mar 29, 2018 at 13:38:09 +0300, Eli Zaretskii wrote:
> > Date: Wed, 28 Mar 2018 19:05:18 +0000
> > From: Alan Mackenzie <acm@muc.de>
> > Cc: Emacs developers <emacs-devel@gnu.org>
> > > It matchs when cursor is between a Chinese char and an ASCII char like “你hao”( cursor before ‘h’).
> > I've committed a fix to master which should fix this bug. Basically,
> > instead of "\\<\\>" CC Mode now uses Stefan's suggestion of "a\\`".
> Please comment the use of this everywhere. AFAICS, you have a comment
> only in some places. (Maybe it's better to have a (pair of)
> defconst(s) with these regexps with some descriptive names, in which
> case we need only comment them in one place.)
I've just commented these "a\\`"s everywhere, and committed the fixes to
master.
> Thanks.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-04-02 19:58 ` Alan Mackenzie
@ 2018-04-02 23:58 ` Stefan Monnier
2018-04-03 17:13 ` Andy Moreton
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2018-04-02 23:58 UTC (permalink / raw)
To: emacs-devel
> I've just commented these "a\\`"s everywhere, and committed the fixes to
> master.
Maybe we should have a
(defconst empty-regexp "\\`\\'a"
"Regular expression which cannot match anything.")
in subr.el?
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-04-02 23:58 ` Stefan Monnier
@ 2018-04-03 17:13 ` Andy Moreton
2018-04-03 21:03 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Andy Moreton @ 2018-04-03 17:13 UTC (permalink / raw)
To: emacs-devel
On Mon 02 Apr 2018, Stefan Monnier wrote:
>> I've just commented these "a\\`"s everywhere, and committed the fixes to
>> master.
>
> Maybe we should have a
>
> (defconst empty-regexp "\\`\\'a"
> "Regular expression which cannot match anything.")
>
> in subr.el?
Perhaps "nomatch-regexp" would be a better name ? There are several
regexp constructs that match an empty string, rather than failing to
match anything.
AndyM
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: c-forward-sws: Is the code right?
2018-04-03 17:13 ` Andy Moreton
@ 2018-04-03 21:03 ` Stefan Monnier
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2018-04-03 21:03 UTC (permalink / raw)
To: emacs-devel
>>> I've just commented these "a\\`"s everywhere, and committed the fixes to
>>> master.
>> Maybe we should have a
>>
>> (defconst empty-regexp "\\`\\'a"
>> "Regular expression which cannot match anything.")
>>
>> in subr.el?
> Perhaps "nomatch-regexp" would be a better name ? There are several
> regexp constructs that match an empty string, rather than failing to
> match anything.
Right, I was thinking of regexps in the mathematical sense where they
describe a "set of strings", hence the "nomatch" regexp corresponds to
an "empty" regexp. IIRC Brzozovski used ∅ for this empty regexp and
ε for the regexp which matches the empty string.
"nomatch" would be less confusing, indeed.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-04-03 21:03 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27 14:44 c-forward-sws: Is the code right? zhang cc
2018-03-27 16:41 ` Alan Mackenzie
2018-03-27 17:15 ` Stefan Monnier
2018-03-28 1:35 ` zhang cc
2018-03-28 1:56 ` Noam Postavsky
2018-03-28 19:05 ` Alan Mackenzie
2018-03-29 3:06 ` net june
2018-03-29 10:38 ` Eli Zaretskii
2018-04-02 19:58 ` Alan Mackenzie
2018-04-02 23:58 ` Stefan Monnier
2018-04-03 17:13 ` Andy Moreton
2018-04-03 21:03 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).