code: def save_current_keywords(self):
          
          current_keywords = self.get_keywords()
          try:
              self.keyword_io.write_keywords(
                  layer=self.layer, keywords=current_keywords)
          except InaSAFEError as e:
              error_message = get_error_message(e)
              # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
              QMessageBox.warning(
                  self,
                  tr('InaSAFE'),
                  tr('An error was encountered when saving the following '
                     'keywords:\n {error_message}').format(
                      error_message=error_message.to_html()))
          if self.dock is not None:
              # noinspection PyUnresolvedReferences
              self.dock.get_layers()
  
          # Save default value to QSetting
          if current_keywords.get('inasafe_default_values'):
              for key, value in (
                      list(current_keywords['inasafe_default_values'].items())):
                  set_inasafe_default_value_qsetting(
                      self.setting, RECENT, key, value)
docs: Save keywords to the layer.
  
          It will write out the keywords for the current layer.
          This method is based on the KeywordsDialog class.