Everybody enjoys being right, especially when it comes to being proved correct about stocks that help investors create long-term wealth. Here, then, are three companies that have fallen out of favor with the market but could offer savvy investors a great buy and a chance to say "I told you so" if things turn around.

Doom and gloom are priced in

It's been a tough go for major automakers over the past year. Despite record profits from General Motors (NYSE:GM), Detroit's largest automaker has fallen out of favor with investors as the new-vehicle sales cycle peaks in the U.S. market. But there are many factors that will help GM drive results regardless.

First, consider that new or refreshed vehicles sell faster and require fewer incentives and deals to move them off dealership lots. In addition, SUVs, crossovers, and trucks generate higher average transaction prices and margins. And that matters, because from 2011 to 2016, GM's global sales of new or refreshed vehicles were 38% SUVs, crossovers, and trucks and 62% cars, but from 2017 through 2020, GM estimates that 52% of its global new or refreshed sales will come from the former category. With a fleet of newer and larger vehicles coming, GM looks set to improve its top and bottom line despite a peaking sales cycle.

A Silver Ice Metallic 2018 Silverado 2500HD and a Cajun Red 2018 Equinox, parked side by side under a tiger statue at Comerica Park in Detroit.

A Silver Ice Metallic 2018 Silverado 2500HD and a Cajun Red 2018 Equinox. Image source: General Motors.

GM has also been diligent about creating cost synergies by improving its material spending, logistics, and manufacturing processes. In fact, management now expects to generate $6.5 billion in cost savings between 2015 and 2018, a billion more than it originally estimated. A large chunk of that savings will turn into investments in brand-building, engineering, and technology, while about $3 billion will remain as net savings.

Moreover, GM has committed to returning value to shareholders over the past few years. Since 2012, the automaker has returned roughly $18 billion to shareholders through dividends and share repurchases. That's more than 90% of its adjusted automotive free cash flow and roughly 34% of its market cap. GM's dividend yield is a juicy 4.4%, and much of the industry's doom and gloom seems priced in, with a price-to-earnings ratio (TTM) of 5.

While there are risks to owning shares of major automakers, GM seems well positioned to drive results over the long term.

A thriving e-commerce story

As retailers go these days, if a company doesn't have an e-commerce growth story, the stock is left for dead. To that end, Williams-Sonoma, Inc. (NYSE:WSM), a multi-channel specialty retailer of high-quality home furnishing products, has a greater stronghold on its e-commerce business than its competitors do.

Graphic showing WSM leading competitors in e-commerce penetration (52%)

Image source: Williams-Sonoma April 2017 investor presentation.

The company generated 52% of its full-year 2016 net revenue from e-commerce, and the other 48% through traditional retail. Its growth story appears poised to continue as well, considering Williams-Sonoma's internet revenue has grown at a compound annual growth rate of 26% since 2000. And with its e-commerce requiring less overhead, that side of the business is a key driver for profitability and recorded a 23% e-commerce operating margin last year, more than double its traditional retail margin.

What's next for the company? Management believes the company can double its top line over the next decade, to roughly $10 billion by 2026. There are some key factors involved in reaching that goal. West Elm, one of the company's newest billion-dollar brands, has posted strong growth with only 18% brand awareness. Williams-Sonoma will continue to advertise to raise awareness and plans to open 10 new stores in 2017 to help drive growth. Also, WSM's global growth has doubled, from 3% to 6% of its total revenue, between 2010 and 2016 -- leaving ample room for growth. In fact, management anticipates that its growing global business will generate 15% of its total revenue over the next decade.

However, Williams-Sonoma has stumbled over the past year with PBteen and Pottery Barn Kids, its brands that focus on younger audiences. And some investors are worried that its e-commerce strategy could falter if Amazon.com decides to focus on the segment. However, at a trailing-12-month price-to-earnings ratio of only 13, the downside seems priced in, and with a dividend yield of 3.2%, this could be a long-term winner if management can indeed double its top line over the next decade.

Daniel Miller owns shares of General Motors. The Motley Fool owns shares of and recommends Amazon. The Motley Fool recommends Williams-Sonoma. The Motley Fool has a disclosure policy.