This file documents some of the editor configurations for commonly used
text editors that will configure them to work more smoothly with BRL-CAD
sources.  These are not "official", just tips based on experience.

##############################################################################################

Vim (http://www.vim.org/download.php) .vimrc file:

" Enable file type detection
filetype on

" Turn on plugin loading and tailored indenting based on file type
filetype plugin indent on

" Enable syntax highlighting
syntax enable

" Make backspace work like most other apps
" http://vim.wikia.com/wiki/Backspace_and_delete_problems
set backspace=indent,eol,start
" If your delete key terminal code is wrong, but the
" code for backspace is alright, you can put ':fixdel' in
" your .vimrc.  This works no matter what the actual code
" for backspace is.
" http://vimdoc.sourceforge.net/htmldoc/options.html#:fixdel
fixdel

" Set theme from http://www.vim.org/scripts/script.php?script_id=791
:colorscheme relaxedgreen

" Enable modeline support (http://vim.wikia.com/wiki/Modeline_magic)
set modeline
set modelines=5

" Disable bells
set belloff=all

" Advanced LaTeX support:
" http://vim-latex.sourceforge.net/
"
" LaTeX mode settings:
" http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html
filetype plugin on
set grepprg=grep\ -nH\ $*
let g:tex_flavor='latex'

" Go with US spelling
set spell spelllang=en_us

" Show trailing whitespace:
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/

" Fix C indenting behavior:
" http://stackoverflow.com/questions/28217118/vim-indents-c-c-functions-badly-when-the-type-and-name-are-in-different-lines
set cinoptions+=t0

" CMake vim resources:
"
" Install into ~/.vim/indent/
" https://github.com/Kitware/CMake/blob/master/Auxiliary/cmake-indent.vim
"
" Install into ~/.vim/syntax/
" https://github.com/Kitware/CMake/blob/master/Auxiliary/cmake-syntax.vim

" Trigger CMake mode for various file extensions
:autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in setf cmake
:autocmd BufRead,BufNewFile *.ctest,*.ctest.in setf cmake

" Tcl resources:
" http://www.vim.org/scripts/script.php?script_id=1603
" http://www.vim.org/scripts/script.php?script_id=1717
:autocmd BufRead,BufNewFile *.tcl,*.tcl.in setf tcl

" Git commit settings
" https://csswizardry.com/2017/03/configuring-git-and-vim/
autocmd FileType gitcommit set textwidth=72
autocmd FileType gitcommit set colorcolumn=+51

" YAML settings
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

"Asynchronous Lint Engine: https://github.com/dense-analysis/ale
let g:indentLine_char = '⦙'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
let g:ale_lint_on_text_changed = 'never'

##############################################################################################

Emacs .emacs file:

;; Run btclsh within emacs - function set up as
;; discussed in https://emacs.stackexchange.com/q/18672
;;
;; Note also https://superuser.com/q/794145
;;
;; To launch directly into btclsh in terminal mode:
;;
;; emacs -nw -f btclsh
;;
(defun btclsh ()
  (interactive)
  (require 'term)
  (let* ((cmd "btclsh")
         (termbuf (apply 'make-term "btclsh console" cmd nil nil)))
    (set-buffer termbuf)
    (term-mode)
    (term-line-mode)
    (switch-to-buffer termbuf))) 


;; Nxml mode for DocBook:
;; https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html
;; To set the DocBook 5 schema, select the file
;; <path/to/brlcad>/doc/docbook/resources/other/docbook5xi.rnc
;; using XMl->Set Schema->File... from the GUI or C-c C-s C-f in
;; the editor itself.
(add-to-list 'auto-mode-alist (cons (concat "\\." (regexp-opt '("xml") t) "\\'") 'nxml-mode))
