This file is indexed.

/usr/share/jed/jed-extra/extra/occur.sl is in jed-extra 2.5.6-2.

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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
% occur.sl
%
% $Id: occur.sl,v 1.5 2005/05/24 09:20:43 paul Exp $
% Keywords: matching
%
% Copyright (c) John Davis, Paul Boekholt.
% Released under the terms of the GNU GPL (version 2 or later).
%
% Improved occur function:
% - can show occurrences with context
% - occur() has optional arguments for scripting
% - inherits from view-mode
% - propose to list occurrences of the word at point
% - in occur mode you can scroll the other window like in bufed or rmail
% - moccur: occur in multiple buffers
% - (SLang 2 only) highlight matches

provide ("occur");
require ("keydefs");
require ("view");
implements ("occur");
define get_buffer_name();

% default number of context lines
% unfortunately it's not possible to give a 0 prefix argument
custom_variable ("Occur_Context", 0);

$1 = "Occur";

%{{{ keymap

!if (keymap_p ($1))
  copy_keymap ($1, "view");
. "occur->occur_goto_line" "g"
. "occur->next" "n"
. "occur->prev" "p"
. "occur->scroll" " "
. "occur->scroll_up" Key_BS
. "occur->occur_pop_to_line" "\t"
loop(6) definekey($1);

%}}}

%{{{ static variables
variable buf = "*occur*",
  % The buffer that's searched
  obuf = Null_String,
  % How many lines of context to show
  % In occur mode, it should not be assumed that the entry really has
  % `nlines' lines of context, but if this is not 0 entries are separated by
  % "^-----"
  nlines = 0,
  % flag indicating that we're occurring in multiple buffers
  mbuffers=0,
  % were there any matches?
  matches_flag = 0;

  % Width of line number prefix without the colon.  Choose a width that's a
  % multiple of `tab-width' so that lines in *Occur* appear right.
  variable line_number_width=(4 / TAB_DEFAULT + 1) * TAB_DEFAULT - 1,
  line_number_format = sprintf("%%%dd:", line_number_width),
  empty =sprintf("%*s", line_number_width + 1, ":");

#ifexists _slang_utf8_ok
variable match_marker = sprintf("\e[%d]", color_number("keyword"));
#endif
%}}}

%{{{ occur mode
%{{{ moving around

static define next()
{
   if (nlines)
     ()=bol_fsearch("---");
   eol;
   () = re_fsearch ("^ *[0-9]");
   bol;
   if (nlines)
     recenter(nlines+2);
}

static define prev()
{
   if (nlines)
     ()=bol_bsearch("---");
   bol;
   () = re_bsearch ("^ *[0-9]");
   if (nlines)
     {
	if(bol_bsearch("---"))
	  {
	     () = re_fsearch ("^ *[0-9]");
	     recenter(nlines+2);
	  }
     }
}

%}}}
%{{{ jumping to the match

static define occur_goto_line()
{
   if (mbuffers)
     obuf = get_buffer_name();
   !if (bufferp (obuf))
     return vmessage("buffer: <%s> doesn't exist anymore", obuf);
   push_spot ();
   if (nlines)
     {
	% goto nearest of separator or matching line
	eol ();
	push_spot;
	!if (bol_bsearch ("---")) bob;
	push_mark; pop_spot;
	!if(re_bsearch ("^ *[0-9]+:")) bob;
	check_region(0);
	pop_mark_0;
     }
   bol;
   if (re_fsearch ("^ *\\([0-9]+\\):"))
     integer(regexp_nth_match(1));
   else
     return pop_spot;

.   pop_spot  obuf pop2buf  goto_line
}

static define occur_pop_to_line()
{
   occur_goto_line();
   pop2buf(buf);
}

%}}}
%{{{ scrolling the other window

static define scroll()
{
   !if (bufferp (obuf)) return;
   pop2buf (obuf);
   call("page_down");
   pop2buf (buf);
}

static define scroll_up()
{
   !if (bufferp (obuf)) return;
   pop2buf (obuf);
   call("page_up");
   pop2buf (buf);
}

%}}}
%{{{ syntax table
create_syntax_table($1);
#ifdef HAS_DFA_SYNTAX
dfa_enable_highlight_cache ("occur.dfa",$1);
dfa_define_highlight_rule("^Buffer", "keyword0", $1);
dfa_define_highlight_rule("^-+$", "keyword1", $1);
dfa_define_highlight_rule("^ *[0-9]+", "number", $1);
dfa_define_highlight_rule(":.*$", "normal", $1);
dfa_build_highlight_table($1);
enable_dfa_syntax_for_mode("occur");
#endif
%}}}

%!%+
%\function{occur_mode}
%\synopsis{mode of the *occur* buffer}
%\usage{occur_mode()}
%\description
%   Mode of the \var{*occur*} buffer.  The following keys are defined:
%   \var{RET}	go to the source buffer and visit the line
%               this entry points to
%   \var{TAB}	Visit this line, but stay in the \var{*occur*} buffer
%   \var{n}	Next entry
%   \var{p}	Previous entry
%   \var{SPC}	Scroll source buffer down
%   \var{DEL}	Scroll backward in the source buffer.
%\seealso{occur, moccur}
%!%-
public define occur_mode()
{
   use_keymap ("Occur");
   set_mode ("occur", 0);
   use_syntax_table("Occur");
#ifexists _slang_utf8_ok
   _set_buffer_flag(0x1000);
#endif
   set_buffer_hook ("newline_indent_hook", &occur_goto_line);
   set_help_message("RET:goto match  TAB:popup match  n:next  p:prev  SPC: scroll source buffer");
   run_mode_hooks ("occur_mode_hook");
}

%}}}

