Skip to content

Commit

Permalink
Harmonize function names with snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
Athozus committed Mar 22, 2024
1 parent 6f7ccc7 commit 1c5e4b6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ function mail.send(m)
-- normalize to, cc and bcc while compiling a list of all recipients
local recipients = {}
local undeliverable = {}
m.to = mail.concat_player_list(mail.extractMaillists(m.to, m.from))
m.to = mail.concat_player_list(mail.extract_maillists(m.to, m.from))
m.to = mail.normalize_players_and_add_recipients(m.from, m.to, recipients, undeliverable)
if m.cc then
m.cc = mail.concat_player_list(mail.extractMaillists(m.cc, m.from))
m.cc = mail.concat_player_list(mail.extract_maillists(m.cc, m.from))
m.cc = mail.normalize_players_and_add_recipients(mail.from, m.cc, recipients, undeliverable)
end
if m.bcc then
m.bcc = mail.concat_player_list(mail.extractMaillists(m.bcc, m.from))
m.bcc = mail.concat_player_list(mail.extract_maillists(m.bcc, m.from))
m.bcc = mail.normalize_players_and_add_recipients(m.from, m.bcc, recipients, undeliverable)
end

Expand Down
4 changes: 2 additions & 2 deletions storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ local function extract_maillists_main(receivers, maillists_owner, expanded_recei
end
end

function mail.extractMaillists(receivers, maillists_owner)
function mail.extract_maillists(receivers, maillists_owner)
local expanded_receivers = {}
extract_maillists_main(receivers, maillists_owner, expanded_receivers, {})
return expanded_receivers
Expand Down Expand Up @@ -478,7 +478,7 @@ function mail.reset_settings(playername)
mail.set_storage_entry(playername, entry)
end

function mail.pairsByKeys(t, f)
function mail.pairs_by_keys(t, f)
-- http://www.lua.org/pil/19.3.html
local a = {}
for n in pairs(t) do table.insert(a, n) end
Expand Down
4 changes: 2 additions & 2 deletions ui/contacts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)

if fields.contacts then
local evt = minetest.explode_table_event(fields.contacts)
for k, _, i in mail.pairsByKeys(contacts) do
for k, _, i in mail.pairs_by_keys(contacts) do
if i == evt.row - 1 then
mail.selected_idxs.contacts[name] = tonumber(k)
break
Expand Down Expand Up @@ -58,7 +58,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- except if it was the last. Then determine the new last
local found = false
local last = nil
for k in mail.pairsByKeys(contacts) do
for k in mail.pairs_by_keys(contacts) do
if found then
mail.selected_idxs.contacts[name] = tonumber(k)
break
Expand Down
6 changes: 3 additions & 3 deletions ui/events.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

-- Getter to filter and sort messages on demand
local function messageGetter(messages, sortfield, ascending, filter)
local function message_getter(messages, sortfield, ascending, filter)
local results
return function()
if not results then
Expand Down Expand Up @@ -54,8 +54,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local entry = mail.get_storage_entry(name)
local messagesDrafts = entry.drafts
local messagesTrash = entry.trash
local getInbox = messageGetter(entry.inbox, inboxsortfield, sortdirection == "2", filter)
local getOutbox = messageGetter(entry.outbox, outboxsortfield, sortdirection == "2", filter)
local getInbox = message_getter(entry.inbox, inboxsortfield, sortdirection == "2", filter)
local getOutbox = message_getter(entry.outbox, outboxsortfield, sortdirection == "2", filter)

-- Hanmdle formspec event
if fields.inbox then -- inbox table
Expand Down
2 changes: 1 addition & 1 deletion ui/maillists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- except if it was the last. Then determine the new last
local found = false
local last = nil
for k in mail.pairsByKeys(maillists) do
for k in mail.pairs_by_keys(maillists) do
if found then
mail.selected_idxs.maillists[name] = k
break
Expand Down
8 changes: 4 additions & 4 deletions ui/message.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local S = minetest.get_translator("mail")

local FORMNAME = "mail:message"

local function interleaveMsg(body)
local function interleave_msg(body)
return "> " .. (body or ""):gsub("\n", "\n> ")
end

Expand Down Expand Up @@ -78,7 +78,7 @@ function mail.reply(name, message)
minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs))
return
end
mail.show_compose(name, message.from, "Re: "..message.subject, interleaveMsg(message.body))
mail.show_compose(name, message.from, "Re: "..message.subject, interleave_msg(message.body))
end

function mail.replyall(name, message)
Expand Down Expand Up @@ -113,11 +113,11 @@ function mail.replyall(name, message)
end
cc = mail.concat_player_list(cc)

mail.show_compose(name, recipients, "Re: "..message.subject, interleaveMsg(message.body), cc)
mail.show_compose(name, recipients, "Re: "..message.subject, interleave_msg(message.body), cc)
end

function mail.forward(name, message)
mail.show_compose(name, "", "Fw: " .. (message.subject or ""), interleaveMsg(message.body))
mail.show_compose(name, "", "Fw: " .. (message.subject or ""), interleave_msg(message.body))
end

minetest.register_on_player_receive_fields(function(player, formname, fields)
Expand Down
2 changes: 1 addition & 1 deletion ui/select_contact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields[v.."add"] then
update = true
if mail.selected_idxs.contacts[name] then
for k, contact, i in mail.pairsByKeys(contacts) do
for k, contact, i in mail.pairs_by_keys(contacts) do
if k == mail.selected_idxs.contacts[name] or i == mail.selected_idxs.contacts[name] then
local list = mail.parse_player_list(draft[v])
list[#list+1] = contact.name
Expand Down
4 changes: 2 additions & 2 deletions util/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local function rgb2hex(rgb)
return "#" .. string.format("%x", rgb.r) .. string.format("%x", rgb.g) .. string.format("%x", rgb.b)
end

local function rgbColorsMix(colors)
local function rgb_colors_mix(colors)
local R = 0
local G = 0
local B = 0
Expand All @@ -52,7 +52,7 @@ function mail.get_color(mix)
for _, c in ipairs(mix) do
colors2mix[#colors2mix+1] = hex2rgb(get_base_color(c))
end
local mixed_color = rgbColorsMix(colors2mix)
local mixed_color = rgb_colors_mix(colors2mix)
return rgb2hex(mixed_color)
end
end
2 changes: 1 addition & 1 deletion util/contact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function mail.compile_contact_list(name, selected, playernames)

if playernames == nil then
local length = 0
for k, contact, i, l in mail.pairsByKeys(contacts) do
for k, contact, i, l in mail.pairs_by_keys(contacts) do
if i == 1 then length = l end
formspec[#formspec + 1] = ","
formspec[#formspec + 1] = ","
Expand Down

0 comments on commit 1c5e4b6

Please sign in to comment.