Subject: Re: bug#11095: 24.0.94; hi-lock-face-buffer/unhighlight-regexp': Augment?

From: Juri Linkov <[email-masked]>
Date: Fri, 12 Oct 2012 01:41:04 +0300

> The patch allows highlighting of tag at point.  (Note that for all
> practical purposes, tag at point is the symbol at point.) See
> Part_I/Item-2 below for a usecase.
> [...]
> +	       (cond ((not tag) "")
> +		     ((eq tagf 'find-tag-default)
> +		      (format "\\_<%s\\_>" (regexp-quote tag)))
> [...]
>>    As a programmer, I use highlighting to trace variable dependencies
>>    within a function.  For example, in the example below, after
>>    highlighting the variables in __different__ faces, I will come to the
>>    conclusion that "a" depends on "d" and "tmp".
>>
>>      c = d;
>>      b = c + tmp;
>>      a = b;
>>
>>    And I use this very often to track variables and how they get their
>>    values from.
>>
>>    If I were to use the default Emacs provided behaviour then I would
>>    have to press M-n multiple times as I highlight more and more
>>    symbols. (Typically I have 3-5 symbols highlighted before I turn off
>>    highlighting.)

Would you agree that a better way to implement your proposal is to add a new
command to hi-lock.el with a name like `highlight-symbol'?  I mean there are
already such hi-lock commands as:

1. highlight-lines-matching-regexp (that corresponds to occur)
2. highlight-regexp (that corresponds to isearch-forward-regexp)
3. highlight-phrase (that corresponds to isearch-forward-word)

what is currently missing is this command:

4. highlight-symbol (that corresponds to isearch-forward-symbol)

Then both highlight-phrase and highlight-symbol could use internally
isearch functions that turn words and symbols into regexps
and that will do the right thing using search-upper-case and
search-whitespace-regexp.