Discussion:
edit-and-execute-command (C-xC-e) doesn't use FCEDIT env variable
(too old to reply)
Francis Moreau
2008-08-22 07:53:54 UTC
Permalink
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
2008-08-22 16:40:48 UTC
Permalink
Post by Francis Moreau
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
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 ***@case.edu http://cnswww.cns.cwru.edu/~chet/
Francis Moreau
2008-08-22 18:41:55 UTC
Permalink
Post by Chet Ramey
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
2008-08-22 22:53:39 UTC
Permalink
Post by Francis Moreau
Post by Chet Ramey
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.
Post by Francis Moreau
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.
Post by Francis Moreau
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.

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

Chet Ramey, ITS, CWRU ***@case.edu http://cnswww.cns.cwru.edu/~chet/
Andrew Stribblehill
2020-12-07 14:45:36 UTC
Permalink
Post by Chet Ramey
Post by Francis Moreau
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.
Post by Francis Moreau
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.
Post by Francis Moreau
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.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
[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 :)
Francis Moreau
2008-08-23 09:42:43 UTC
Permalink
Post by Chet Ramey
Post by Francis Moreau
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 ?
Post by Chet Ramey
Post by Francis Moreau
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.
Post by Chet Ramey
Post by Francis Moreau
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
Post by Chet Ramey
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
2008-08-24 06:46:21 UTC
Permalink
Post by Francis Moreau
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
2008-08-25 07:33:22 UTC
Permalink
Post by Francis Moreau
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))
yep that's finally what I did.
--
Francis
Loading...