jed-users mailing list

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

Re: Orthogonality beetween keybinding and language modes [was: "RE: Your enhanced Perl mode for JED (fwd)"]


On  6.11.08, Michele Dondi wrote:
> On Thu, 6 Nov 2008, Olesen, Mark wrote:

...

>>> ... just run the script.

>> Something like perl_exec (Ctrl-C e), or perl_check (Ctrl-C c) ?

>>> Then some refinements of the same action: e.g. run it on a given 
>>> buffer or selection within a buffer, to be passed either via STDIN or 
>>> as a filename on the cmd line. With output in another buffer or 
>>> modifiying the buffer or selection in place.

>> This shouldn't be so hard, but I've never needed it myself.
>> There is a filter region command within JED, but that's not how I work.

You might have a look at the functions ishell.sl 
http://jedmodes.sourceforge.net/mode/ishell/
and their use in the extended python mode
http://jedmodes.sourceforge.net/mode/pymode/

...

> I don't have a keybinding for it: of course I can set it up FOR ME and it 
> would make some sense 
...
> ... another problem: namely, that of orthogonality between main editing
> modes (i.e.  keybindings) and language-specific modes. I believe the
> former ones should provide an "introductory keybinding" upon which the
> latter ones could form composed ones. For example, I see ^J is not
> taken by the ide mode I use. Then the perl mode may use it abstractly
> (i.e. asking it to some function which I don't know) to form ^J-e, ^J-c
> and assign them to perl_exec, perl_check and so on. 
> And similarly other modes. 

This is usually done by the _Reserved_Key_Prefix and the functions
definekey_reserved, unsetkey_reserved, local_setkey_reserved,
setkey_reserved, local_unsetkey_reserved, undefinekey_reserved.

The idea is to have a mode-specific keymap under the _Reserved_Key_Prefix
(^D with emacs and ^E with cua emulation).

A modern mode should also define a mode menu that lists the "end-user"
functions. This way it is easy to see the functionality of the mode and
the pre-defined keybindings.

The perl mode has a rudimentary mode menu missing perl_exec etc.

OTOH, there are a couple of common actions (like "run the buffer" or
"compile") that should be available with configurable "first-class" short
keybindings.

The "buffer-local" hooks from http://jedmodes.sf.net/mode/bufutils/ 
are a framework for such a setup.

E.g. I define in my private setup:

setkey("run_buffer", "^[^M");    % Alt-Return: evaluate buffer/region

(with run_buffer() from http://jedmodes.sf.net/mode/bufutils/ )
and set up hooks like:

mode_set_mode_info("latex", "run_buffer_hook", "latex_compose");

or

mode_set_mode_info("SLang", "run_buffer_hook",  "slang_run_buffer");
define slang_mode_hook()
{
   % ... 
   % Evaluating (Run the buffer)
   push_spot_bob();
   if (fsearch("require(\"unittest\");"))
      define_blocal_var("run_buffer_hook", "test_buffer");
   % ... other commands ...   
}

(again with some locally defined functions).

Günter


 

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


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