Skip to content

Add an imap for Feynman slash notation#1611

Closed
rsekman wants to merge 2 commits intolervag:masterfrom
rsekman:master
Closed

Add an imap for Feynman slash notation#1611
rsekman wants to merge 2 commits intolervag:masterfrom
rsekman:master

Conversation

@rsekman
Copy link
Copy Markdown
Contributor

@rsekman rsekman commented Feb 28, 2020

`/p -> \slashed{p}

One can also imagine similar mappings like `_v -> \mathbf{v}.

Robin Ekman added 2 commits February 28, 2020 17:09
We need to add a flag to g:vimtex_imaps_list entries that tell vimtex not to call string() on the rhs to make this possible.
endif
let b:vimtex_context[l:key] = a:map.context
endif
if ! get(a:map, 'expr', 0)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer:

   if !get(a:map, 'expr') 

The 0 is default and the space after ! is unnecessary, IMHO.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Feb 29, 2020

I like this idea. It is simple and provide some extra utility. However, I'm curious, is it possible to make it slightly more "general"? If not, then I'd prefer to keep the Feynman specific stuff out and instead only add the part that allows the functionality. This allows you to add the Feynman map in your own custom configuration without too much inconvenience.

Note: The tests do not pass. So there is something that is not quite right yet.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Feb 29, 2020

The tests fail due to a minor error on my part. I'll push a fix for it now, please rebase your work on top of new master (i.e. with git rebase master then git push --force).

lervag added a commit that referenced this pull request Feb 29, 2020
@rsekman
Copy link
Copy Markdown
Contributor Author

rsekman commented Feb 29, 2020

I like this idea. It is simple and provide some extra utility. However, I'm curious, is it possible to make it slightly more "general"? If not, then I'd prefer to keep the Feynman specific stuff out and instead only add the part that allows the functionality. This allows you to add the Feynman map in your own custom configuration without too much inconvenience.

I agree, there are several similar applications, like, \mathbf, \mathfrak, \overline, \mathcal. The reason I coded it like this is I like how vimtex's imaps activate only in math mode.

The general pattern is c -> \$command{c}, which my function is easily extended to handle. So perhaps we could consider a new "class" of imaps {'lhs': '/', 'rhs': 'slashed', } -- maybe with a prefix different from `, since most of those are already taken. I don't think # is used much in math mode, so that could be an idea.

@rsekman
Copy link
Copy Markdown
Contributor Author

rsekman commented Feb 29, 2020

Closing in favor of #1612 which is more general.

@rsekman rsekman closed this Feb 29, 2020
@lervag
Copy link
Copy Markdown
Owner

lervag commented Mar 1, 2020

Great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants