1

I'm occasionally writing fanfiction-stories as plain-text files in emacs. It would be great if emacs could add a "header-section" in the beginning of these documents, for example:

Title:
Author:
Chapter:
Series:
Rating:
Email:

Some fields - like Author and Email - could obviously be pre-filled...


How could something like this be accomplished in emacs?

What would be the best way of doing it? Would it be an idea to make a new major-mode - based on text-mode - called fanfic? Or perhaps a new minor-mode (called fanfic) to be used with the text-major-mode? A major/minor-mode could perhaps also set-up a few other things - like fly-spell-mode, auto-fill-mode and a suitable page-width...

For completeness, I'd like to know how such a standard header could be added for:

  • All new files created with emacs (just curious...)
  • All files of a certain type - eg. all .txt-files. (I guess it could be bound to the file-type (.txt) and/or the text-mode in emacs)
  • Files created with a customized major/minor-mode

I've used emacs for a several years, but haven't really dived into customization or elisp much... (why mess with perfection? ;-)

Dan
  • 32,584
  • 6
  • 98
  • 168
  • Did you have a look at [Auto Insert](https://www.emacswiki.org/emacs/AutoInsertMode), or [Yasnippet](https://github.com/joaotavora/yasnippet/blob/master/README.mdown)? – Juancho Jun 20 '16 at 22:19
  • 1
    [EmacsWiki Automatic File Headers](https://www.emacswiki.org/emacs/AutomaticFileHeaders) – Dan Jun 20 '16 at 23:24

0 Answers0