Git Product home page Git Product logo

Comments (11)

olethanh avatar olethanh commented on May 14, 2024 1

You can use the "-i or --mime" option of file which return the mime type, which should be easier to parse and not depends on locales

 -i, --mime
         Causes the file command to output mime type strings rather than the more traditional human readable ones.  Thus it may say ‘text/plain; charset=us-ascii’ rather than “ASCII text”.

from nnn.

jarun avatar jarun commented on May 14, 2024 1

@kaushalmodi @olethanh please test with the fix and confirm everything works as expected. Thanks!

from nnn.

kaushalmodi avatar kaushalmodi commented on May 14, 2024 1

Thanks! I confirm this fix.

from nnn.

jarun avatar jarun commented on May 14, 2024

Are you on v1.1 (released today)?

Which opener variable did you define? We do detect and attempt to open plaintext files in EDITOR (fallback vi). But that works only if NNN_OPENER is not used. I don't have NNN_OPENER and it's working for me right now.

from nnn.

kaushalmodi avatar kaushalmodi commented on May 14, 2024

I have none of the NNN_* env vars defined. I get the same behavior on the v1.1 release too.

> echo $NNN_OPENER
NNN_OPENER: Undefined variable.
> echo $EDITOR
emacsclient

If it matters, I am using tcsh shell. I can easily get that "No association" message by launching nnn in this repo root, navigating to the CHANGELOG file and hitting RET.


To add, if I hit e instead of RET on CHANGELOG, the file opens fine in my default $EDITOR.

from nnn.

jarun avatar jarun commented on May 14, 2024

What's the output of file -b CHANGELOG?

from nnn.

kaushalmodi avatar kaushalmodi commented on May 14, 2024

What's the output of file -b CHANGELOG?

That's it! It outputs ASCII English text, not ASCII text. May be you should match for a regular expression like ASCII .*text?

from nnn.

kaushalmodi avatar kaushalmodi commented on May 14, 2024

This is not a good fix, but I tested this out and it works for me:

diff --git a/nnn.c b/nnn.c
index 110495e..e6b8d2b 100644
--- a/nnn.c
+++ b/nnn.c
@@ -1598,7 +1598,7 @@ nochange:
 				if (get_output(cmd, MAX_CMD_LEN) == NULL)
 					continue;
 
-				if (strstr(cmd, "ASCII text") != NULL) {
+				if (strstr(cmd, "ASCII English text") != NULL) {
 					exitcurses();
 					run = xgetenv("EDITOR", "emacsclient");
 					spawn(run, newpath, NULL, 0);

from nnn.

kaushalmodi avatar kaushalmodi commented on May 14, 2024

Also I found the use of PAGER there more intuitive than EDITOR ( kaushalmodi@05d7641 ). If I wanted to edit the file, I would have hit the e binding.

from nnn.

jarun avatar jarun commented on May 14, 2024

I would have to look into the magic numbers and see if I can do anything better than this.

If I wanted to edit the file, I would have hit the e binding

I don't think this is too relevant here. The keybind here is Enter and I don't see a reason to open a text file in read-only mode by default.

from nnn.

jarun avatar jarun commented on May 14, 2024

@olethanh yes, that'ld be nice! I'll push it in.

from nnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.