What's new? | Help | Directory | Sign in
Google
smart-snippet
Textmate-like Emacs template extension with smarter behavior
  
  
  
  
    
Search
for
Updated Nov 01, 2007 by pluskid
Labels: Featured, Phase-Support
TipForEscape  
You can use \ to escape a character in snippet

Introduction

You might be in troble with $, for example, you use perl. So you want to escape your $ in snippet.

Details

for example, you want a snippet to expand to

foreach my $key (keys %HASH) {
    $value = $HASH{$key};
    # do something
}

This won't work

(require 'cperl-mode)
(smart-snippet-with-abbrev-tables
(cperl-mode-abbrev-table)
("fh" "foreach my $key (keys %$${HASH}) {
     $>$value = $$${HASH}{$key};
     $>$. # do something 
     }$>"
     'bol?))

You need to escape the first $ :

(cperl-mode-abbrev-table)
("fh" "foreach my $key (keys %$${HASH}) {
     $>$value = \\$$${HASH}{$key};
     $>$. # do something 
     }$>"
     'bol?))

Refer to here for more information about this.


Sign in to add a comment