%{{{ search a buffer

% This is complicated, but it should always highlight the correct part of the line
% even when doing a case insensitive or anchored regexp search.
static define search_buffer(obuf, str)
{
   if (buf == obuf) return;
   if (andelse {mbuffers}{is_substr("* ", obuf[[0]])}) return;
   variable n, line;
   setbuf(obuf);
   push_spot_bob ();
   variable this_line, next_line, match_len;

   match_len = re_fsearch (str);
   !if (match_len) return pop_spot;
#ifexists _slang_utf8_ok
   push_spot;
#endif
   this_line = what_line();
   matches_flag=1;
   setbuf (buf);
   !if (bobp) newline;
   vinsert("Buffer: %s\n", obuf);
   if (nlines) insert ("------\n");
   setbuf (obuf);
   
   %%% get line and context
   variable c; % context
   variable sd = _stkdepth;
   variable beg, len;
   USER_BLOCK0 
     {
#ifexists _slang_utf8_ok
.	""
.	bol push_mark pop_spot
.	bufsubstr
.	push_mark
.	match_len 1 - go_right
.	match_marker
.	bufsubstr
.	"\e[0]"
.	push_mark_eol
.	bufsubstr
.	5 create_delimited_string
#else
.       line_as_string
#endif
     }
   while (this_line)
     {
	% before
	n = up (nlines);
	loop (n)
	  {
.	     empty  line_as_string  go_down_1
	  }
	% line
	sprintf(line_number_format, this_line); X_USER_BLOCK0; ++n;
	% if context overlaps with next line, merge
	forever
	  {
	     go_down_1;
	     match_len = re_fsearch (str);
	     !if (match_len)
	       {
		  next_line=0;
		  goto_line(this_line);
		  break;
	       }
#ifexists _slang_utf8_ok
	     push_spot;
#endif	  
	     next_line=what_line();
	     if (next_line - this_line > 2 * nlines)
	       {
		  goto_line(this_line);
		  break;
	       }
	     goto_line(this_line +1);
	     loop(next_line - this_line - 1)
	       { 
.		  empty  line_as_string    go_down_1 ++n
	       }
	     this_line = what_line();
	     sprintf(line_number_format, this_line); X_USER_BLOCK0; ++n;
	  }
	
		  
	% after
	loop (nlines)
	  {
	     !if(down_1) break;
.	     empty  line_as_string ++n
	  }


	_stk_reverse (_stkdepth-sd);
	
	%%% insert in the *occur* buffer
	setbuf (buf);

	loop (n)
	  {
	     insert ();
	     insert ();
	     newline ();
	  }

	if (nlines) insert ("------\n");

	setbuf (obuf);
	this_line=next_line;
	goto_line(this_line);
     }
   pop_spot ();
}

%}}}

%{{{ occur

%!%+
%\function{occur}
%\synopsis{occur}
%\usage{Void occur ([regexp, nlines]);}
%\description
%  This function may be used to search for all occurrences of a string in
%  the current buffer.  Without arguments, it prompts for a string to search
%  for, defaulting to the word at point.  It creates a separate buffer called
%  \var{*occur*} and associates a keymap called \var{Occur} with the new
%  buffer.  In this buffer, the \var{g} and \var{enter} key may be used to go
%  to the line described by the match.
%
%  Each line is displayed with \var{nlines} lines before and after.
%  \var{Nlines} defaults to \var{Occur_Context}.  Interactively it is the
%  prefix arg.
%\seealso{occur_mode, moccur}
%!%-
public define occur()
{
   variable str, n;

   (str, nlines) = push_defaults (, Occur_Context, _NARGS);
   if (str == NULL)
     {
	nlines = prefix_argument (nlines);
	str = read_mini ("Find All (Regexp):", get_word (), Null_String);
     }
   
   if (whatbuf() == buf)
     {
	if (mbuffers)
	  obuf = get_buffer_name();
	% else obuf = previous obuf
     }
   else obuf = whatbuf ();
   mbuffers=0;
   setbuf (buf);
   erase_buffer ();
   matches_flag=0;
   search_buffer(obuf, str);
   setbuf (buf);
   set_buffer_modified_flag (0);
   !if (matches_flag)
     {
	message ("no matches");
	return;
     }

   popup_buffer (buf);
   bob ();

   occur_mode();
}

%}}}

%{{{ moccur
static define get_buffer_name()
{
   push_spot();
   eol();
   !if (bol_bsearch("Buffer: "))
     error("What did you do with the header?!");
   ()=ffind_char(' ');
.  go_right_1  push_mark_eol  bufsubstr  pop_spot
}

%!%+
%\function{moccur}
%\synopsis{occur multiple buffers}
%\usage{moccur([regexp, nlines])}
%\description
%   This function may be used to search for all occurrences of a string in
%   all buffers except those whose names start with "*" or " ".  Otherwise
%   it works pretty much like \var{occur}
%\seealso{occur, occur_mode}
%!%-
public define moccur()
{
   variable str, n;

   (str, nlines) = push_defaults (, Occur_Context, _NARGS);
   if (str == NULL)
     {
	nlines = prefix_argument (nlines);
	str = read_mini ("Find All (Regexp):", get_word (), Null_String);
     }
   mbuffers=1;

   setbuf(buf);
   erase_buffer ();
   matches_flag=0;

   loop(buffer_list())
     search_buffer(str);
   setbuf (buf);
   set_buffer_modified_flag (0);
   !if (matches_flag)
     return message ("no matches");

   popup_buffer (buf);
   bob ();

   occur_mode();
}

%}}}