So to summarize: when I copy-paste those chords/lyrics into a buffer
with guitar-mode, not everything gets syntax highlighted until I edit
the content around the chords.
Why is this?
It’s not a problem with pasting. Your function `guitar-chord-matcher’
isn’t defined correctly. When font-lock calls a function to provide
match data for keyword fontification, it calls that function repeatedly
until either (a) point reaches the limit of the region being fontified,
or (b) the matching function returns nil. Your function returns nil
when it encounters an invalid chord, stopping fontification at that
point. What you want is for `guitar-chord-matcher’ to keep searching
if it encounters an invalid chord. So, something like:
(defun guitar-chord-matcher (limit)
(with-syntax-table guitar-mode-syntax-table
(catch 'found
(while (re-search-forward guitar-full-chord-regexp limit t)
(when (save-match-data
(guitar-valid-chord-p (match-string 0)))
(throw 'found t))))))
Although catch forms are slow, so you'll probably want to code it
differently.