diff options
author | toonn <toonn@toonn.io> | 2018-01-23 17:27:48 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2018-01-23 23:08:20 +0100 |
commit | f186e8877b360e0b523de75781c8f1d23301d350 (patch) | |
tree | 0eebcba5a670847a374932b8dbf6be8bc4e9fff0 | |
parent | 0a75fdb06980c72a2ed58f65495ab0f02fae2506 (diff) | |
download | ranger-f186e8877b360e0b523de75781c8f1d23301d350.tar.gz |
Prefer VISUAL to EDITOR
`VISUAL` is often misused to mean desktop GUI editor it's actual purpose was to distinguish editors like `vi` (which is short for visual) from editors like `ed` (which was probably short for editor), `EDITOR` is actually intended to point to one of the latter. Rifle still defaults to `vim` if both variables are undefined, even with an old `rifle.conf` after trying to fall back on `EDITOR`. For some better information on this see, https://unix.stackexchange.com/a/334022
-rw-r--r-- | doc/ranger.1 | 15 | ||||
-rw-r--r-- | doc/ranger.pod | 10 | ||||
-rw-r--r-- | doc/rifle.1 | 11 | ||||
-rw-r--r-- | doc/rifle.pod | 8 | ||||
-rw-r--r-- | ranger/config/rifle.conf | 6 | ||||
-rwxr-xr-x | ranger/ext/rifle.py | 4 |
6 files changed, 39 insertions, 15 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index bb7114a2..780027ac 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.0b6" "12/07/2017" "ranger manual" +.TH RANGER 1 "ranger-1.9.0b6" "2018-01-23" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -508,7 +508,7 @@ Redraw the screen Inspect the current file in a bigger window. .IP "E" 14 .IX Item "E" -Edit the current file in \f(CW$EDITOR\fR (\*(L"nano\*(R" by default) +Edit the current file in \f(CW$VISUAL\fR otherwise \f(CW$EDITOR\fR otherwise \*(L"vim\*(R" .IP "S" 14 .IX Item "S" Open a shell in the current directory @@ -599,7 +599,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -1457,9 +1457,14 @@ by checking for this variable. If this variable is set to \s-1FALSE,\s0 ranger will not load the default rc.conf. This can save time if you copied the whole rc.conf to ~/.config/ranger/ and don't need the default one at all. +.IP "\s-1VISUAL\s0" 8 +.IX Item "VISUAL" +Defines the editor to be used for the \*(L"E\*(R" key. Falls back to \s-1EDITOR\s0 if +undefined or empty. .IP "\s-1EDITOR\s0" 8 .IX Item "EDITOR" -Defines the editor to be used for the \*(L"E\*(R" key. Defaults to \*(L"nano\*(R". +Defines the editor to be used for the \*(L"E\*(R" key if \s-1VISUAL\s0 is undefined or empty. +Defaults to \*(L"vim\*(R". .IP "\s-1SHELL\s0" 8 .IX Item "SHELL" Defines the shell that ranger is going to use with the :shell command and diff --git a/doc/ranger.pod b/doc/ranger.pod index 43926f46..1260c8db 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -423,7 +423,7 @@ Inspect the current file in a bigger window. =item E -Edit the current file in $EDITOR ("nano" by default) +Edit the current file in $VISUAL otherwise $EDITOR otherwise "vim" =item S @@ -1566,9 +1566,15 @@ If this variable is set to FALSE, ranger will not load the default rc.conf. This can save time if you copied the whole rc.conf to ~/.config/ranger/ and don't need the default one at all. +=item VISUAL + +Defines the editor to be used for the "E" key. Falls back to EDITOR if +undefined or empty. + =item EDITOR -Defines the editor to be used for the "E" key. Defaults to "nano". +Defines the editor to be used for the "E" key if VISUAL is undefined or empty. +Defaults to "vim". =item SHELL diff --git a/doc/rifle.1 b/doc/rifle.1 index 8531d69c..44faa332 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.0b6" "12/07/2017" "rifle manual" +.TH RIFLE 1 "rifle-1.9.0b6" "2018-01-23" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -188,9 +188,14 @@ The syntax is described in the comments of the default \fIrifle.conf\fR that shi with ranger. To obtain it, you need to run: \f(CW\*(C`ranger \-\-copy\-config=rifle\*(C'\fR .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" +.IP "\s-1VISUAL\s0" 8 +.IX Item "VISUAL" +Determines which editor to use for editing files. .IP "\s-1EDITOR\s0" 8 .IX Item "EDITOR" -Determines which editor to use for editing files (in the default \fIrifle.conf\fR). +Determines which editor to use for editing files if \s-1VISUAL\s0 is undefined or +empty (in the default \fIrifle.conf\fR). If both are undefined or empty, \*(L"vim\*(R" is +used instead. .IP "\s-1PAGER\s0" 8 .IX Item "PAGER" Determines which pager to use for displaying files (in the default \fIrifle.conf\fR). diff --git a/doc/rifle.pod b/doc/rifle.pod index 7241f6b5..b4d76287 100644 --- a/doc/rifle.pod +++ b/doc/rifle.pod @@ -84,9 +84,15 @@ with ranger. To obtain it, you need to run: C<ranger --copy-config=rifle> =over 8 +=item VISUAL + +Determines which editor to use for editing files. + =item EDITOR -Determines which editor to use for editing files (in the default F<rifle.conf>). +Determines which editor to use for editing files if VISUAL is undefined or +empty (in the default F<rifle.conf>). If both are undefined or empty, "vim" is +used instead. =item PAGER diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index 2c081479..564fff8d 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -85,9 +85,9 @@ ext x?html?, has w3m, terminal = w3m "$@" # Misc #------------------------------------------- # Define the "editor" for text files as first action -mime ^text, label editor = $EDITOR -- "$@" +mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" mime ^text, label pager = "$PAGER" -- "$@" -!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@" +!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" ext 1 = man "$1" @@ -218,7 +218,7 @@ label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1" # Define the editor for non-text files + pager as last action !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask -label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@" +label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" # The very last action, so that it's never triggered accidentally, is to execute a program: diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index a6c0b9f0..c664423a 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -343,7 +343,9 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes else: if 'PAGER' not in os.environ: os.environ['PAGER'] = DEFAULT_PAGER - if 'EDITOR' not in os.environ: + if 'VISUAL' not in os.environ and 'EDITOR' not in os.environ: + os.environ['VISUAL'] = DEFAULT_EDITOR + # necessary for compatibility with old rifle.conf os.environ['EDITOR'] = DEFAULT_EDITOR command = self.hook_command_postprocessing(command) self.hook_before_executing(command, self._mimetype, self._app_flags) |