/quakec-mode

Emacs major mode for QuakeC development

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

Emacs major mode for QuakeC files

quakec-mode provides support for the original Quake 1 extension language, as well as some popular extensions provided by the FTEQCC and GMQCC compilers. In addition to qc code itself, a bundled quakec-progs-mode supports editing traditions src files.

Features:

  • QuakeC syntax
  • progs.src syntax highlighting
  • imenu support
  • xref-based definition lookups
  • ElDoc inline help for known defintions
  • completion-at-point backend for known definition
  • compilation mode support
  • which-function support

In other words, this is your typical Emacs major-mode.

A QuakeC project as seen by quakec-mode

quakec-mode understands QuakeC mode projects as a directory containing a file specified in the quakec-project-source variable (progs.src by default).

Compiling with compilation-mode

QuakeC includes compilation diagnostic message highlighting for FTEQCC and GMQCC. Custom compilation commands are provided in the mode map: quakec-compile (C-c C-c) and quakec-recompile (C-c C-r). Custom compilation commands always run from the QuakeC project root defined by the quakec-project-source file.

Completion and definition lookups

The default completion-at-point backend (provided by quakec-completion-at-point) loads definitions from the current buffer and a few additional files listed in quakec-project-definition-files variable (defs.qc and world.qc by default).

For best experience it makes sense to use an additional completion frontend such as company-mode.

Flymake

Partial support for error highlighting with Flyamke by FTEQCC / GMQCC is provided. Its usefulness is limited because of how both compilers don’t support limiting compilation errors to a single file and always try to compile the full project. Most of the time this means that errors will only be shown for files listed early in the progs.src file.

Flymake support can be added by running (quakec-setup-flymake-fteqcc-backend) or (quakec-setup-flymake-gmqcc-backend) followed by the usual (flymake-mode 1).

Setup

Example setup:

(defun my-quakec-mode-hook ()
  ;; typical QuakeC conventions (makes sense to set through
  ;; .dir-locals.el files)
  (setq-local indent-tabs-mode t)
  (setq-local tab-width 4)

  ;; Company mode backend to for completion-at-point for local
  ;; definition

  ;; (setq-local company-backends '(company-capf))

  ;; Limited Flymake support for error/warning inline highlighting

  ;; (quakec-setup-flymake-fteqcc-backend)
  ;; (flymake-mode 1)
  )

(use-package quakec-mode
  ;; drop the quakec-mode.el somewhere (or just install from MELPA)
  :load-path "path/to/quakec-mode"
  ;; run our configration
  :hook (quakec-mode . my-quakec-mode-hook))

Reference