mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Added yas/substr for convenient mirror transformation
This commit is contained in:
parent
1c0d664d65
commit
acf04d6952
@ -3,6 +3,6 @@
|
||||
class ${1:Name}
|
||||
{
|
||||
public:
|
||||
$1($2);
|
||||
virtual ~$1();
|
||||
${1:$(yas/substr text "[^:]*")}($2);
|
||||
virtual ~${1:$(yas/substr text "[^:]*")}();
|
||||
};
|
14
yasnippet.el
14
yasnippet.el
@ -185,6 +185,20 @@ to expand.
|
||||
YASnippet and call other command bound to `yas/trigger-key'.
|
||||
* 'return-nil means return nil.")
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Utility functions for transformations
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defun yas/substr (str pattern &optional group)
|
||||
"Search PATTERN in STR. If found, the content of group
|
||||
GROUP (default 0) is returned, or else the original STR will be
|
||||
returned."
|
||||
(let ((grp (or group 0)))
|
||||
(save-match-data
|
||||
(if (string-match pattern str)
|
||||
(match-string-no-properties grp str)
|
||||
str))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Internal variables
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user