edit-and-execute-command (C-xC-e) doesn't use FCEDIT env variable

14 views
Skip to first unread message

Francis Moreau

unread,
Aug 22, 2008, 3:53:54 AM8/22/08
to bug-...@gnu.org
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include
-I./lib -D_GNU_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64
-mtune=generic
uname output: Linux mars.wyplay.int 2.6.26 #25 SMP Thu Aug 14 15:32:39
CEST 2008 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 33
Release Status: release

Description:
When I execute edit-and-execute-command realdline command by typing C-xC-e,
it seems that bash always launch emacs whatever the setting of
FCEDIT env variable.
However man bash say the opposite.

Repeat-By:
$ export FCEDIT=vi
$ <C-xC-e>
<emacs is launched>

$ alias emacs=vi
$ <C-xC-e>
<vi si launched>

--
Francis


Chet Ramey

unread,
Aug 22, 2008, 12:40:48 PM8/22/08
to Francis Moreau, bug-...@gnu.org, chet....@case.edu
Francis Moreau wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu'
> -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include
> -I./lib -D_GNU_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64
> -mtune=generic
> uname output: Linux mars.wyplay.int 2.6.26 #25 SMP Thu Aug 14 15:32:39
> CEST 2008 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-redhat-linux-gnu
>
> Bash Version: 3.2
> Patch Level: 33
> Release Status: release
>
> Description:
> When I execute edit-and-execute-command realdline command by typing C-xC-e,
> it seems that bash always launch emacs whatever the setting of
> FCEDIT env variable.
> However man bash say the opposite.

Good catch. The command executed is actually

fc -e "${VISUAL:-${EDITOR:-emacs}}"

It's the same command for vi and emacs editing modes, though the default
for vi editing mode is `vi' instead of `emacs'. The documentation needs
to be updated, and has for a while, since it's been this way since at
least bash-2.05. Seven years is a long time for this to go unnoticed.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


Francis Moreau

unread,
Aug 22, 2008, 2:41:55 PM8/22/08
to chet....@case.edu, bug-...@gnu.org
On 8/22/08, Chet Ramey <chet....@case.edu> wrote:
> Good catch. The command executed is actually
>
> fc -e "${VISUAL:-${EDITOR:-emacs}}"
>
> It's the same command for vi and emacs editing modes, though the default
> for vi editing mode is `vi' instead of `emacs'. The documentation needs
> to be updated, and has for a while, since it's been this way since at
> least bash-2.05. Seven years is a long time for this to go unnoticed.

hmm why not fixing the command instead ?

VISUAL can be used to visualize a file, so can be set to 'less' for
example. It shouldn't be used if you wand to edit.

I think what is described in the man is fine. And I wanted to
customize FCEDIT to launch emacs in sh-mode, something I can't do with
current command setting.

--
Francis


Chet Ramey

unread,
Aug 22, 2008, 6:53:39 PM8/22/08
to Francis Moreau, bug-...@gnu.org, chet....@case.edu
Francis Moreau wrote:
> On 8/22/08, Chet Ramey <chet....@case.edu> wrote:
>> Good catch. The command executed is actually
>>
>> fc -e "${VISUAL:-${EDITOR:-emacs}}"
>>
>> It's the same command for vi and emacs editing modes, though the default
>> for vi editing mode is `vi' instead of `emacs'. The documentation needs
>> to be updated, and has for a while, since it's been this way since at
>> least bash-2.05. Seven years is a long time for this to go unnoticed.
>
> hmm why not fixing the command instead ?

It's not broken.

> VISUAL can be used to visualize a file, so can be set to 'less' for
> example. It shouldn't be used if you wand to edit.

That isn't the case. In fact, it's exactly the opposite.

The historic use of VISUAL was for the user to set it to his preferred
`visual' (screen-oriented) editor (note the similarity to `vi') while
leaving EDITOR set to, most often, `ed'. It can be set to `less', but
I'm not sure why you'd want to.

These days there's no practical difference between the two.

You might see what `man environ' on your system says. A random Ubuntu
system I have access to reflects the usage as I've described it.

> I think what is described in the man is fine. And I wanted to
> customize FCEDIT to launch emacs in sh-mode, something I can't do with
> current command setting.

I'll consider it as an enhancement request for a future version. You
can, of course, set `VISUAL' to a command that starts emacs in the
desired mode.

Francis Moreau

unread,
Aug 23, 2008, 5:42:43 AM8/23/08
to chet....@case.edu, bug-...@gnu.org
On Sat, Aug 23, 2008 at 12:53 AM, Chet Ramey <chet....@case.edu> wrote:
> Francis Moreau wrote:
>> hmm why not fixing the command instead ?
>
> It's not broken.

Well, if you consider the man page correct, the command is, isn't it ?

>> VISUAL can be used to visualize a file, so can be set to 'less' for
>> example. It shouldn't be used if you wand to edit.
>
> That isn't the case. In fact, it's exactly the opposite.
>
> The historic use of VISUAL was for the user to set it to his preferred
> `visual' (screen-oriented) editor (note the similarity to `vi') while
> leaving EDITOR set to, most often, `ed'. It can be set to `less', but
> I'm not sure why you'd want to.
>
> These days there's no practical difference between the two.
>
> You might see what `man environ' on your system says. A random Ubuntu
> system I have access to reflects the usage as I've described it.
>

Indeed thanks for the clarificaiton.

>> I think what is described in the man is fine. And I wanted to
>> customize FCEDIT to launch emacs in sh-mode, something I can't do with
>> current command setting.
>
> I'll consider it as an enhancement request for a future version. You

Thanks

> can, of course, set `VISUAL' to a command that starts emacs in the
> desired mode.

VISUAL is used by so many others programs where emacs in sh-mode by
default is not the right thing to do.

I think I won't use VISUAL but start emacs in sh-mode if the file name
argument matches "*bash-fc-*" pattern. It should be safe.

Could you point out the source code where the command you showed is
located ?

thanks
--
Francis


Pierre Gaston

unread,
Aug 24, 2008, 2:46:21 AM8/24/08
to Francis Moreau, bug-...@gnu.org

On Sat, 23 Aug 2008, Francis Moreau wrote:

> I think I won't use VISUAL but start emacs in sh-mode if the file name
> argument matches "*bash-fc-*" pattern. It should be safe.
>

adding the following in your .emacs should do the trick:
(add-to-list 'auto-mode-alist '("^/tmp/bash-fc" . sh-mode))


Francis Moreau

unread,
Aug 25, 2008, 3:33:22 AM8/25/08
to Pierre Gaston, bug-...@gnu.org

yep that's finally what I did.

--
Francis


Andrew Stribblehill

unread,
Dec 7, 2020, 9:45:37 AM12/7/20
to
[I know, some serious thread necromancy going on here...]

I too am interested in the rationale for bash's C-x C-e command invoking:
fc -e "${VISUAL:-${EDITOR:-emacs}}"

fc itself has its own ordered list for editors, which is different fromm C-x C-e.
If nothing else, this is a mite confusing. (From "help fc": "Default is FCEDIT,
then EDITOR, then vi").

How would you feel about either of the following:

A) a patch to remove the "-e" special casing, relying on "fc" to do its job

or

B) a patch that changed the C-x C-e ordered list to:
$FCEDIT;$VISUAL;$EDITOR;emacs?

It goes without saying that the offer of updated documentation goes with these :)
Reply all
Reply to author
Forward
0 new messages