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

Persistent named sessions #1023

Closed
mizlan opened this issue May 20, 2021 · 14 comments
Closed

Persistent named sessions #1023

mizlan opened this issue May 20, 2021 · 14 comments

Comments

@mizlan
Copy link
Collaborator

mizlan commented May 20, 2021

Is your feature request related to a problem? Please describe.

Right now, you can either have a persistent default @ session (-S), or non-persistent named sessions (-s <name>)

Describe the solution you'd like

I want the ability to persist named sessions. This would help where nnn is embedded in text editors, for example.

Describe alternatives you've considered

I have not considered alternatives to having persistent named sessions as a concept, but there are definitely some options to be weighed when considering how to implement this (details linked in issue below).

Additional context

Please view mcchrish/nnn.vim#43 (comment) to understand the context of this request and the proposed solutions.

Consider contributing

I am more than eager to write this patch, but I need some pointers on how to proceed.

@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

Here's the deal. Currently, when both -S flag and -s <name> flag are passed, only the later one has any effect. This is because the value of session is overwritten during option parsing:

nnn/src/nnn.c

Lines 7766 to 7772 in 36e1544

case 's':
if (env_opts_id < 0)
session = optarg;
break;
case 'S':
session = "@";
break;

Also good to note is that nnn only checks if the session should be persistent when the program exits:

nnn/src/nnn.c

Lines 7189 to 7190 in 36e1544

if (session && *session == '@' && !session[1])
save_session(TRUE, NULL);

As a result, if we wanted to, we could have a named persistent session in the form of passing both flags in either order: nnn -S -s <name>.

@jarun
Copy link
Owner

jarun commented May 20, 2021

I am already working on it. In the same line so we are good.

@jarun jarun closed this as completed in 54d760b May 20, 2021
@jarun jarun mentioned this issue May 20, 2021
50 tasks
@mizlan mizlan reopened this May 20, 2021
@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

The behavior isn't exactly as desired. There is still an error message when I try to create a session that is nonexistent (I would instead expect for it to be created).

@jarun
Copy link
Owner

jarun commented May 20, 2021

It is created. The msg comes the first time you load it because it's non-existent.

@jarun
Copy link
Owner

jarun commented May 20, 2021

Maybe we can get rid of it now that we know we will create it if it doesn't exist.

@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

Yeah, I was referring to the error message. I agree with removing it since -s <name> will always succeed, but its behavior may differ.

@jarun
Copy link
Owner

jarun commented May 20, 2021

On second thoughts, I think we should have it to indicate that the session file doesn't exist.
It would be correct to indicate in cases where, say user had created the session earlier but somehow it was removed. He may want to be notified in that case. And it's also useful for us to debug later.

I am not sure why it's confusing. When you are creating the session for the first time, it doesn't exist and that's what the msg says. If you use option -S it will be created when you quit the program as documented.

@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

I see where you are coming from but I think there should be some method of disabling that, especially if the user is not directly controlling the session as in the case with nnn.vim. It would be odd for the user to see "failed!" or other messages when they expect it to be more discreet.

@Kabouik
Copy link
Collaborator

Kabouik commented May 20, 2021

How about rephrasing the error so that it looks like a simple warning/feedback about the newly created session?

@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

Sure. My main concern is mostly the 1-second delay that occurs with the error message. So if that could be removed that would be much better already.

@jarun
Copy link
Owner

jarun commented May 20, 2021

My main concern is mostly the 1-second delay that occurs with the error message.

It's necessary information.

How about rephrasing the error so that it looks like a simple warning/feedback about the newly created session?

I think it's just fine for a 1-time message. Let's not overthink. We can document it if we want. I do not want 3 people to spend time discussing it.

@mizlan
Copy link
Collaborator Author

mizlan commented May 20, 2021

I'll let you try it out after I'm done with the nnn.vim patch. I personally think its annoying, since a nice part of nnn is its fast startup time.

@jarun
Copy link
Owner

jarun commented May 20, 2021

OK.

@jarun
Copy link
Owner

jarun commented May 21, 2021

Closed at 54d760b.

@jarun jarun closed this as completed May 21, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants