This is rather basic.
In an empty notebook I type in a single cell
BeginPackage["fun`"]
Unprotect @@ Names["fun`*"];
ClearAll @@ Names["fun`*"];
f::usage = "f[x]"
Begin["`Private`"]
f[x_] := Module[{}, Sin[x^2]];
End[]
Protect @@ Names["fun`*"];
EndPackage[]
I select the cell and change to become an initialization cell. When I save the notebook, there is the option to save it as an Mathematica package. But I have read somewhere that when you save it for the first time it should appear a pop-up men asking about an AUTO SAVE choice.
But, this menu does not appear. Any ideas?
EDIT There is an answer to a similar query here
SetOptions[Notebooks["<notebook name>.nb"][[1]],AutoGeneratedPackage->Automatic]
This function has not been fully integrated into the long-term Wolfram Language, and is subject to change.
AutoGeneratedPackage is an option for notebooks that specifies whether a package is automatically created when a notebook that contains initialization cells or groups is saved.
(...since 1999...)