From: Alp Aker <aker@pitt.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Syntax highlighting fails on copy-paste
Date: Fri, 13 May 2011 21:31:47 +0000 (UTC) [thread overview]
Message-ID: <loom.20110513T232440-220@post.gmane.org> (raw)
In-Reply-To: 4DCD23B9.7020400@dogan.se
> 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.
next prev parent reply other threads:[~2011-05-13 21:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-13 12:27 Syntax highlighting fails on copy-paste Deniz Dogan
2011-05-13 21:31 ` Alp Aker [this message]
2011-05-14 8:21 ` Deniz Dogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20110513T232440-220@post.gmane.org \
--to=aker@pitt.edu \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.