bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14427: 24.3.50; Highlight symbol at point


From: Jambunathan K
Subject: bug#14427: 24.3.50; Highlight symbol at point
Date: Sun, 02 Jun 2013 15:31:48 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

If you could commit this change, I can start using it right away.  I
have no firm opinion on whether `hi-lock-auto-select-face' should come
from user setting or be let bound.

Remember to provide a keybinding in hi-lock mode.  I suggest C-x w
"dot".

Juri Linkov <address@hidden> writes:

> This feature request mostly doesn't depend on the outcome of bug#14405.
> I don't know why Jambunathan didn't propose this feature earlier, but it
> logically follows from his other improvements in hi-lock.el, i.e. the
> feature that doesn't ask for a face and automatically uses the next face
> from the list of available faces suggests also a command that doesn't ask
> for a symbol and automatically uses the symbol at point:
>
> === modified file 'lisp/hi-lock.el'
> --- lisp/hi-lock.el   2013-03-31 13:34:35 +0000
> +++ lisp/hi-lock.el   2013-05-20 22:52:54 +0000
> @@ -483,6 +461,27 @@ (defun hi-lock-face-phrase-buffer (regex
>    (unless hi-lock-mode (hi-lock-mode 1))
>    (hi-lock-set-pattern regexp face))
>  
> +;;;###autoload
> +(defalias 'highlight-symbol-at-point 'hi-lock-face-symbol-at-point)
> +;;;###autoload
> +(defun hi-lock-face-symbol-at-point ()
> +  "Set face of each match of the symbol at point.
> +Use `find-tag-default-as-symbol-regexp' to retrieve the symbol at point.
> +Use non-nil `hi-lock-auto-select-face' to retrieve the next face
> +from `hi-lock-face-defaults' automatically.
> +
> +Use Font lock mode, if enabled, to highlight symbol at point.
> +Otherwise, use overlays for highlighting.  If overlays are used,
> +the highlighting will not update as you type."
> +  (interactive)
> +  (let* ((regexp (hi-lock-regexp-okay
> +               (find-tag-default-as-symbol-regexp)))
> +      (hi-lock-auto-select-face t)
> +      (face (hi-lock-read-face-name)))
> +    (or (facep face) (setq face 'hi-yellow))
> +    (unless hi-lock-mode (hi-lock-mode 1))
> +    (hi-lock-set-pattern regexp face)))
> +
>  (defun hi-lock-keyword->face (keyword)
>    (cadr (cadr (cadr keyword))))    ; Keyword looks like (REGEXP (0 'FACE) 
> ...).
>  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]