diff --git a/vim-default-editor.csh b/vim-default-editor.csh new file mode 100644 index 0000000..d98316d --- /dev/null +++ b/vim-default-editor.csh @@ -0,0 +1,5 @@ +# Ensure vim is set as EDITOR if it isn't already set + +if ( ! ($?EDITOR) ) then + setenv EDITOR "/usr/bin/vim" +endif diff --git a/vim-default-editor.fish b/vim-default-editor.fish new file mode 100644 index 0000000..f4cc15e --- /dev/null +++ b/vim-default-editor.fish @@ -0,0 +1,8 @@ +# Ensure vim is set as EDITOR if it isn't already set +# This is set as a universal variable so that any other definition +# by the user would win +# Cf. https://fishshell.com/docs/current/index.html#variables-scope + +if ! set -q EDITOR; + set -Ux EDITOR /usr/bin/vim +end diff --git a/vim-default-editor.sh b/vim-default-editor.sh new file mode 100644 index 0000000..1a53daf --- /dev/null +++ b/vim-default-editor.sh @@ -0,0 +1,5 @@ +# Ensure vim is set as EDITOR if it isn't already set + +if [ -z "$EDITOR" ]; then + export EDITOR="/usr/bin/vim" +fi diff --git a/vim.spec b/vim.spec index d645d3c..3946dfe 100644 --- a/vim.spec +++ b/vim.spec @@ -21,7 +21,7 @@ Summary: The VIM editor URL: http://www.vim.org/ Name: vim Version: %{baseversion}.%{patchlevel} -Release: 1%{?dist} +Release: 2%{?dist} License: Vim and MIT Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2 Source1: vim.sh @@ -37,6 +37,9 @@ Source13: vim-spell-files.tar.bz2 %endif Source14: spec-template.new Source15: macros.vim +Source16: vim-default-editor.sh +Source17: vim-default-editor.csh +Source18: vim-default-editor.fish Patch2002: vim-7.0-fixkeys.patch Patch2003: vim-7.4-specsyntax.patch @@ -216,6 +219,15 @@ Install the vim-X11 package if you'd like to try out a version of vi with graphics and mouse capabilities. You'll also need to install the vim-common package. +%package default-editor +Summary: Set vim as a default editor +Requires: vim-enhanced +BuildArch: noarch +Conflicts: nano-default-editor + +%description default-editor +This subpackage contains files needed to set Vim as a default editor. + %prep %setup -q -b 0 -n %{vimdir} @@ -519,7 +531,11 @@ chmod 644 ../runtime/doc/vim2html.pl mkdir -p %{buildroot}/%{_sysconfdir}/profile.d cp %{SOURCE1} %{buildroot}/%{_sysconfdir}/profile.d/vim.sh cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/profile.d/vim.csh +cp %{SOURCE16} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.sh +cp %{SOURCE17} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.csh +cp %{SOURCE18} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.fish chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim.* +chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.* install -p -m644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/virc install -p -m644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/vimrc @@ -785,7 +801,13 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags %dir %{_datadir}/icons/locolor/*/apps %{_datadir}/icons/locolor/*/apps/* +%files default-editor +%config(noreplace) %{_sysconfdir}/profile.d/vim-default-editor.* + %changelog +* Fri Oct 09 2020 Paweł Marciniak - 2:8.2.1815-2 +- A new subpackage, set vim as a default editor. + * Fri Oct 09 2020 Zdenek Dohnal - 2:8.2.1815-1 - patchlevel 1815