jfbercher / jupyter_latex_envs

(Some) LaTeX environments for Jupyter
Other
112 stars 28 forks source link

Customize hotkeys for inserting equation and itemize environments #15

Closed moble closed 7 years ago

moble commented 7 years ago

I frequently use Ctrl-E to jump to the end of a line. Unfortunately, that clashes with this extension, which uses that hotkey to insert an equation environment. I don't have the time just now to do this myself, but I'd really appreciate an option in the configurator to customize that hotkey. Something like this is needed in latex_envs.yaml:

- name: latex_envs.equation_hotkey
  description: Hotkey used to insert equation environment
  input_type: hotkey
  default: Ctrl-E
- name: latex_envs.itemize_hotkey
  description: Hotkey used to insert itemize environment
  input_type: hotkey
  default: Ctrl-I

I can't quite figure out how the configuration is actually being loaded and used, though.

jfbercher commented 7 years ago

Yes, this is certainly a good idea. I will implement that though I have not lot of time myself, but it should not be very difficult. FYI, the config is loaded in the file initNb.js, and these shortcuts are used in envsLatex.js. For now you can simply directly edit envsLatex.js and change/remove the shortcut there.

moble commented 7 years ago

Yeah, I've solved it for myself for now. I tried solving it properly, but it looks like the envsLatex variable (which contains the hotkeys) gets read in before the configuration is loaded (even when I change the order of the require statements in latex_envs.js). I guess the variable could be explicitly adjusted in config_loaded_callback, but that doesn't seem right. This feels like enough of a development question that I'll leave the decision to you. :)

shanhaiying commented 7 years ago

I wish that environments such as $$...$$, $...$ or ( ...), [ ... ] can autocomplete in markdown cell, just like with latextools in sublime text.

jfbercher commented 7 years ago

@moble This was addressed in https://github.com/jfbercher/jupyter_latex_envs/commit/110dc0e167d01aed5999e6cec54edcdeba12760d

It is now possible to customize these hotkeys in the nbextensions_configurator. Additionally, one can still add other hotkeys in the envsLatex.json file. I renamed envsLatex.js into envsLatex.json and changed the format. Now the question of merging this file with user_envs.json and provide a general interface is open...

jfbercher commented 7 years ago

@shanhaiying Good idea! I have a long term plan to add autocompletion but this seems not easy at all! I still added a limited support for $..$, (..), {..} in https://github.com/jfbercher/jupyter_latex_envs/commit/575db8336241517de7fac249d27a702794a7d780

This was also pushed to pypi.

moble commented 7 years ago

@jfbercher Thanks! That works very nicely.