all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Introspecting yas tab binding
@ 2024-02-03  2:14 Psionic K
  2024-02-03  6:11 ` tomas
  2024-02-03  8:06 ` Eli Zaretskii
  0 siblings, 2 replies; 12+ messages in thread
From: Psionic K @ 2024-02-03  2:14 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

> What is "Yas minor mode"?  I don't see it in Emacs 29 or in Emacs 30.

I will ignore what appears to me to be some kind of sarcastic
perversion of reality attempting to imply "go away, this is not
Emacs", which it most surely is not, and rephrase the question to
focus on Emacs specific elements.

I have identified a command by viewing lossage called
`mysterious-command`.  It is called in some situations when I press
TAB, but not always.

`where-is' reports that `mysterious-command' is not bound on any key.
Lossage reports:

 <tab>          ;; mysterious-command

I have found `mysterious-command' in a keymap menu item, and the key
definition matches the command I observe, but I cannot get debug to
trigger when using `debug-on-entry' on the function assigned as the
`:filter' in that menu item, so I'm unsure if the menu item is related
at all.

I can get a debugger for `mysterious-command' itself, which displays a
stack beginning with `command-execute', called only with
`mysterious-command'.   I need to discover how `mysterious-command' is
arrived at to work backwards toward the mechanism used to make it only
receive the TAB key in certain situations.

Evaluating (key-binding (kbd "TAB")) shows that the binding is
situational, returning different commands depending on the location of
the point, but still not how.   After following the code into
`lookup_key_1', I am expecting attaching a debugger will reveal that
the external state, the keymap with the menu item, is changed between
calls, but again not where this behavior originates.

What Emacs facilities might uncover the states and execution flow
responsible for this situational behavior for the TAB key sequence?
How can I identify or rule out the menu item's responsibility?



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Introspecting yas tab binding
@ 2024-02-03 13:47 Psionic K
  0 siblings, 0 replies; 12+ messages in thread
From: Psionic K @ 2024-02-03 13:47 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

It's solved.  The general method is described at the end.

> For the first question, we have trace.el, stepping through Lisp code
> in Edebug, and stepping through code in keyboard.c in GDB.  For the
> second, I would modify the offending menu entry in some way that would
> signal that it is responsible

I re-bound the command to "X" like so:

    (setcar  (car(last yas-minor-mode-map)) (string-to-char "X"))

This confirmed the responsibility of the menu binding, the contents of
which are:

    (9 menu-item "" yas-expand :filter yas-maybe-expand-abbrev-key-filter)

> The fact that :filter function cannot be debugged using debug-on-entry
> perhaps warrants a bug report.

I confirmed that `trace-function' was able to see the filter be
called.  However, debug-on-entry did not trigger a debugger session.

`key-binding' succeeds in uncovering that a binding exists, but not where it is.

Identifying keymaps from `current-active-maps' and corroborating the
symbol names with the obarray values, then calling `keymap-lookup'
appears to be viable.

The `keymap-lookup' returns nil or `yas-expand' depending on the
:filter result.  The user must configure the filter to be true to
observer the binding.  This is the only such conditional binding I
have observed in Emacs that didn't rely on variables in
`emulation-mode-alists` or modifying keymaps themselves.



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Introspecting yas tab binding
@ 2024-02-02 12:34 Psionic K
  2024-02-02 12:39 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Psionic K @ 2024-02-02 12:34 UTC (permalink / raw)
  To: help-gnu-emacs

As far as I can tell, Yas minor mode uses a menu item to define the tab binding.

In this case I knew where to look, and the keymap was simple.  I could
guess yas's minor mode keymap was responsible by turning the minor
mode off.  Still, it was not a  regular binding, and so I almost
missed it.

I do think I should be able to figure this out without the prior
knowledge.  I debugged the call but saw no evidence on the stack.
`where-is' for the command did not find the binding.  Command log and
lossage are both dead ends.

As far as I can tell, yas is using this menu hack to implement a form
of conditional binding, intercepting the key sequence conditionally
with a `:filter' function in the menu binding.

How should I have discovered this?



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-02-03 13:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-03  2:14 Introspecting yas tab binding Psionic K
2024-02-03  6:11 ` tomas
2024-02-03  6:43   ` Joost Kremers
2024-02-03  7:09     ` Emanuel Berg
2024-02-03  7:42     ` Eli Zaretskii
2024-02-03  7:57       ` Emanuel Berg
2024-02-03  6:54   ` Emanuel Berg
2024-02-03  8:06 ` Eli Zaretskii
2024-02-03  8:29   ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2024-02-03 13:47 Psionic K
2024-02-02 12:34 Psionic K
2024-02-02 12:39 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.