cannot live without it. I write most of my [[http://www.cfengine.com][CFEngine]] code with
snippets. Some help for Perl and even for org-mode.
Thought about using snippets for shell-mode and eshell-mode?
-
+=ha-autoinsert-yas-expand= copied from Howard Abrams.
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path
"~/.emacs.d/elpa/yasnippet-20150415.244")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
(yas-global-mode 1)
+ (auto-insert-mode 1)
+ (setq auto-insert-directory "~/.emacs.d/templates")
(define-key global-map "\C-cy" 'yas-insert-snippet)
(if (>= emacs-major-version 24)
(add-to-list 'yas-prompt-functions 'yas-shk-helm-prompt))
+ (defun ha-autoinsert-yas-expand()
+ "Replace text in yasnippet template."
+ (yas-expand-snippet (buffer-string) (point-min) (point-max)))
+ (define-auto-insert "\\.sh$" ["default-sh.sh" ha-autoinsert-yas-expand])
+ (define-auto-insert "\\.pl$" ["default-pl.pl" ha-autoinsert-yas-expand])
+
+
#+END_SRC
From http://emacswiki.org/emacs/Yasnippet
#+END_SRC
-* template support
-
-Some default templates for new files are stored in [[templates/]].
-No need to start .pl .sh from scratch.
-
-#+BEGIN_SRC emacs-lisp
- (require 'template)
- (template-initialize)
-#+END_SRC
-
* thesaurus
#+BEGIN_SRC emacs-lisp
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+
+my %params;
+
+=head1 NAME
+
+`( file-name-nondirectory (buffer-file-name))` -
+
+=head1 DESCRIPTION
+
+$0
+
+=head1 SYNOPSIS
+
+=head1 EXAMPLES
+
+=head1 SUBS
+
+=head2 main
+
+=cut
+
+sub main {
+
+ my $result = GetOptions (
+ "help|h" => \$params{help},
+ "verbose|v" => \$params{verbose},
+ "man|m" => \$params{man}
+ );
+
+ if ( $params{man} ) { pod2usage( -verbose => 2 ); }
+
+ if ( ! ( $server ) || $params{help} )
+ {
+ pod2usage(1);
+ }
+
+
+}
+
+main();
+
+=head1 AUTHOR
+
+
+`(user-full-name)` <`user-mail-address`>
+
+=head1 LICENSE
+
+This program is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
--- /dev/null
+#!/bin/${1:sh}
+# ----------------------------------------------------------------------
+# `(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`: $0
+# ----------------------------------------------------------------------
+
+ OPT1="default value" # Setup a default value
+ OPT2=0
+
+ while getopts "d:s" o
+ do case "$o" in
+ d) OPT1="$OPTARG";;
+ s) OPT2=1;;
+ [?]) print >&2 "Usage: \$0 [-s] [-d seplist] file ..."
+ exit 1;;
+ esac
+ done
+ shift $(expr $OPTIND - 1)
+
+# ----------------------------------------------------------------------