Question

My question is about Midnight-commander. I've unset usage of internal editor (in Options -> Configuration) and put in .bashrc:

export EDITOR='emacsclient -n'

still - pressing F4 gives nothing, pressing F3 - opens in vi. Is there a way to make emacsclient to be a default text editor in mc?

Was it helpful?

Solution 3

I found a way: one can use mc's macro feature. For that make a file:

e   Open in emacsclient
    emacsclient -n %s

and save it as ~/.mc/menu or ~/.mc.menu. After that on pressin F2 - You'll get a list of Your's functions. And there will be a function Open in emacs - which will be accessible by the e. So the two keys F2-e open current file (or all selected files) in emacsclient -n.

OTHER TIPS

Remove ~/.selected_editor, then when you press F4 next time, MC will prompt for select editor. Or, you may directly change it.

$ cat .selected_editor
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.basic" 

This works on Ubuntu. I have tried any other ways to setup default editor which won't help.

What I do is change the ~/.mc/bindings file:

### Default ###

# Default target for anything not described above
default/*
    Open=%var{EDITOR:emacs} %f &
    View=

That way I can still view files with F3, but F4 or enter usually edits them with Emacs.

By the way, the ampersand is so that the file will pop up in X, and I can continue in mc. You may have to remove that if you're only working on the command line.

UPDATE: If you don't have a ~/.mc/bindings file, from inside mc, press F9 c e (Menu, Commands, Edit extension file), and it should get you there.

In addition, you need to switch off the internal edit option by going to F9 o c t (Menu, Options, Configuration, use Internal edit), unchecking the box, and then saving the options.

Here is another solution: edit the extension-file and add an Edit-entry.
(Sorry, not enough reputation to add this as comment to Gustav Bertram's answer.)

Be sure to use MidnightCommander's built-in functionality, as the location of config-files seems to change between some versions of MC.

So press F9 or ESC,9 (to open the menu), then go to Command -> Edit Extension File.
In the editor, find the last block looking like that:

# Default target for anything not described above
default /*
            Open=
            View=

Change it to something like that (note the added Edit-line!!!):

# Default target for anything not described above
default/*
        Open= %var{EDITOR:emacs} %f &
        View=
        Edit= %var{EDITOR:emacs} %f &

After saving the file, be sure to turn the internal editor off!!
(F9 or ESC,9, Options -> Configuration, "Use internal edit" must be unchecked)

That way (working at least with later versions of MC) you can have three different editors (or command-line options) to open a file: "View" (F3), "Edit" (F4) and "Open" (Enter) - each individually configurable.

Note #1: If you added a custom view-command, do not forget to uncheck "Use internal view" under Options -> Configuration.
Note #2: MC still uses its preferred editor (e.g. nano) for editing config-files when opening them from within MC.

Run MC as usual. On the command line right above the bottom row of menu selections type "select-editor" without the quotes. This should open a menu with a list of all of your installed editors. This is working for me on all my current linux machines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top