an emacs macro

(defun guard ()
  "http://en.wikipedia.org/wiki/Include_guard"
  (interactive)
  (if (buffer-file-name)
      (let ((macro-name
         (concat
          (upcase
           (file-name-sans-extension
        (file-name-nondirectory
         (buffer-file-name))))
          "_H")))
    (save-excursion
      (goto-char (point-min))
      (insert
       (concat
        "#ifndef "
        macro-name
        "\n#define "
        macro-name
        "\n"))
      (goto-char (point-max))
      (insert
       (concat
        "\n#endif /* "
        macro-name
        " */\n"))))))