Monday Mini-Golf #2: Truncating long text Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.

Many web applications (especially social media) automatically truncate long passages of text so they fit within the app's formatting. In this challenge, we're going to create an algorithm to automatically trim a passage of text to a certain length.

Challenge

The goal of the challenge is to write a program or function that takes in two arguments:


T, the text to truncate.
L, the maximum length to return.


And returns T, truncated with the following logic:


If the length of T is less than or equal to L, no truncation is needed. Return the original string.
Truncate T to length L-2. If this contains no spaces or hyphens, return T truncated to exactly L-3 characters, followed by an ellipsis ....
Otherwise, trim the end of the result up to the last space or hyphen. Add an ellipsis ... and return the result.


Details


T and L may be taken in either order and any format.
You may assume that 3 &lt; L &lt; 231.
You may not use U+2026 Horizontal Ellipsis …; you must use three periods.
The input will not start with a space or a hyphen.
The input will not contain any whitespace other than regular spaces. (No tabs, newlines, etc.)


Test-cases

Inputs:

"This is some very long text." 25
"This-is-some-long-hyphen-separated-text." 33
"Programming Puzzles &amp; Code Golf is a question and answer site for programming puzzle enthusiasts and code golfers." 55 
"abcdefghijklmnopqrstuvwxyz" 20
"a b c" 4
"Very long." 100


Outputs:

"This is some very long..."
"This-is-some-long-hyphen..."
"Programming Puzzles &amp; Code Golf is a question and..."
"abcdefghijklmnopq..."
"a..."
"Very long."


(Note that the quotes are just to specify that these are strings; they need not be included.)

Scoring

This is code-golf, so shortest valid code in bytes wins. Tiebreaker goes to submission that reached its final byte count first. The winner will be chosen next Monday, Oct 5. Good luck!

Edit: Congrats to your winner, @Jakube with Pyth again, with 25 bytes!
Pyth, 25 bytes

+WnzK&lt;zeo}@zN" -"-Q2K"...


Try it online: Demonstration or Test Suite

Explanation:

+WnzK&lt;zeo}@zN" -"-Q2K"...  implicit: z = input string, Q = input number
        o        -Q2       order the indices N in [0, 1, ..., Q-3] by
         }@zN" -"            z[T] in " -"
                           (hyphen-indices get sorted to the back)
       e                   take the last such number
     &lt;z                    reduce z to length ^
    K                      save this string to K
+WnzK               K"...  print (K + "...") if z != K else only K