Insert a comment with username and date in emacs

November 8, 2007

Submitted by: Fahdos

Category: Computers

151 views

Add the following to your .emacs file:

;; insert a comment w/ name and date
(defun insert-comment ()
  (interactive)
  (comment-dwim "")
  (insert-string "!!! ")
  (insert-string (getenv "USER"))
  (insert (format-time-string " %Y%m%d: ")))

To use it, just type “M-x insert-comment“.
If it’s too much work for you, you can add a shortcut for it, again, in your .emacs, after the insert-comment definition, add the following:

(global-set-key "C-xv" 'insert-comment)

Now you can insert your comment with just “C-x v

If you liked this, please share it at your favorite sites:
  • Digg
  • Reddit
  • del.icio.us
  • Wikio
  • Facebook
  • Google
  • Technorati
  • TwitThis
  • MySpace
  • N4G
  • NewsVine
  • StumbleUpon
  • BlogMemes
  • Blogsvine
  • blogtercimlap
  • description
  • eKudos
  • Faves
  • Fleck
  • Scoopeo
  • Socialogs
  • Upnews
  • Yigg
  • E-mail this story to a friend!
  • Mixx

Leave a Reply

:D :) :cry: :( 8O :twisted: :!: :vangry: :XO: :up: ;) :mrgreen: :halo: :kiss: :roll: :? 8) :evil: :oops: :| :?: :x :$: more »