8
$\begingroup$

At the top of the .m file which is automatically generated from initialization cells in a notebook there appears a header:

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
...

Is there any way to suppress generating this header?

$\endgroup$
3
  • 2
    $\begingroup$ Welcome to Mathematica.SE! Could you take a moment and change your username to something easier to remember than the auto-generated one? I am not aware of any method to suppress that header, so you may want to simply post-process the file. Let's see if you'll get any definite answers. $\endgroup$
    – Szabolcs
    Sep 10 '13 at 18:43
  • 1
    $\begingroup$ Any specific reason why you would want this? Normally an automatically generated initialization package will be rewritten every time its parent is saved (and any changes you made will be lost). The header is a good warning for this. If you would want to manually write code in a copy of such a file removing the code block wouldn't take too much effort. $\endgroup$ Sep 10 '13 at 19:36
  • $\begingroup$ Use Wolfram Workbench for programming. Then you do not get that header and you have a ton of other improvements (like multiple undo, better code formatting, less crashes etc.). $\endgroup$ Sep 10 '13 at 20:49
11
$\begingroup$

The information for the header appears to be stored in the file:

\SystemFiles\FrontEnd\TextResources\FileHeaders.tr

Which includes:

@@resource PackageHeader
(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)

et cetera.

You should of course make careful backups before modifying a system file, but I expect that deleting the lines following @@resource PackageHeader or replacing them with a single blank line would suppress inclusion of this header in generated packages.

$\endgroup$
2
  • 2
    $\begingroup$ A quick note on this: if you don't want to modify the system file, you can create you own copy of FileHeaders.tr in the $UserBaseDirectory\SystemFiles\FrontEnd\TextResources directory (create it if it doesn't exist) and modify that. The settings defined in $UserBaseDirectory are user-specific and supersede the default system settings. To recover the default behavior, simply delete or rename the file. $\endgroup$
    – Virgil
    Oct 20 '16 at 15:27
  • $\begingroup$ @Virgil Good point. I hadn't tested that but I am glad to know it works. I have recommended similar methods in other cases but I was too lazy to include it here. Thank you. $\endgroup$
    – Mr.Wizard
    Oct 21 '16 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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