midnight commander - Can I bind F4 to 'emacs -nw' in mc?

  • chenge

    It seems it' ok to use 'EDITOR=emacs',it open GUI emacs. If I use 'EDITOR=emacs -nw', it fails.

  • Answers
  • Gilles

    There are many programs that launch an editor based on the EDITOR environment variable. Unfortunately, they disagree on whether that variable should contain a shell script snippet (so that you can pass options to the editor), or should contain the name of an executable file (which may happen to contain spaces).

    The safe option is to write a short script that calls your editor with the options you want and give it a name that doesn't include any special characters. Here's a sample script:

    exec emacs -nw "$@"

    Call that script /home/chenge/bin/EDITOR (for example) and set EDITOR=/home/chenge/bin/EDITOR.

    Also set VISUAL to the same value (the two variables have the same purpose; most but not all programs understand both).

    By the way, if you have Emacs 23, you may want to set up the Emacs daemon and call emacsclient instead of emacs.

  • Related Question

    osx - Changing Emacs bindings in Mac OS X
  • Rob Jones

    I'm trying to reset the binding for "C-x C-c". Specifically, I want to rebind it to a function that asks me if I really want to quit (I just fat finger it way too much). I've done this before under Linux with no issues. Under Mac OS X, when I evaluate the expression

    (global-unset-key “\C-x\C-c”)

    I get:

    eval-buffer: Symbol's value as variable is void: “C-xC-c”

    So, why is it void? The command does exit Emacs, so it can't be void. I must not be referring to "C-x C-c" correctly. But what is the correct way?

    I get the same problem when using global-set-key to bind the command sequence to a new function.

    I'm using GNU Emacs 23.0.0 from MacPorts and Mac OS X 10.5 (Leopard).

  • Related Answers
  • Richard Hoskins

    Somehow, you are using smartquotes.


    (global-unset-key "\C-x\C-c")  ;; use this

    instead of

    (global-unset-key “\C-x\C-c”)  ;; Not this one!
  • Christian Lemer

    Emacs has a configuration for what you asked that does not require to touch the C-x C-c binding.

    Just add to your config one of the following:

    (setq confirm-kill-emacs 'y-or-n-p)
    (setq confirm-kill-emacs 'yes-or-no-p)

    The first one will you ask you to type a single character y/n for confirmation, while the second one will ask you the full answer yes/no.

  • Ronald Pottol

    This is a start, here is a somewhat relevant page http://www.delorie.com/gnu/docs/emacs/emacs%5F496.html , but it seems what you want is to redefine the binding, not to remove it. Or just always have a modified file around, that way it will ask before quitting (and you could automate that in your .emacs or ~/.emacs.d/init.el )