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

MC file plugins for win #9

Open
eugenov opened this issue Nov 9, 2021 · 5 comments
Open

MC file plugins for win #9

eugenov opened this issue Nov 9, 2021 · 5 comments

Comments

@eugenov
Copy link

eugenov commented Nov 9, 2021

mc has some plugins for handling files such as "plugin\archive.sh", "plugin\doc.sh" and such. All commands inside them are for unix. It will be very nice to make mc handle various types of files, but at least we need ability to pass file handling to win. Right now I can only launch executables.

@adamyg
Copy link
Owner

adamyg commented Nov 9, 2021

need an example use-case; scripts can always exec "start file-name" gaining win shell file association features.

@eugenov
Copy link
Author

eugenov commented Nov 10, 2021

I.e. I have some *.pdf file, which opens with MS edge in Explorer. When I execute it in mc (with RETURN key), nothing happens. The same with *.doc, *.xls and other file formats with windows assosiations.
I believe it's hard to implement archive processing inside mc in win, am I right?

@atravert
Copy link

atravert commented Apr 1, 2022

Hello,

Currently the workaround I found to open a file from mc in a external application is to run the following in mc command line:

$ start program %f

  • start is a DOS command -- type help start on a command window for details,
  • program is the name of the executable, with or without its extension. In the case of MS word, for instance, the executable is winword.exe and generally in the PATH, so winword should work.
  • %f is the mc macro for the currently selected file.

So providing a .doc or .docx file is selected in the active panel, the following should work :

$ start winword %f

or equivalently:

$ start winword followed by CTRL + RETURN to add the filename

@eugenov , regarding your initial question: when I just type RETURN on a word file I have the following error (I guess that you should see a similar error, but you must type CRL+o to see the full output of the command line)

image

I don't know much about its implementation, but I suppose that mc is able to execute a part of doc.sh. Here for instance It recognize that type of file is a msdoc, but can't execute wvHtml or elinks which are linux commands.

I agree with you it would be nice being able to directly open the files by typing RETURN. I think that the mc.ext file is meant to do that, but I hanven't figured out yet how to properly do that in windows...

@atravert
Copy link

atravert commented Apr 1, 2022

Hello,

Finally I found the following solution: in mc.ext the lines Open=... or View=... invoking doc.sh can be replaced by:
Open=cmd /c start openprogram %p
View=cmd /c start viewerprogram %p

where openprogram and viewerprogram are exe programs that can be found in the DOS PATH.

For instance for ms word/excel/powerpoint, one could use:

# Microsoft Word Document
regex/i/\.(do[ct]|wri|docx)$
	Open=cmd /c start winword %p
	View=cmd /c start winword %p
type/^Microsoft\ Word
	Open=cmd /c start winword %p
	View=cmd /c start winword %p


# Microsoft Excel Worksheet
regex/i/\.(xl[sw]|xlsx)$
	Open=cmd /c start excel %p
	View=cmd /c start excel %p
type/^Microsoft\ Excel
	Open=cmd /c start excel %p
	View=cmd /c start excel %p

# Microsoft PowerPoint Presentation
regex/i/\.(pp[ts]|pptx)$
	Open=cmd /c start powerpnt %p
	View=cmd /c start powerpnt %p

Finally, as start "" filename.ext makes WIN opening the file with the default program based on extension, one can put on top of mc.ext:

Open=cmd /c start "" %p

This will directly open the file with the default program.

@adamyg : I made few web search, but I did not find recipes to open/view files with mcwin32 (but maybe I did not use the correct keywords). It could be helpful to do so and/or change the default mc.ext so that files with current extensions could be directly opend/read with RETURN/ F3 keys ?

@adamyg
Copy link
Owner

adamyg commented Jun 19, 2022

The diagnostics reported is result of the logic within plugin/doc.sh (below); which is assuming a unix / open-office / abiword environment; shall consider reworking

  wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1
  elinks "$tmp/page.html"

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

No branches or pull requests

3 participants