joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

Leading parenthesis is not displayed in the menu #1059

Open saf-dmitry opened 4 years ago

saf-dmitry commented 4 years ago

When an abbreviation starts with the left parenthesis ((), this parenthesis is not shown up in the YASnippet snippets menu.

Software Versions:

npostavs commented 4 years ago

Can you show the whole snippet that you are talking about? It seems to work here (but maybe this is macOS specific? I know it has a different menu system)

saf-dmitry commented 4 years ago

Sure. Here is the snippet:

# -*- mode: snippet -*-
# name: parentheses
# key: ()
# group: Math – Delimiters
# condition: (yas-texmathp)
# --
\left( $0 \right)

and here the corresponding menu selection:

Screenshot 2020-07-14 at 13 01 46

npostavs commented 4 years ago

Hmm, I guess you've customized yas-trigger-symbol? I'm puzzled what code is apparently wrapping the the snippet's abbrev key in parens though (afaict yas-trigger-symbol only allows putting a string between the name and key). Can you reproduce this starting from emacs -Q?

saf-dmitry commented 4 years ago

Hmm, I guess you've customized yas-trigger-symbol?

Here the menu selection without customization of yas-trigger-symbol:

Screenshot 2020-07-15 at 12 05 59

I expected to see here something like parentheses (() =>) and not parentheses () =>).

Can you reproduce this starting from emacs -Q?

Yes, I can reproduce the issue.

npostavs commented 4 years ago

Can you show the resulting "Test Menu" entry after evaluating the elisp below in a fresh emacs -Q session:

(defun test-fun ()
  (interactive)
  (message "ran the test fun"))

(defvar menu-bar-test-menu (make-sparse-keymap "Test Menu"))
(define-key menu-bar-test-menu [test-fun]
  '(menu-item "Test Menu Item" test-fun . (:keys "C-c x")))
(define-key menu-bar-test-menu [test-fun-paren]
  '(menu-item "Test Menu Item paren :keys" test-fun . (:keys "()")))

(define-key global-map [menu-bar menu-bar-test]
  (list 'menu-item "Test Menu" menu-bar-test-menu))

Here's what I get:

test-menu

saf-dmitry commented 4 years ago

Can you show the resulting "Test Menu" entry after evaluating the elisp below in a fresh emacs -Q session:

Here is what I get:

Screenshot 2020-07-17 at 14 35 44 You are right, the issue is macOS-specific. macOS wraps item keys in parentheses and this "eats" a leading left parenthesis being part of a key expression.