mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] Changing F9-F12 keys for presentation mode


Chronological Thread 
  • From: Henri Lesourd <address@hidden>
  • To: address@hidden
  • Cc: address@hidden
  • Subject: Re: [TeXmacs] Changing F9-F12 keys for presentation mode
  • Date: Sun, 13 May 2007 21:23:10 +0200

Philip Welch wrote:


Dear Henri,
I did not have much success with the code you sent me.
Q1 What are the ]] ?

This is just a notation to delimit the beginning and the end
of the code in the e-mail I sent, this is not part of the code
itself (i.e., it's like writing "<< Hello >>", or "[[ Hello ]]",
with the "<<" and ">>", or the "[[" and "]]" used to delimit
the "Hello".


Q2 Where should I put the code?
I tried appending it to Example1.scm but got the attached result.

Thats the appropriate way to do, although appending in the
beginning (but *after* the starting (texmacs-module ...) statement)
would be better style.


This being said, the code was buggy due to its needed use from
inside the module example1. Below is a corrected version :
[[
;; Permanent key mappings
(define-public kbd-map-old kbd-map)
(define-public kbd-map-looping #f)
(define-public-macro (kbd-map . l)
`(begin
(kbd-map-old . ,l)
(if (not kbd-map-looping)
(begin
(set! kbd-map-looping #t)
(always-key-mappings)
(set! kbd-map-looping #f)))))

(define-public (always-key-mappings) (lambda () #t))
(define-public always-key-mappings0 always-key-mappings)

(define-public keyboard-extend-forever-nb 0)
(define-macro (keyboard-extend-forever . body)
(define akm0 "")
(define akm1 "")
(set! akm0 (string->symbol (string-append "always-key-mappings"
(number->string keyboard-extend-forever-nb))))
(set! keyboard-extend-forever-nb (+ keyboard-extend-forever-nb 1))
(set! akm1 (string->symbol (string-append "always-key-mappings"
(number->string keyboard-extend-forever-nb))))
`(begin
(define-public (,akm1)
,(cons 'kbd-map body)
(,akm0))
(set! always-key-mappings ,akm1)))
]]


You must also write the redefine keyboard statements outside any
function, i.e., replace the previous :
[[
; Initialization routine
(tm-define (example1-initialize)
; A keyboard shortcut
(kbd-map ("C-i" (display "Example1\n")))
(kbd-map ("C-u" (example1-shortcut2)))
(display* "Loading Example1...\n"))
]]

by :
[[
; Keyboard shortcuts
(keyboard-extend-forever ("C-i" (display "Example1\n")))
(keyboard-extend-forever ("C-u" (example1-shortcut2)))

; Initialization routine
(tm-define (example1-initialize)
(display* "Loading Example1...\n"))
]]


Given this Example1 plugin, all the keyboard shortcuts you will
redefine by means of adding other (keyboard-extend-forever ...)
statements will thus take precedence over all the other ones (including
the predefined / standard TeXmacs ones).


Best, Henri




Archive powered by MHonArc 2.6.19.

Top of page