Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rexim/simpc-mode
Simple C mode for Emacs
https://github.com/rexim/simpc-mode
Last synced: 7 days ago
JSON representation
Simple C mode for Emacs
- Host: GitHub
- URL: https://github.com/rexim/simpc-mode
- Owner: rexim
- License: mit
- Created: 2020-07-11T22:45:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-11T16:32:21.000Z (about 2 years ago)
- Last Synced: 2024-02-17T08:35:51.345Z (11 months ago)
- Language: Emacs Lisp
- Size: 22.5 KB
- Stars: 26
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple C mode for Emacs
Because whatever comes with Emacs is too slow.
This mode does not try to be as featureful as `c-mode`, `c++-mode`,
`cc-mode`, etc. Instead we are trying to implement a bare minimum
syntax highlighting and indentation to maintain high performance on
big files with long lines.The goal is to be able to comfortably browse and modify the following files:
- [imgui](https://raw.githubusercontent.com/ocornut/imgui/fb7f6cab8c322731da336e553915e944bf386e62/imgui.h)
- [amalgamated sqlite3.c](https://raw.githubusercontent.com/IreneKnapp/direct-sqlite/a74cc50c735053c7c49c487a66e7756b524db883/cbits/sqlite3.c)
- ...Right now the only way to work with these files in Emacs is to use
`text-mode`. Which is actually a good evidence that Emacs itself can
handles such files! It's `c-mode` (and others) that cannot.## Quick Start
Right now the only way to use this mode is to
1. `C-x C-f simpc-mode.el RET`
2. `M-x eval-buffer RET`
3. `M-x simpc-mode RET`## Indentation
Right now the mode supports only very simple indentations based on the
analysing the previous non-empty line and its surrounding curly
braces. Anything more complicated is outside of the scope of the
project.It is recommended to use an external formatter such as
[indent](https://www.gnu.org/software/indent/),
[astyle](http://astyle.sourceforge.net/),
[clang-format](https://clang.llvm.org/docs/ClangFormat.html), etc.Here is how I use [astyle](http://astyle.sourceforge.net/):
```emacs-lisp
(defun astyle-buffer ()
(interactive)
(let ((saved-line-number (line-number-at-pos)))
(shell-command-on-region
(point-min)
(point-max)
"astyle --style=kr"
nil
t)
(goto-line saved-line-number)))
```Then I bind `astyle-buffer` to some key combination and invoke it
periodically to reformat the whole current buffer.