mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] Keybinding information


Chronological Thread 
  • From: K Vos <address@hidden>
  • To: Miguel de Benito Delgado <address@hidden>, address@hidden
  • Subject: Re: [TeXmacs] Keybinding information
  • Date: Mon, 17 Feb 2014 16:46:47 +0100

Thank you! This is just what I need to get started
.


On Sun, Feb 16, 2014 at 7:43 PM, Miguel de Benito Delgado <address@hidden> wrote:
Hi,

On Sun, Feb 16, 2014 at 6:49 PM, K Vos <address@hidden> wrote:
I am a new user of Texmacs.

Welcome!
 
1. How do I find out which keys are currently bound in the mode where the cursor is?

Easily, you can't, someone has to implement this. If you like hacking in scheme, either:

* you look at the files *-kbd.scm in the sources (edit-, math-, generic- ...) 

* inside a scheme session you use kbd-find-key-binding and kbd-find-rev-binding. See an unrelated recent post of mine (january the 12th, "minibuffer support in Qt version") for the latter. More on the former below.

About "current mode": The problem is that kbd-maps are defined using "contextual overloading", meaning that when a key is pressed all the kbd-maps associated to a given key combination are so to speak evaluated, and they check whether the cursor is at a math environment, or inside italics, or whatever. In other words: there is no per-mode "dispatch table", but a single one (not public) containing pointers to one procedure for each key combination. This procedure is actually a lot of ifs, one for each overloaded mode.

Hmmm, that wasn't exactly crystal clear...

2. Given a keybinding, how do I find out its definition?

The car of (kbd-find-key-binding "$") is the procedure which is executed when $ is pressed. To see the definition (after macro expansion, etc) you may use procedure-sources:

    (procedure-sources (car (kbd-find-key-binding "$")))

The keys are given in "raw" format, i.e. after replacing the wildcards you find in the kbd-maps (like "std", "macos" or whatever) with C, M, A, S. E.g. in my apple machine:

    (procedure-sources (car (kbd-find-key-binding "M-W")))

returns

    ((lambda () (safely-kill-window)))

As you can see, this is the "compiled" definition, not what you wrote in the kbd-map exactly. This is so because internally, pointers to the procedures are stored.
 
3. Give a Guile-function, how do I find the associated documentation(, if there is any)?

For guile functions there's the guile manual (version 1.8). For TeXmacs functions there's rarely any documentation, but when there is you may access it by right clicking on the procedure and selecting "Help with...". This works if you have Tools->Developer activated and the word you click on is inside a scheme environment (code snippet, scheme file, session, whatever)
 
3. How do I find out about existing guile functions which may be of use when defining my own set of keybindings for editing? I have found glue-editor.scm. Is this the only relevant file?

No. glue-editor.scm is only the scheme interface to the editor facilities provided in c++ code. Most of the stuff you actually want is written in scheme, in $TEXMACS_PATH/progs/*, but that's huge. You can search the code with shift+F1 or you can open up a little dialog which allows you to filter the list of all public procedures (after Tools->Developer has been activated, go to Developer->Open symbol browser). This is handy if you have a hunch about the possible name of something you are looking for (I just used it because I knew I was looking for something containing kbd and binding, just not what)

But your best friend is the manual. It's really thorough, although not exactly easy to peruse. Try to use the search in the docs (press F1) as much as possible. >80% of the time what you want will be there.
 
4. In general, what resources should I look into for finding out what the Guile-interface has to offer, as far as editing goes? Text and math editing is my priority at the moment.

To be pedantic guile is the name of the gnu scheme interpreter, and is unrelated to TeXmacs' facilities.

If you want inspiration, check any file named *-kbd.scm in the scheme sources. 
 
And ask here!

Best,
--
Miguel de  Benito.





Archive powered by MHonArc 2.6.19.

Top of page