Description
PLEASE SEE THE ASSUMPTIONS NEAR THE BOTTOM OF THIS COMMENT
TODO
- create an automatic vim no TAB configuration for all calc source except makefiles
Inspired by @pmetzger's comment-1939127107 we wish to replace ASCII TAB characters with ASCII SPACE charcters in calc source code as part of the process to plan for calc v3 as noted in issue #103. This issue is here to develop a vim(1)
framework to allow this to happen automatically.
Some hints at a solution were suggested by @xexyl in comment-2093121295. We have not tested this solution.
vim and calc
We need a framework where, when using the vim(1)
editor on calc source, we have the following modes in effect:
" Use 4-space indents
"
:set shiftwidth=4
" Intelligently use the tab key for indentation instead of for inserting tab characters
"
:set smarttab
" Use space characters, never tab characters
"
:set expandtab
" Set tab stops to be different from the indentation width.
"
:set tabstop=8
" Reduce the chance of tab characters masquerading as proper indents.
"
:set softtabstop=0
Assumption 0: use of vim
ASSUMPTION: This issue is focused on the use of vim(1) as the editor to manage to the calc source.
We are aware that they are other fine editors besides vim. Indeed, we have used other editors in the past such as:
- ed(1)
- TECO emacs
- Gosling Emacs
- Multics Emacs
- NOS EDIT
- EDITH
- ex(1)
- GNU Emacs
- vi(1)
- GNU nano
- etc. (the above list is far from complete)
On accession we DO still use some of the above editors from time to time today. Editors have their strengths and their mis-feature weaknesses. We intend no disrespect to other editors. This issue is focused on use of vim(1) for calc.
Assumption 1: using SPACE instead of TAB
ASSUMPTION: This issue assumes that the calc source will NOT USE THE TAB CHARACTER.
We know is a long standing Tabs versus Spaces debate.
If you wish to debate the issue of using the TAB character in calc source, PLEASE COMMENT UNDER issue #103 instead of this issue. This issue assumes that the calc source will not use TABS. In particular if you wish to object to using SPACE characters instead of TAB characters, please feel free to comment under issue #103 (see #103).
Assumption 2: Not using TABS applies to ONLY calc source
ASSUMPTION: We do NOT want to do this for all files everywhere, only files under the calc source directory.
For purposes of discussion, assume that the calc source directory resides under:
/usr/local/src/bin/calc
Assumption 3: Not enabling via a local directory .vimrc
file
ASSUMPTION: We will NOT enable the use of a .vimrc
file within the calc source tree.
We do NOT want to enable local directory .vimrc
files in general as this is dangerous. Someone could provide a tarball with an evil .vimrc
that could do things like autocmd BufEnter * :silent! !echo rm -rf stuff
.
While it might be permissible to enable the .vimrc
files for the specific directory, but that could also be dangerous as some patch could alter that local .vimrc
file and create similar problems.
Assumption 4: vim solution will not not part of the calc source
ASSUMPTION: We are NOT trying to configure this for everyone who happens to have a copy of the calc source.
We really need to configure vim just for ourselves. While we can document HOW we configured vim(1)
for editing calc in some someone else wants to do the same. So we don't see a need for this configuration be enforce on anyone who happens to have a copy of the calc source.
It is our guess that the solution will involve editing our own private ~/.vimrc
file under our home directory AND / OR file(s) under the ~/.vim/
directory.
We plan to, as part of the calc build process, issue warnings if TAB characters are found in the source source where they should not be. Those warnings will not prevent calc from being compiled.
Assumption 5: automatic use for calc source
ASSUMPTION: We want the NO TAB CHARACTERS mode to be automatically enabled whenever we edit the calc source.
We do NOT want to have to remember to execute some magic vim command to set this stuff, before editing files under that directory, we and others are likely to forget to execute such a magic command. We want it to be automatic.
While we plan as part of our release process, to verify that calc source does NOT contain tab characters, while we are working on the calc source tree, we want vim(1)
to automatically enable no TABS for the calc source directory (assume /usr/local/src/bin/calc
for the sake of discussion).
Assumption 6: Some calc files will have TAB characters
ASSUMPTION: Some files WILL CONTAIN TAB characters, just not C source.
Files such as Makefiles need TAB characters for commands related to a make rule. While some make tools allow for whitespace indented Makefiles, others do not. Because intending with spaces is not portable across various make tools, calc makefiles WILL continue to use TAB characters.
Calc source has the following make relate files that WILL CONTAIN TAB characters:
- Makefile
- Makefile.config
- Makefile.local
- Makefile.target
- cal/Makefile
- cscript/Makefile
- custom/Makefile
- help/Makefile
- rpm.mk
There may be other exceptions in the calc source tree, but for now assume that all files other than the above list WILL NOT CONTAIN TAB characters.