jed-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

_jed_set_mode_hooks not called by compression mode


Hi,

I've created a hook for _jed_set_mode_hooks.

#v+
private define mode_selection(ext)
{
    variable tmp = buffer_filename();
    if (orelse {is_substr(tmp, "/changelog.Debian")}
               {andelse {strlen(tmp) > 17}
                        {strcmp(tmp[[-17:]], "/debian/changelog") == 0}
                } )
    {
        deb_mode();
        return 1;
    }
}
add_to_hook("_jed_set_mode_hooks", &mode_selection);
#v-

I've set auto_compression_mode(1). If I open a file
/usr/share/jed/changelog.Debian.gz the function above does not get
called. So the default text_mode() gets called.

#v+
% xjed -batch $d/jed-common/changelog.Debian.gz
loading /usr/share/jed/lib/site.sl
loading /usr/share/jed/lib/os.sl
loading /usr/share/jed/lib/menus.slc
loading /usr/share/jed/lib/defaults.sl
loading /etc/jed.d/05jed-common.sl
loading /etc/jed.d/50jed-extra.sl
loading /usr/share/jed/jed-extra/libdir.sl
loading /etc/jed.d/50local.sl
loading /home/joerg/.jed/jed.rc
loading /usr/share/jed/lib/keydefs.slc
loading /home/joerg/.jed/debmode.sl
loading /usr/share/jed/lib/modeinfo.sl
loading /usr/share/jed/lib/compress.slc
loading /usr/share/jed/lib/abbrev.slc
Reading /usr/share/doc//jed-common/changelog.Debian.gz
loading /home/joerg/.jed/textmode.sl
bla
Traceback: error
/home/joerg/.jed/textmode.sl:3:text_mode:Run-Time Error
/usr/share/jed/lib/site.sl:-1:mode_hook:Run-Time Error
  Local variables for mode_hook:
        String_Type ext = "Debian"
        Integer_Type n = 0
        String_Type mode = "debian_mode"
/usr/share/jed/lib/compress.slc:107:compressed_set_mode_hook:Run-Time Error
  Local variables for compressed_set_mode_hook:
        String_Type compressed_set_mode_hook = "gz"
        Integer_Type compressed_set_mode_hook = 0
        String_Type compressed_set_mode_hook = "changelog.Debian"
Error encountered while executing compressed_set_mode_hook
Traceback: find_file
/usr/share/jed/lib/site.sl:3188:command_line_hook:Run-Time Error
  Local variables for command_line_hook:
        Integer_Type n = 0
        Integer_Type i = 3
        String_Type file = "/usr/share/doc//jed-common/changelog.Debian.gz"
        Integer_Type depth = 0
        Undefined_Type next_file = Undefined_Type
        String_Type tmp = "sr/share/doc//jed_common/changelog.Debian.gz"
        String_Type init_file = "/home/joerg/.jed/jed.rc"
        Undefined_Type next_file_arg = Undefined_Type
Error encountered while executing command_line_hook
#v-

The patch below is more like a quick hack, because I did not have any
idea how to solve it otherwise. But it works :-)

#v+
--- site.sl     (Revision 23)
+++ site.sl     (Arbeitskopie)
@@ -1842,9 +1842,15 @@
 % for the buffer. This function takes one parameter, the filename extension
 % and returns nothing.
 %!%-
-
+private variable in_mode_hook = 0;
 define mode_hook (ext)
 {
+    if (in_mode_hook)
+      return;
+    in_mode_hook = 1;
+
+    try
+    {
    variable n, mode;
 #ifdef VMS
    ext = extract_element(ext, 0, ';');
@@ -1887,6 +1893,10 @@
        return;
      }
 
+   _jed_run_hooks("_jed_set_mode_hooks", JED_HOOKS_RUN_UNTIL_0, [ext]);
+    if (get_mode_name() != "")
+      return;
+
    !if (strncmp (strup (extract_filename (buffer_filename ())), "READ", 4))
      {
        text_mode ();
@@ -1894,6 +1904,9 @@
      }
 
    @Default_Mode ();
+    } finally {
+        in_mode_hook = 0;
+    }
 }
 
 %}}}
#v-

Bye, Jörg.
-- 
"...anytime you install something new on the Windows platform, you risk
spending the next five or six hours trying to figure out what happened"
         -- Robert Roblin, Adobe

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]