/usr/share/jed/lib/recent.sl is in jed-common 1:0.99.19-3.
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 | % File: recent.sl -*- SLang -*-
%
% Author: Guido Gonzato, <ggonza@tin.it>
%
% Version: 1.0.1. This file provides easy access to recently
% accessed files.
%
% Installation: to install this feature globally, load recent.sl from site.sl
% and insert the following lines in defaults.sl:
%
% variable RECENT_FILES_LIST = ".jedrecent"; % or other
% variable MAX_RECENT_FILES = 20; % ditto
%
% For personal customisation, insert these lines in your .jedrc:
%
% % WANT_RECENT_FILES_LIST = 1 % set this to 0 to disable
% % RECENT_FILES_LIST = ".jedrecent"; % uncomment to customise
% % MAX_RECENT_FILES = 10;
%
% Last updated: 17 April 2001
custom_variable ("WANT_RECENT_FILES_LIST", 1);
#ifdef IBMPC_SYSTEM
custom_variable ("RECENT_FILES_LIST", "_jedrcnt");
#else
custom_variable ("RECENT_FILES_LIST", ".jedrecent");
#endif
custom_variable ("MAX_RECENT_FILES", 15);
% -----
private variable Recent_Files_Buf = " *recent files*";
private variable List_Of_Buffers = NULL;
private define get_recent_file_list_name ()
{
variable file = RECENT_FILES_LIST;
% Versions of slang prior to 1.4.3 have a bug in the path_is_absolute function.
if (_slang_version >= 10403)
{
if (path_is_absolute (file))
return file;
}
variable dir = Jed_Home_Directory;
#ifdef IBMPC_SYSTEM
if (dir == "")
{
dir = getenv ("TEMP");
if (dir == NULL)
dir = "";
}
#endif
return dircat (dir, file);
}
% Load the list of recent files in recent_files_buf.
private define load_recent_file_list ()
{
variable file = get_recent_file_list_name ();
if (bufferp (Recent_Files_Buf))
{
setbuf (Recent_Files_Buf);
if (file_changed_on_disk (file))
delbuf (Recent_Files_Buf);
}
!if (bufferp (Recent_Files_Buf))
{
() = read_file (file);
rename_buffer (Recent_Files_Buf);
}
bob ();
}
% Build the menu of recent files.
public define recent_files_menu_callback (popup)
{
variable buf, tmp, i, cmd;
variable menu;
buf = whatbuf ();
load_recent_file_list (); % load the list of recent files
bob ();
i = '1'; % use 1-9 first, then a-z, then A-Z, then give up and restart
forever
{
tmp = line_as_string ();
!if (strlen (tmp))
break;
cmd = sprintf ("()=find_file (\"%s\")", tmp);
(cmd, ) = strreplace (cmd, "\\", "\\\\", strlen (cmd)); % fix DOS
menu_append_item (popup, sprintf ("&%c %s", i, tmp), cmd);
go_down_1 ();
% check - what should we use?
switch (i)
{ case '9': i = 'a' - 1; }
{ case 'z': i = 'A' - 1; }
{ case 'Z': i = '1' - 1; }
i++;
}
setbuf (buf);
}
% This function is called by _jed_switch_active_buffer_hooks
public define append_recent_files (buf)
{
variable file, dir, n;
variable blist;
!if (WANT_RECENT_FILES_LIST)
return;
% find out the file name with full path
(file,dir,buf,) = getbuf_info ();
!if (strlen (file))
return;
blist = [buffer_list (), pop ()];
file = dircat (dir, file);
load_recent_file_list ();
EXIT_BLOCK
{
sw2buf (buf);
List_Of_Buffers = blist;
}
if (is_readonly ())
return; % no permission to modify buffer/list
% Check to see if this one is already on the list
bob ();
if (file == line_as_string ())
return;
% Only add the file to the list if it is not on the list, or it was
% not in the previously checked list of buffers.
if (List_Of_Buffers != NULL)
{
if (any (List_Of_Buffers == buf))
return;
}
if (bol_fsearch (file))
{
go_right (strlen (file));
if (eolp ())
delete_line ();
}
bob ();
vinsert ("%s\n", file);
% are there more entries than allowed?
goto_line (MAX_RECENT_FILES);
if (down_1 ())
{
bol ();
push_mark ();
eob ();
del_region ();
}
ERROR_BLOCK
{
_clear_error ();
}
file = get_recent_file_list_name ();
() = write_buffer (file);
() = chmod (file, 0600);
}
%add_to_hook ("_jed_find_file_after_hooks", &append_recent_files);
append_to_hook ("_jed_switch_active_buffer_hooks", &append_recent_files);
private define add_recent_files_popup_hook (menubar)
{
!if (WANT_RECENT_FILES_LIST)
return;
variable menu = "Global.&File";
menu_append_separator (menu);
menu_append_popup (menu, "&Recent Files");
menu_set_select_popup_callback (strcat (menu, ".&Recent Files"),
&recent_files_menu_callback);
}
#ifexists _jed_run_hooks
append_to_hook ("load_popup_hooks", &add_recent_files_popup_hook);
#else
variable Menu_Load_Popups_Hook = &add_recent_files_popup_hook;
#endif
provide ("recent");
% End of file recent.sl
|