From 5699cdb10dfdf93be8d1ae74bc94c23857ebf49a Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 4 Nov 2016 22:15:52 +0900 Subject: [PATCH 1/5] Update init.lua --- micro/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/micro/init.lua b/micro/init.lua index 60f3fd3..65f0079 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -2,6 +2,8 @@ local function getProperties(fullpath) -- TODO: Avoid command injection vulnerability + -- For example, following command will create file b.txt + -- $ micro "a.txt'; touch 'b.txt" local file = io.popen("editorconfig '" .. fullpath .. "'", "r") local output = file:read("*all") file:close() From 8e6fdd50108bd0c23eb44aec1437a9b1f614d9bd Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sat, 5 Nov 2016 19:26:50 +0900 Subject: [PATCH 2/5] Update micro init.lua --- micro/init.lua | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/micro/init.lua b/micro/init.lua index 65f0079..15b55cc 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -22,16 +22,46 @@ local function getProperties(fullpath) return properties end +local function setIndentation(properties, view) + local indent_size_str = properties["indent_size"] + local tab_width_str = properties["tab_width"] + local indent_style = properties["indent_style"] + + local indent_size = tonumber(indent_size, 10) + if indent_size ~= nil then + SetLocalOption("tabsize", indent_size, view) + end + + if indent_style == "space" then + messenger:Message("indent_style to space") + SetLocalOption("indentchar", " ", view) + elseif indent_style == "tab" then + messenger:Message("indent_style to tab") + SetLocalOption("indentchar", "\t", view) + else + messenger:Message("unknown indent_style") + end +end + function onViewOpen(view) -- Is this portable? (work on windows?) local pwd = os.getenv("PWD") local filename = view.Buf.Path -- prop, names = ec.parse(filepath) local fullpath = JoinPaths(pwd, filename) - local out = getProperties(fullpath) - messenger:Message("edconf: " .. out["indent_style"]) + local properties = getProperties(fullpath) + if properties["indent_style"] == nil then + messenger:Message("edconf: nil") + else + messenger:Message("edconf: " .. properties["indent_style"]) + end + + setIndentation(properties, view) + -- setCodingSystem(propertieps, view) end function onSave(view) messenger:Message("Saved!") end + +-- function getindentstyle() From 93dcf9fccd72d7c3286b86dede2505bbc26036d6 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Sun, 6 Nov 2016 18:49:53 +0900 Subject: [PATCH 3/5] Add super-save package to the list --- emacs.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/emacs.el b/emacs.el index 362e14b..3d54bf3 100644 --- a/emacs.el +++ b/emacs.el @@ -100,6 +100,7 @@ found, otherwise returns nil." gitignore-mode adoc-mode malabar-mode + ;; ack color-moccur ggtags @@ -120,6 +121,8 @@ found, otherwise returns nil." pkgbuild-mode minibuffer-line which-key + ;; I think this works in place of my autosave lib + super-save scala-mode ;;ensime From e6e9c3b76ba12e176c1cf011351f6895458523a2 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 15 Nov 2016 01:47:08 +0900 Subject: [PATCH 4/5] Fix micro init.lua --- micro/init.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/micro/init.lua b/micro/init.lua index 15b55cc..205a50a 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -27,19 +27,20 @@ local function setIndentation(properties, view) local tab_width_str = properties["tab_width"] local indent_style = properties["indent_style"] - local indent_size = tonumber(indent_size, 10) + local indent_size = tonumber(indent_size_str, 10) if indent_size ~= nil then + messenger:Message("set tabsize to " .. indent_size_str) SetLocalOption("tabsize", indent_size, view) end if indent_style == "space" then - messenger:Message("indent_style to space") - SetLocalOption("indentchar", " ", view) + -- messenger:Message("indent_style to space") + SetLocalOption("tabstospaces", "on", view) elseif indent_style == "tab" then - messenger:Message("indent_style to tab") - SetLocalOption("indentchar", "\t", view) + -- messenger:Message("indent_style to tab") + SetLocalOption("tabstospaces", "off", view) else - messenger:Message("unknown indent_style") + -- messenger:Message("unknown indent_style") end end @@ -56,6 +57,8 @@ function onViewOpen(view) messenger:Message("edconf: " .. properties["indent_style"]) end + -- SetLocalOption("tabsize", 4, view) + -- SetLocalOption("tabstospaces", "on", view) setIndentation(properties, view) -- setCodingSystem(propertieps, view) end From be010b0ed273607d3f3848498cae88817487f964 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 15 Nov 2016 02:04:36 +0900 Subject: [PATCH 5/5] Add some comments --- micro/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/micro/init.lua b/micro/init.lua index 205a50a..7826895 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -60,7 +60,14 @@ function onViewOpen(view) -- SetLocalOption("tabsize", 4, view) -- SetLocalOption("tabstospaces", "on", view) setIndentation(properties, view) - -- setCodingSystem(propertieps, view) + -- Currently micro does not support changing coding-systems + -- (Always use utf-8 with LF?) + -- setCodingSystem(properties, view) + -- `ruler' is not what we want! + -- setMaxLineLength(properties, view) + -- setTrimTrailingWhitespace(properties, view) + -- We have eofnewline! Use this! + -- setInsertFinalNewline(properties, view) end function onSave(view)