Function: semantic-idle-symbol-maybe-highlight

semantic-idle-symbol-maybe-highlight is a byte-compiled function defined in idle.el.gz.

Signature

(semantic-idle-symbol-maybe-highlight TAG)

Documentation

Perhaps add highlighting to the symbol represented by TAG.

TAG was found as the symbol under point. If it happens to be visible, then highlight it.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/idle.el.gz
(defun semantic-idle-symbol-maybe-highlight (tag)
  "Perhaps add highlighting to the symbol represented by TAG.
TAG was found as the symbol under point.  If it happens to be
visible, then highlight it."
  (require 'pulse)
  (let* ((region (when (and (semantic-tag-p tag)
			    (semantic-tag-with-position-p tag))
		   (semantic-tag-overlay tag)))
	 (file (when (and (semantic-tag-p tag)
			  (semantic-tag-with-position-p tag))
		 (semantic-tag-file-name tag)))
	 (buffer (when file (get-file-buffer file)))
	 ;; We use pulse, but we don't want the flashy version,
	 ;; just the stable version.
	 (pulse-flag nil)
	 )
    (cond ((overlayp region)
	   (with-current-buffer (overlay-buffer region)
	     (save-excursion
	       (goto-char (overlay-start region))
	       (when (pos-visible-in-window-p
		      (point) (get-buffer-window (current-buffer) 'visible))
                 (if (< (overlay-end region) (line-end-position))
		     (pulse-momentary-highlight-overlay
		      region semantic-idle-symbol-highlight-face)
		   ;; Not the same
		   (pulse-momentary-highlight-region
		    (overlay-start region)
                    (line-end-position)
		    semantic-idle-symbol-highlight-face))))
	     ))
	  ((vectorp region)
	   (let ((start (aref region 0))
		 (end (aref region 1)))
	     (save-excursion
	       (when buffer (set-buffer buffer))
	       ;; As a vector, we have no filename.  Perhaps it is a
	       ;; local variable?
	       (when (and (<= end (point-max))
			  (pos-visible-in-window-p
			   start (get-buffer-window (current-buffer) 'visible)))
		 (goto-char start)
		 (when (re-search-forward
			(regexp-quote (semantic-tag-name tag))
			end t)
		   ;; This is likely it, give it a try.
		   (pulse-momentary-highlight-region
                    start (if (<= end (line-end-position)) end
                            (line-end-position))
		    semantic-idle-symbol-highlight-face)))
	       ))))
    nil))