Re: [code] ` Follow up

From: Pedro Andres Aranda Gutierrez <>
Date: Wed, 4 Oct 2017 18:00:35 +0200

My own fix:

I included the following code in ~/.textadept/init.lua

-- Fix for the ` key in the spanish keyboard
local previous = nil
events.connect(events.KEYPRESS, function(code)
  local altcode = nil
  if previous == 65104 and code == 32 then
    altcode = string.byte('`')
  previous = code
  if altcode ~= nil then
    if textadept.editing.typeover_chars and
textadept.editing.typeover_chars[altcode] and
      buffer.selection_start == buffer.selection_end and
      buffer.char_at[buffer.current_pos] == altcode then
      return true
On 4 October 2017 at 14:50, Alberto González Palomo <>
>   Yes, the keypress event should produce two codes, because in the Spanish
> keyboard we get the backtick by combining the dead key for the grave accent
> with the space.
>   The issue here is that the auto_pair insertion uses event.CHAR_ADDED but
> typeover_chars uses event.KEYPRESS.
>   CHAR_ADDED gets the actual character produced by the input method in
> use, while KEYPRESS gets the individual key presses.
>   You can see this at "modules/textadept/editing.lua":
> textadept/editing.lua#l124
> textadept/editing.lua#l160
>   The solution I'd propose is to use CHAR_ADDED for both cases so that we
> always get the actual character.
>   Since this event fires after the character has been already inserted in
> the document, for typeover_chars instead of cancelling the event we need to
> remove the character.
>   Additionally, since both actions will be triggered by the same event, we
> can unify them to make sure that they run in the right order.
>   I attach the corresponding patch.
>   I've tested it with a Spanish keyboard, on Ubuntu Linux with TA 9.5.
>   It still needs some improvement: the character insertion gets into the
> undo history so it behaves a bit different from the original.
>   If instead of deleting the inserted char we undid its insertion it would
> be perfect, but calling "buffer:undo()" instead of "buffer:delete_back()"
> undoes too much.
>   I'm now taking a look at SC_MOD_INSERTCHECK [1] from Scintilla which
> allows modifying the text about to be inserted, but so far it seems not to
> be accessible from Textadept.
> [1]
>   Cheers,
> --
>     Alberto González Palomo
>     Toledo, España / Saarbrücken, Deutschland
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellet zu werden
Georg Kreisler
You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Wed 04 Oct 2017 - 12:00:35 EDT

This archive was generated by hypermail 2.2.0 : Thu 05 Oct 2017 - 06:47:59 EDT