I customized my own header and want it to be inserted between the second and the third line of the document. Unfortunately I'm not very used to Lisp, therefore I have a hard time trying to find the corresponding lines in header2.el. Any ideas on how to proceed?

1 Answer 1


As the Commentary of header2.el says:

;; To have Emacs update file headers automatically whenever you save a
;; file, put this in your init file (~/.emacs):
;;   (autoload 'auto-update-file-header "header2")
;;   (add-hook 'write-file-hooks 'auto-update-file-header)
;; To have Emacs add a file header whenever you create a new file in
;; some mode, put this in your init file (~/.emacs):
;;   (autoload 'auto-make-header "header2")
;;   (add-hook 'emacs-lisp-mode-hook 'auto-make-header)
;;   (add-hook 'c-mode-common-hook   'auto-make-header)

If you want the header to contain two lines of your choice as its first two lines then just define a function that inserts those two lines, and put that function at the beginning of option make-header-hook. E.g.:

(defun insert-my-first-two-lines ()
  (insert "MY FIRST LINE")
  (insert "MY SECOND LINE"))

M-x customize-option make-header-hook

Click INS in Customize at the beginning of the default value of make-header-hook, to insert insert-my-first-two-lines:

INS DEL insert-my-first-two-lines

Save your customization.

Automatic updating of the header, by update-file-header, will do nothing to those first two lines (which I guess is what you want). It changes only lines for which you have defined an updating action using register-file-header-action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.