Skip to content

Commit

Permalink
Fixed issue kevinstadler#12
Browse files Browse the repository at this point in the history
Fixed issue kevinstadler#12 . I wasn't able to directly alter the values of setting through the API's .set() function, so I created a function returning a copy of the settings instead.

If someone knows how to load the default settings, that would be better than using a hardcoded dictionary with their values.
  • Loading branch information
mazunki committed Oct 19, 2019
1 parent e78ad8a commit 9134922
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion WordCount.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
import re

settings = None
LATEX_DEFAULTS = {
'exclude_abstract': True,
'exclude_headers': True,
'markup_commands': ['text\\w+', 'uppercase', 'uline', 'emph'],
'exclude_appendices': True,
'exclude_footnotes': True
}


def load_settings():
global settings
settings = sublime.load_settings("LaTeXWordCount.sublime-settings")


def load_latex_settings(settings):
temp_settings = dict()
for conf, default_value in LATEX_DEFAULTS.items():
temp_settings[conf] = settings.get(conf, default_value)
return temp_settings


def plugin_loaded():
load_settings()

Expand Down Expand Up @@ -65,7 +79,7 @@ def wrap(func):
@custom_wordcount("LaTeX")
def wordcount_latex(text):
global settings
latex_settings = settings.get("LaTeX")
latex_settings = load_latex_settings(settings)

# strip latex comments
text = latex_comment.sub(" ", text)
Expand Down

0 comments on commit 9134922

Please sign in to comment.