Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make editor local. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make editor local. #14

wants to merge 1 commit into from

Conversation

bjornbm
Copy link
Contributor

@bjornbm bjornbm commented May 7, 2023

A benefit of making editor local would be that there is no risk of:

  • accidentally using it in, for example, buffer.lua (I'm sure you wouldn't but maybe a well-meaning patch might…), or
  • something silly like ple_init setting editor = nil breaking the editor (which now will cause the below but with 933b2b3 does not crash).
/Users/bjorn/repos/ple/ple.lua:220: attempt to index a nil value (global 'editor')                                              
stack traceback:
	/Users/bjorn/repos/ple/ple.lua:220: in field 'statusline'
	/Users/bjorn/repos/ple/ple.lua:348: in upvalue 'adjcursor'
	/Users/bjorn/repos/ple/ple.lua:391: in upvalue 'redisplay'
	/Users/bjorn/repos/ple/ple.lua:416: in field 'fullredisplay'
	/Users/bjorn/repos/ple/ple.lua:797: in field 'newbuffer'
	/Users/bjorn/repos/ple/ple.lua:1085: in function </Users/bjorn/repos/ple/ple.lua:1080>
	[C]: in function 'xpcall'
	/Users/bjorn/repos/ple/ple.lua:1133: in local 'main'
	/Users/bjorn/repos/ple/ple.lua:1147: in main chunk
	[C]: in function 'dofile'
	/Users/bjorn/bin/ple:5: in main chunk
	[C]: in

Supersedes #10.

Refer to discussion in pull request philanc#10.
@bjornbm bjornbm mentioned this pull request May 7, 2023
@@ -1051,17 +1051,18 @@ local function editor_loadinitfile()
-- function to be executed before entering the editor loop
-- could be used to load a configuration/initialization file
local initfile = os.getenv("PLE_INIT")
local env = {editor = editor, table.unpack(_G)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit wasted effort in case no initfile is found. Also there is some duplication on the lines below (1056, 1060, 1065).

Let me know if you prefer to also separate the locating and the loading of the initfile as in 8280237 (addresses the wasted effort and duplication).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant