git: 57777718bded - main - editors/lite: the port had been improved (part two)

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Mon, 11 Jul 2022 09:27:55 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=57777718bded8d4b025863b893b6b9efc3b27753

commit 57777718bded8d4b025863b893b6b9efc3b27753
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2022-07-11 09:27:12 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2022-07-11 09:27:12 +0000

    editors/lite: the port had been improved (part two)
    
    - Install additional plugins, but abstain from automatically
      loading them all: unlike syntax highlight ones, some of them
      might change editor's behavior in potentially unwanted ways
    - Save the crash error log in the user's home directory
---
 editors/lite/Makefile                       |  2 ++
 editors/lite/files/patch-data_core_init.lua | 26 +++++++++++++-----
 editors/lite/files/patch-src_main.c         |  3 ++-
 editors/lite/pkg-plist                      | 42 +++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/editors/lite/Makefile b/editors/lite/Makefile
index a8dd5403cbc2..4d989df3a935 100644
--- a/editors/lite/Makefile
+++ b/editors/lite/Makefile
@@ -45,6 +45,8 @@ do-install:
 	${CP} -a ${WRKSRC_colors}/colors ${STAGEDIR}${DATADIR}/user
 	${MV} ${WRKSRC_plugins}/plugins/language_*.lua \
 		${STAGEDIR}${DATADIR}/plugins
+	${CP} -a ${WRKSRC_plugins}/plugins \
+		${STAGEDIR}${DATADIR}/plugins/extra
 
 do-install-DOCS-on:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
diff --git a/editors/lite/files/patch-data_core_init.lua b/editors/lite/files/patch-data_core_init.lua
index 7d13910080af..e0ec26783801 100644
--- a/editors/lite/files/patch-data_core_init.lua
+++ b/editors/lite/files/patch-data_core_init.lua
@@ -5,7 +5,7 @@
    Doc = require "core.doc"
  
 -  local project_dir = EXEDIR
-+  local project_dir = os.getenv("HOME") or EXEDIR
++  local project_dir = HOMEDIR
    local files = {}
    for i = 2, #ARGS do
      local info = system.get_file_info(ARGS[i]) or {}
@@ -29,21 +29,35 @@
        .. string.format("%06x", temp_file_counter) .. (ext or "")
  end
  
-@@ -174,7 +174,7 @@ function core.load_plugins()
+@@ -174,16 +174,18 @@ function core.load_plugins()
  
  function core.load_plugins()
    local no_errors = true
 -  local files = system.list_dir(EXEDIR .. "/data/plugins")
+-  for _, filename in ipairs(files) do
+-    local modname = "plugins." .. filename:gsub(".lua$", "")
 +  local files = system.list_dir(DATADIR .. "/plugins")
-   for _, filename in ipairs(files) do
-     local modname = "plugins." .. filename:gsub(".lua$", "")
++  for _, filename in ipairs(files) do repeat
++    local luafile = filename:match("(.*)%.lua$")
++    if not luafile then break end
++    local modname = "plugins." .. luafile
      local ok = core.try(require, modname)
-@@ -464,7 +464,7 @@ function core.on_error(err)
+     if ok then
+       core.log_quiet("Loaded plugin %q", modname)
+     else
+       no_errors = false
+     end
+-  end
++  until true end
+   return no_errors
+ end
+ 
+@@ -464,7 +466,7 @@ function core.on_error(err)
  
  function core.on_error(err)
    -- write error to file
 -  local fp = io.open(EXEDIR .. "/error.txt", "wb")
-+  local fp = io.open("/tmp/lite-error.txt", "wb")
++  local fp = io.open(HOMEDIR .. "/lite-error.txt", "wb")
    fp:write("Error: " .. tostring(err) .. "\n")
    fp:write(debug.traceback(nil, 4))
    fp:close()
diff --git a/editors/lite/files/patch-src_main.c b/editors/lite/files/patch-src_main.c
index 1041196a88a6..bfb59f4a3b10 100644
--- a/editors/lite/files/patch-src_main.c
+++ b/editors/lite/files/patch-src_main.c
@@ -20,13 +20,14 @@
  #else
    strcpy(buf, "./lite");
  #endif
