[tech] Emacs cperl-mode auto-insert perl head info

(defvar current-date-time-format "%Y-%m-%d %a %H:%M:%S %Z"
  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defun insert-head-info-myname ()
  "insert the author, current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
       (interactive)
       (insert "#! /usr/bin/env perl\n")
       (insert "use warnings;\nuse strict;\nuse autodie;\n")
       (insert "## Author: ****\n")
       (insert "## Date: ")
       (insert (format-time-string current-date-time-format (current-time)))
       (insert "\n\n")
       )
;;cperl template
(define-auto-insert 'cperl-mode 'insert-head-info-myname)
(add-hook 'find-file-hooks 'auto-insert)

###

emacs 24.2

I am a newbie. : )

--
This paper is original. All rights reserved. Welcome reproduce, please indicate the source and keep this statement!
Title:
Link:
posted @ 2014-04-25 21:54  Dicor  阅读(320)  评论(0编辑  收藏  举报