mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-15 05:53:04 +00:00
fix: respect 80 column rule mostly
This commit is contained in:
parent
3446300c1f
commit
e00c7e2661
62
snippet.el
62
snippet.el
@ -1,4 +1,4 @@
|
|||||||
;;; snippet.el --- yasnippet's snippet engine distilled -*- lexical-binding: t; -*-
|
;;; snippet.el --- yasnippet's engine distilled -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 2013 João Távora
|
;; Copyright (C) 2013 João Távora
|
||||||
|
|
||||||
@ -40,7 +40,8 @@
|
|||||||
(if parent-field-sym
|
(if parent-field-sym
|
||||||
(format "-son-of-%s" parent-field-sym)
|
(format "-son-of-%s" parent-field-sym)
|
||||||
""))))
|
""))))
|
||||||
(defun snippet--form-make-mirror-sym (mirror-name source-field-name &optional parent-field-sym)
|
(defun snippet--form-make-mirror-sym (mirror-name source-field-name
|
||||||
|
&optional parent-field-sym)
|
||||||
(make-symbol (format "mirror-%s-of-%s%s" mirror-name source-field-name
|
(make-symbol (format "mirror-%s-of-%s%s" mirror-name source-field-name
|
||||||
(if parent-field-sym
|
(if parent-field-sym
|
||||||
(format "-son-of-%s" parent-field-sym)
|
(format "-son-of-%s" parent-field-sym)
|
||||||
@ -74,14 +75,17 @@ iterated depth-first, resulting in a flattened list."
|
|||||||
for next-form in (append (rest forms) (list nil))
|
for next-form in (append (rest forms) (list nil))
|
||||||
|
|
||||||
for (sym childrenp) = (cond ((snippet--form-field-p form)
|
for (sym childrenp) = (cond ((snippet--form-field-p form)
|
||||||
(list (snippet--form-make-field-sym (second form)
|
(list (snippet--form-make-field-sym
|
||||||
parent-field-sym)
|
(second form)
|
||||||
|
parent-field-sym)
|
||||||
(listp (third form))))
|
(listp (third form))))
|
||||||
((snippet--form-mirror-p form)
|
((snippet--form-mirror-p form)
|
||||||
(incf snippet--form-mirror-sym-idx)
|
(incf snippet--form-mirror-sym-idx)
|
||||||
(list (snippet--form-make-mirror-sym snippet--form-mirror-sym-idx
|
(list (snippet--form-make-mirror-sym
|
||||||
(second form)
|
snippet--form-mirror-sym-idx
|
||||||
parent-field-sym))))
|
(second form)
|
||||||
|
parent-field-sym))))
|
||||||
|
|
||||||
append (cond (sym
|
append (cond (sym
|
||||||
`((,sym
|
`((,sym
|
||||||
,form
|
,form
|
||||||
@ -158,33 +162,43 @@ I would need these somewhere in the let* form
|
|||||||
(second form-b)))
|
(second form-b)))
|
||||||
do
|
do
|
||||||
(setq source-sym sym-b)
|
(setq source-sym sym-b)
|
||||||
(puthash source-sym (cons sym (gethash source-sym field-mirrors)) field-mirrors))
|
(puthash source-sym
|
||||||
|
(cons sym (gethash source-sym
|
||||||
|
field-mirrors))
|
||||||
|
field-mirrors))
|
||||||
(unless source-sym
|
(unless source-sym
|
||||||
(error "mirror definition %s mentions unknown field" form))
|
(error "mirror %s mentions unknown field"
|
||||||
|
form))
|
||||||
`((,sym (snippet--make-mirror))
|
`((,sym (snippet--make-mirror))
|
||||||
(snippet--init-mirror ,sym
|
(snippet--init-mirror
|
||||||
,source-sym
|
,sym
|
||||||
,(snippet--start-marker-name sym)
|
,source-sym
|
||||||
,(snippet--end-marker-name sym)
|
,(snippet--start-marker-name sym)
|
||||||
,(snippet--transform-lambda (third form) source-sym)
|
,(snippet--end-marker-name sym)
|
||||||
,parent-sym)))))
|
,(snippet--transform-lambda (third form))
|
||||||
|
,parent-sym)))))
|
||||||
;; so that we can now create `snippet--make-field' forms with
|
;; so that we can now create `snippet--make-field' forms with
|
||||||
;; complete lists of mirror symbols.
|
;; complete lists of mirror symbols.
|
||||||
;;
|
;;
|
||||||
(make-field-forms
|
(make-field-forms
|
||||||
(loop with field-tuples = (cl-remove-if-not #'snippet--form-field-p tuples :key #'second)
|
(loop with field-tuples = (cl-remove-if-not #'snippet--form-field-p
|
||||||
|
tuples
|
||||||
|
:key #'second)
|
||||||
for (prev-sym) in (cons nil field-tuples)
|
for (prev-sym) in (cons nil field-tuples)
|
||||||
for (sym form parent-sym) in field-tuples
|
for (sym form parent-sym) in field-tuples
|
||||||
for (next-sym) in (append (rest field-tuples) (list nil))
|
for (next-sym) in (append (rest field-tuples) (list nil))
|
||||||
collect `((,sym (snippet--make-field))
|
collect `((,sym (snippet--make-field))
|
||||||
(snippet--init-field ,sym
|
(snippet--init-field
|
||||||
,(second form)
|
,sym
|
||||||
,(snippet--start-marker-name sym)
|
,(second form)
|
||||||
,(snippet--end-marker-name sym)
|
,(snippet--start-marker-name sym)
|
||||||
,parent-sym
|
,(snippet--end-marker-name sym)
|
||||||
(list ,@(reverse (gethash sym field-mirrors)))
|
,parent-sym
|
||||||
,next-sym
|
(list
|
||||||
,prev-sym)))))
|
,@(reverse
|
||||||
|
(gethash sym field-mirrors)))
|
||||||
|
,next-sym
|
||||||
|
,prev-sym)))))
|
||||||
|
|
||||||
(append make-field-forms
|
(append make-field-forms
|
||||||
make-mirror-forms)))
|
make-mirror-forms)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user