Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8107219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:41:44+00:00 2026-06-06T00:41:44+00:00

I am using Emacs to write XHTML pages in a JSF project and the

  • 0

I am using Emacs to write XHTML pages in a JSF project and the amount of boilerplate code that has to go at the header of each XHTML file is hard-to-type, ugly and error-prone. E.g:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">

What would be the “emacs way” of dealing with this? I ‘ve read about the nXhtml mode but haven’t tried it and don’t know if it auto-completes boilerplate like the above or just offers more rudimentary XML checking / completion syntax. At any rate I would like to evaluate more lightweight alternatives first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:41:46+00:00Added an answer on June 6, 2026 at 12:41 am

    search for “template emacs”. https://www.google.com/search?q=template+engine+emacs

    here’s a good survey: http://www.emacswiki.org/emacs/CategoryTemplates .

    I use defaultcontent.el, which is one of the options listed on that page. Defaultcontent.el fills new files with a template depending on a pattern match on the filename. All .html files can get a particular template. You can do more advanced mapping of templates to files; defaultcontent.el uses an alist and you can specify any regex for the filename you like.

    The template that gets placed into the new file can expand various things dynamically, including the filename, basefilename, date/time, environment variables. In more advanced scenarios the template can run elisp code that you provide.

    It’s a good companion to yasnippet, which I use for optional pieces of code within a file. For example, my base .htm template (inserted by defaultcontent.el) doesn’t include a script reference for jquery. But I have a yasnippet for jquery , so that when I type (jquery[TAB]), I get the full expansion of

    <script type='text/javascript'
            src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js'>
    </script>
    

    defaultcontent.el uses find-file-hooks and inserts template contents only when a file is initially created.

    I use it for virtually all file formats.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using emacs and auctex to write LaTeX documents. For some reason, M-e doesn't
So I wrote the following code in linux(Ubuntu) using the emacs text editor it
I'm trying to write a helloworld with clojure. I'm using leinengen with emacs and
I'm trying to write emacs tools that require sending data to an external process,
Say you write some code like this (using ruby-mode, but I've seen this happen
We are using Emacs on Sun OS 5.9. I wrote the exact same code
I'm using Aspell as a spelling checker for Emacs. I know that, as a
When using emacs for writing erlang source code, I have made the following configuration.
I'm using Emacs on Windows. In my .emacs file, I changed the background and
I'm learning emacs lisp and I'm trying to script using it. I wrote a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.