1

I'm presently combing isearch.el to find out how to highlight-string and unhighlight-string in the buffer. This is needed when highlight-regexp will not work -- e.g., a string like this:

** Active [#A] .;;;;;;;;;;;;;;;;;;;;;;;;;;;; HIGH ;;;;;;;;;;;;;;;;;;;;;;;;;;;. :HIGH:
   DEADLINE: <2013-12-15 Sun>

The functions isearch-highlight (beg end) and isearch-dehighlight are almost exactly what is needed -- I just need to modify (beg end) so that a string can be used.

beg and end may move during the function (e.g., org-archive-subtree), so it is a few extra lines of code to find the string again and re-define beg and end -- it would be nice to just use something like (highlight-string string).

3
  • 1
    The question is not clear to me. In what way does highlight-regexp "not work"? What is the spec for your hypothetical highlight-string? Is it something more than (highlight-regexp (reqgexp-quote string))?
    – Drew
    Dec 15, 2013 at 21:58
  • @Drew I learned something knew today thanks to you -- I hadn't seen (highlight-regexp (regexp-quote string)) before. Thank you very much -- greatly appreciated !!!
    – lawlist
    Dec 15, 2013 at 23:12
  • You're welcome. People sometimes forget that a literal string is a regexp, so that functions that work with regexps also work with literal strings. And regexp-opt makes a string literal, as a regexp. I posted the info as an answer, for clarity.
    – Drew
    Dec 15, 2013 at 23:59

1 Answer 1

1

Just use (highlight-regexp (regexp-quote YOUR-STRING)), to escape all regexp-special characters in YOUR-STRING.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .