Subject: Re: [SWIPL] Editing shortcuts in PCE Emacs

From: "Lesta" <[email-masked]>
Date: Tue, 4 Sep 2001 09:30:13 +0200

----- Original Message -----
From: "Sue Ann Koay" <[email-masked]>
To: <[email-masked]>
Sent: Monday, September 03, 2001 11:00 PM
Subject: [SWIPL] Editing shortcuts in PCE Emacs

> I hate to ask such a newbie question, but I can't for the life of me
figure
> out how to do use shortcut keys to do text copying and pasting in PCE
Emacs
> (sorry, I'm not familiar with Emacs, and can't figure out how to re-bind
> keys in PCE Emacs either). I'd like to press a shortcut key to copy some
> selected text and later paste it. I tried something called "yank", but it
> doesn't seem to work consistently...?

- 1) see the emacs manual
- 2) mark a text with the mouse, go to the target place and press the middel
mouse button
- 3) use my pceemacsrc file and use
       crtl + 'insert'   -->  copy
       shift + 'insert  --> paste
       shift + 'del'     --> cut
     it's windows like :-)

below you will find my '.pceemacsrc' file. put it into your $home directory
use it as an example. See crtl+'F3' , 'shift'+'F3' ...
it works like the search keys in the $microsoft$ visual studio

good luck

Uwe

-----------------------------------------------------
:- pce_extend_class(emacs_editor).

:- pce_global(@modifier_shift, new(modifier(shift:=down))).
:- pce_global(@modifier_control, new(modifier(control:=down))).
:- pce_global(@modifier_meta, new(modifier(meta:=down))).

cursor_move_key(page_up).
cursor_move_key(page_down).
cursor_move_key(d).

special_key_d(E):->
 "Start grep extention when shift crtl d ist pressed"::
 write_ln(d_was_pressed),trace,
 (   (send(@event, has_modifier, @modifier_control), send(@event,
has_modifier, @modifier_shift))
 ->  send(@grep_ext, open)
 ;   send(E, insert_self, character:=d)
 ).

win_insert(E) :->
 "insert was depressed"::
 (   send(@event, has_modifier, @modifier_control)
 ->  send(E, copy)
 ;   (   send(@event, has_modifier, @modifier_shift)
     ->  send(E, paste)
     ;   true
     )
 ).

win_del(E) :->
        "del was depressed"::
        (   send(@event, has_modifier, @modifier_shift)
        ->  send(E, cut)
        ;   send(E, del)
        ).

win_fkey3(E) :->
        "key_top_3 was depressed"::
        (   send(@event, has_modifier, @modifier_control)
        ->  send(E, fkey3_crtl_search)
        ;   true
        ),
        (   send(@event, has_modifier, @modifier_shift)
        ->  send(E, fkey3_search_help, E?caret-1, 0)
        ;   send(E, fkey3_search_help, E?caret, ?(E?text_buffer,slot,size))
        ).

win_fkey1(E) :->
 "key_top_1 was depressed test only"::
 get(E?text_buffer, slot, size, SIZE),
 get(E, caret, C),
 writef('Size = %w Caret = %w\n',[SIZE, C]),
 nl.

print_modifiers(Ev):-
 new(Str, string),
 (   send(Ev, has_modifier, @modifier_control)
 ->  send(Str, append, 'crtl_'); true
 ),
 (   send(Ev, has_modifier, @modifier_shift)
 ->  send(Str, append, 'shift_'); true
 ),
 (   send(Ev, has_modifier, @modifier_meta)
 ->  send(Str, append, 'alt'); true
 ),
 get(Str, value, S),
 (   get(S, size, 0)
 ->  true; write_ln(S)
 ).

win_fkey8(_):->
  send(@grep_ext, open).

:- pce_end_class.

%---------------------------------------------------

:- pce_autoload(grep_ext, my_lib(grep_ext)).
:- pce_global(@grep_ext, new(grep_ext)).

:- emacs_extend_mode(fundamental,
       [
        special_key_d            = key(d),
        win_insert               = key(insert),
        win_del                  = key(del),
        win_fkey3                = key(key_top_3),
        win_fkey8                = key(key_top_8),
        win_fkey1                = key(key_top_1)
       ]).

special_key_d(E):->
 "Start grep extention when shift crtl d ist pressed"::
 write_ln(d_was_pressed),trace,
 (   (send(@event, has_modifier, @modifier_control), send(@event,
has_modifier, @modifier_shift))
 ->  send(@grep_ext, open)
 ;   send(E, insert_self, character:=d)
 ).

fkey3_crtl_search(E) :->
 "Find the word where the caret is in"::
 (   get(E, selected, SP)
 ->  true
 ;   get(E?word, value, SP)
 ),
 send(E, attribute, attribute(f3search_regex, regex(SP))).

fkey3_search_help(E, SearchStart, SearchEnd) :->
 "f3 search helper"::
 get(E, attribute, f3search_regex, Regex),
 (   send(Regex, search, E?text_buffer, SearchStart, SearchEnd)
 ->  get(Regex, register_start, Start),
     get(Regex, register_end, End),
     send(E, caret, End),
     send(E, selection, Start, End)
 ;   send(E, report, status, 'Done.'),
     send(E, focus_function, @nil),
     %send(E?text_cursor, displayed, @on),
     fail
 ).

:- emacs_end_mode.

:- emacs_extend_mode(prolog,
       [
        backward_predicate       = key(key_top_4),
        forward_predicate        = key(key_top_5),
        dabbrev_expand           = key('\ey')
       ]).

:- emacs_end_mode.