nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] browser: remove opendir() for KEY_WINCH


From: Rishabh Dave
Subject: Re: [Nano-devel] [PATCH] browser: remove opendir() for KEY_WINCH
Date: Wed, 29 Jun 2016 19:57:29 +0530

On Tue, Jun 28, 2016 at 3:38 PM, Benno Schulenberg
<address@hidden> wrote:
> First, the goal is to remove duplicated code, and what you do is
> add other duplicated code.  :|

Stuff around "present_name" were mistakes, but do you hold same for
the code "newpath = strdup(present_path); goto
read_directory_contents;"? implying do you mean to remove /only/
opendir from KEY_WINCH and nothing else. Current approach will lead to
simpler code for a reader in future owing to lesser jumps.

> Sixth,
>   if ((path == NULL || dir == NULL) && kbinput != KEY_WINCH)
> bwah, that is ugly -- an error message should not depend on
> what "key" is pressed.

Asking out of curiosity, why so?

> And what does it do anyway?  If I remove
> the "&& kbinput != KEY_WINCH", nano behaves the same way.
>
> Ah, now I see.  It is meant to suppress a repetitive error message
> when resizing the window, but to allow the message when doing
> an explicit Refresh or coming back from Help.  Hmm.  It may be
> slightly annoying, but how often will people resize their windows
> when in the file browser /and/ in a directory that has become
> unreadable?  Not worth a special treatment.
>
> Also, try this:
>   src/nano, and then type ^R ^T M-G doc <Enter>
> In another terminal do: chmod a-x doc
> Change the size of the window of nano, then type ^L
> or ^G ^G.  For some reason you are now in the parent
> dir, at its last file.  ??
>

That was side effect of my addition here - "if ((path == NULL || dir
== NULL) && kbinput != KEY_WINCH)". (I prefer accuracy over beauty;
coincidentally I also found solution to that - condition the statement
"present_path = mallocstrcpy(present_path, path);" by "if (path !=
NULL)". It is up to you, though.)


Following is problem which I don't know how to tackle -

Currently if you change window size (with patch applied) an error
message appears saying - "Cannot open directory: Unknown error 1048"
even though selection remains and screen adapts properly. Error number
changes, but not arbitrarily. It is due to the code -  "if (kbinput ==
KEY_WINCH) goto read_directory_contents;". If I replace "goto
read_directory_contents;" by "browser_refresh();", error message
changes to "Unbound key" and still selection remains and screen adapts
properly. If I were to replace "goto read_directory_contents" by ";"
in a fresh repository, same error message would be received - "Unbound
key".

I read man page of opendir() as dir is NULL after opendir(path), but
there is no mention about "Unknown error ___". If I  follow approach
of remove-only-opendir-from-KEY_WINCH-block I am receiving same error
message.

I have attached improved version of previous patch that follow those
"six points".  :)

Attachment: remove-opendir-for-KEY_WINCH.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]