How to create nonbreaking arbitrary length snakes for full-width justification?

Really is not a snake, but ...

enter image description here

\documentclass{article}
\usepackage[text={1.2in,3in}]{geometry}
\def\snake{\cleaders\hbox to .5em{\hss\ensuremath\sim\hss%
\hspace{-.3em minus -.2em}%
}\hfill$^{_\diamond}$\break}
\raggedright
\begin{document}
\noindent Their famous paper on the relationship between \snake
deindustrialization and \snake the growth of the main ecological  \snake
\end{document}

While I couldn't get David Carlisle's answer to work, I made a simple tielable vector version of the xkcd snake:

result

\documentclass{article}
\usepackage[text={1.2in,3in}]{geometry}
\usepackage[none]{hyphenat}

\directlua{
    PDF_LITERAL = node.subtype("pdf_literal")
    WS = node.id("whatsit")
    GLUE = node.id("glue")
    add_image = function(line, n, width, height, name)
        local sni = img.node{filename=name}
        sni.height = height
        sni.width = width
        return node.insert_before(line,n,sni)
    end
    add_snake = function(line, n, width, height)
        local segments_middle = 0;
        local segments_wave = 0;
        local unstretched_width = height * (1.0 + 1.5)

        while unstretched_width + height * 1.5 < width do
            unstretched_width = unstretched_width + height * 1.5
            segments_wave = segments_wave + 1
        end

        while unstretched_width + height * 0.5 < width do
            unstretched_width = unstretched_width + height * 0.5
            segments_middle = segments_middle + 1
        end

        local stretch = width / unstretched_width

        line = add_image(line, n, height * 1.0 * stretch, height, "snake_tail.pdf")

        for i = 1, segments_wave do
            line = add_image(line, n, height * 1.5 * stretch, height, "snake_wave.pdf")
        end

        for i = 1, segments_middle do
            line = add_image(line, n, height * 0.5 * stretch, height, "snake_middle.pdf")
        end

        line = add_image(line, n, height * 1.5 * stretch, height, "snake_head.pdf")

        return line
    end
    local w = 1250000 % remove when effective_glue works!
    snakefill = function(head)
        for line in node.traverse_id(0,head) do
            for n in node.traverse_id(GLUE,line.head) do
                if n.subtype == 9 then
                    %local w = node.effective_glue(n,line) / 65536
                    w = w * 1.1 % remove when effective_glue works!
                    local h = 500000
                    line = add_snake(line, n, w, 500000)
                end
            end
        end
        return head
    end
}
\def\snakefill{%
    \directlua{
        luatexbase.add_to_callback("post_linebreak_filter",snakefill,"snake fill")
    }%
}
\def\offsnakefill{%
    \directlua{
        luatexbase.remove_from_callback("post_linebreak_filter","snake fill")
    }%
}

\begin{document}
    \raggedright
    \snakefill
    \noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
    \noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
    \noindent Their famous paper on the relationship between deindustrialization and the growth of ecological\ldots\par
\end{document}

The snake images can be obtained from this gist. I'll update the post if I find a way to get effective_glue to work.


this is lualatex only and draws a PDF line w points wide to pad out each line, if you are feeling artistic replace w 0 l by something that draws a snake of the same length

enter image description here

\documentclass{article}

\directlua{
PDF_LITERAL = node.subtype("pdf_literal")
WS=node.id("whatsit")
GLUE  = node.id("glue")
snakefill=function(head)
  for line in node.traverse_id(0,head) do
  for n in node.traverse_id(GLUE,line.head) do
  if n.subtype==9 then
  print('  glue: ' .. n.subtype .. ' ' ..node.effective_glue(n,line) )
  local w = node.effective_glue(n,line) / 65536
local sn = node.new(WS,PDF_LITERAL)
sn.data="0 G 0 0 m  " .. w .. " 0 l S 0 g"
  line=node.insert_before(line,n,sn)
    end
   end
  end
return head
end
}
\def\snakefill{%
\directlua{
luatexbase.add_to_callback("post_linebreak_filter",snakefill,"snake fill")
}%
}
\def\offsnakefill{%
\directlua{
luatexbase.remove_from_callback("post_linebreak_filter","snake fill")
}%
}

\begin{document}

\raggedright\parfillskip=0pt
\snakefill
one two three four five
one two three four five
one two three four fivexxxxxxxxxxxx
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
one two three four five
\end{document}

Or a version that's more snake like

enter image description here

% http://images.clipartpanda.com/cute-snake-clipart-black-and-white-30511wall.png

\directlua{
GLUE  = node.id("glue")
snakefill=function(head)
  for line in node.traverse_id(0,head) do
  for n in node.traverse_id(GLUE,line.head) do
  if n.subtype==9 then
  print('  glue: ' .. n.subtype .. ' ' ..node.effective_glue(n,line) )
  local w = node.effective_glue(n,line)
local sni = img.node{filename="cute-snake-clipart-black-and-white-30511wall.png"}
sni.height=500000
sni.width=w
  line=node.insert_before(line,n,sni)
    end
   end
  end
return head
end
}