yasnippet Emacs के लिए टेक्स्टमैट के स्निपेट वाक्यविन्यास का विशेष रूप से अच्छा कार्यान्वयन है। इसके साथ आप टेक्स्टमेट के सभी स्निपेट आयात कर सकते हैं। ठीक है यह मेरा इस फिक्सिंग करने का अंतिम प्रयास है (यह Textmate के संस्करण की तरह ठीक है यह भी एक के बाद पात्रों पर ध्यान नहीं देता: यदि आप यह तो स्थापित कर लेते हैं, यह स्निपेट कि मैंने लिखा आप क्या चाहते हैं करना चाहिए:
(defun wrap-region-or-point-with-html-tag (start end)
"Wraps the selected text or the point with a tag"
(interactive "r")
(let (string)
(if mark-active
(list (setq string (buffer-substring start end))
(delete-region start end)))
(yas/expand-snippet (point)
(point)
(concat "<${1:p}>" string "$0</${1:$(replace-regexp-in-string \" .*\" \"\" text)}>"))))
(global-set-key (kbd "C-W") 'wrap-region-or-point-with-html-tag)
संपादित करें।। अंत टैग में स्थान)
क्षमा करें मैं आपके प्रश्न को गलत तरीके से पढ़ता हूं। इस समारोह को क्षेत्र में प्रत्येक पंक्ति को संपादित करना चाहिए।
(defun wrap-lines-in-region-with-html-tag (start end)
"Wraps the selected text or the point with a tag"
(interactive "r")
(let (string)
(if mark-active
(list (setq string (buffer-substring start end))
(delete-region start end)))
(yas/expand-snippet
(replace-regexp-in-string "\\(<$1>\\).*\\'" "<${1:p}>"
(mapconcat
(lambda (line) (format "%s" line))
(mapcar
(lambda (match) (concat "<$1>" match "</${1:$(replace-regexp-in-string \" .*\" \"\" text)}>"))
(split-string string "[\r\n]")) "\n") t nil 1) (point) (point))))