This file is indexed.

/usr/share/gps/library/occurrences.py is in gnat-gps-common 5.0-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Highlights all instances of current word in current editor

This script provides a GPS action which, when executed, highlights all
occurrences of the current word in the current editor.
This is a textual search, and ignores cross-references information. As
a result, if you select "Tmp" and have two variables with that names,
occurrences of the two variables will be highlighted.

This is similar to an Eclipse feature called "Dynamically marking occurrences
in file"

You can bind any shortcut you want to the action defined in this package.
This is done through the /Edit/Key Shortcuts menu.

The resulting highlights can be removed either through the "Remove Marked
Occurrences" action, or simply by deleting the corresponding category in the
Locations window.
"""


############################################################################
## no user customization below this line
############################################################################

import GPS
from gps_utils import *

GPS.Preference ("Plugins/occurrences/color").create (
  "Highlight Color", "color",
  """color used to highlight matching occurrences.
you must restart gps to take changes into account""",
  "lightblue")

def on_gps_started (hook_name):
  GPS.Editor.register_highlighting \
    ("dynamic occurrences", GPS.Preference ("Plugins/occurrences/color").get(), True)

@interactive ("Editor", filter="Source editor", name="mark occurrences",
              menu="/Navigate/Mark Occurrences In File")
def mark_selected ():
   """Mark all the occurrences of the selected element in the current editor.
      Does nothing if multiple lines are selected"""
   buffer = GPS.EditorBuffer.get()
   if buffer.selection_start().line != buffer.selection_end().line:
      return

   selection = buffer.get_chars (buffer.selection_start(), buffer.selection_end() - 1)
   context=GPS.current_context()

   if selection=="" and context.__class__ == GPS.EntityContext:
      selection=context.entity().name()

   if selection != "":
      for m in buffer.file().search (selection, regexp=False):
         GPS.Locations.add ("Local occurrences", m.file(), m.line(), m.column(),
              selection, highlight="dynamic occurrences", length=len(selection))

@interactive ("Editor", filter="Source editor",
              name="remove marked occurrences")
def unmark_selected ():
   GPS.Locations.remove_category ("Local occurrences")

GPS.Hook ("gps_started").add (on_gps_started)