-@@ -123,8 +129,9 @@ int main(int argc, char **argv) {
+@@ -123,8 +129,10 @@ int main(int argc, char **argv) {
      "  SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n"
      "  PATHSEP = package.config:sub(1, 1)\n"
      "  EXEDIR = EXEFILE:match(\"^(.+)[/\\\\].*$\")\n"
 -    "  package.path = EXEDIR .. '/data/?.lua;' .. package.path\n"
 -    "  package.path = EXEDIR .. '/data/?/init.lua;' .. package.path\n"
 +    "  DATADIR = '%%DATADIR%%'\n"
++    "  HOMEDIR = os.getenv('HOME') or '/'\n"
 +    "  package.path = DATADIR .. '/?.lua;' .. package.path\n"
 +    "  package.path = DATADIR .. '/?/init.lua;' .. package.path\n"
      "  core = require('core')\n"
diff --git a/editors/lite/pkg-plist b/editors/lite/pkg-plist
index e4b7eac16d10..fbfd3e40f992 100644
--- a/editors/lite/pkg-plist
+++ b/editors/lite/pkg-plist
@@ -29,6 +29,48 @@ bin/lite
 %%DATADIR%%/fonts/monospace.ttf
 %%DATADIR%%/plugins/autocomplete.lua
 %%DATADIR%%/plugins/autoreload.lua
+%%DATADIR%%/plugins/extra/autoinsert.lua
+%%DATADIR%%/plugins/extra/autowrap.lua
+%%DATADIR%%/plugins/extra/bigclock.lua
+%%DATADIR%%/plugins/extra/bracketmatch.lua
+%%DATADIR%%/plugins/extra/centerdoc.lua
+%%DATADIR%%/plugins/extra/closeconfirmx.lua
+%%DATADIR%%/plugins/extra/colorpreview.lua
+%%DATADIR%%/plugins/extra/copyfilelocation.lua
+%%DATADIR%%/plugins/extra/datetimestamps.lua
+%%DATADIR%%/plugins/extra/detectindent.lua
+%%DATADIR%%/plugins/extra/dragdropselected.lua
+%%DATADIR%%/plugins/extra/drawwhitespace.lua
+%%DATADIR%%/plugins/extra/eval.lua
+%%DATADIR%%/plugins/extra/exec.lua
+%%DATADIR%%/plugins/extra/ghmarkdown.lua
+%%DATADIR%%/plugins/extra/gitstatus.lua
+%%DATADIR%%/plugins/extra/gofmt.lua
+%%DATADIR%%/plugins/extra/hidelinenumbers.lua
+%%DATADIR%%/plugins/extra/hidestatus.lua
+%%DATADIR%%/plugins/extra/inanimate.lua
+%%DATADIR%%/plugins/extra/indentguide.lua
+%%DATADIR%%/plugins/extra/lastproject.lua
+%%DATADIR%%/plugins/extra/lfautoinsert.lua
+%%DATADIR%%/plugins/extra/linecopypaste.lua
+%%DATADIR%%/plugins/extra/lineguide.lua
+%%DATADIR%%/plugins/extra/macmodkeys.lua
+%%DATADIR%%/plugins/extra/markers.lua
+%%DATADIR%%/plugins/extra/motiontrail.lua
+%%DATADIR%%/plugins/extra/openfilelocation.lua
+%%DATADIR%%/plugins/extra/openselected.lua
+%%DATADIR%%/plugins/extra/projectmanager.lua
+%%DATADIR%%/plugins/extra/rainbowparen.lua
+%%DATADIR%%/plugins/extra/scale.lua
+%%DATADIR%%/plugins/extra/scalestatus.lua
+%%DATADIR%%/plugins/extra/selectionhighlight.lua
+%%DATADIR%%/plugins/extra/sort.lua
+%%DATADIR%%/plugins/extra/spellcheck.lua
+%%DATADIR%%/plugins/extra/tabnumbers.lua
+%%DATADIR%%/plugins/extra/titleize.lua
+%%DATADIR%%/plugins/extra/togglesnakecamel.lua
+%%DATADIR%%/plugins/extra/unboundedscroll.lua
+%%DATADIR%%/plugins/extra/workspace.lua
 %%DATADIR%%/plugins/language_angelscript.lua
 %%DATADIR%%/plugins/language_batch.lua
 %%DATADIR%%/plugins/language_c.lua