geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit 9f6992fbf205ebf60a0674c9ec29a86c73cb4fa9
parent b8f2f9e71128445ed61141bb7eec1d241790fb43
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed,  3 Aug 2022 18:24:55 +0200

Add gph major-mode file for emacs.

Thanks Athas!

Diffstat:
gph/README.md | 6++++++
gph/emacs/gph-mode.el | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/gph/README.md b/gph/README.md @@ -9,3 +9,9 @@ cp vim/ftdetect/gph.vim ~/.vim/ftdetect cp vim/syntax/gph.vim ~/.vim/syntax +## emacs + +Please read this on how emacs finds its major mode files: + + https://www.gnu.org/software/emacs/manual/html_node/elisp/Auto-Major-Mode.html + diff --git a/gph/emacs/gph-mode.el b/gph/emacs/gph-mode.el @@ -0,0 +1,61 @@ +;;; gph-mode.el --- major mode for gph files -*- lexical-binding: t; -*- + +;; Copyright (C) Troels Henriksen (athas@sigkill.dk) 2022 +;; +;; URL: https://github.com/diku-dk/futhark-mode +;; Keywords: gopher +;; Version: 1.0 +;; Package-Requires: ((emacs "25.1")) + +;; This file is not part of GNU Emacs. + +;;; License: +;; GPL-3+ + +;;; Commentary: +;; .gph is the map file format used by the geomyidae Gopher daemon. +;; This Emacs mode provides basic understanding of the link syntax, +;; such that highlighting and folding works properly. +;; +;; Files with the ".gph" extension are automatically handled by this mode. +;; +;; For extensions: Define local keybindings in `gph-mode-map'. Add +;; startup functions to `gph-mode-hook'. + +;;; Code: + +(eval-when-compile + (require 'rx)) + +(defvar gph--font-lock-defaults + (let* ((type-rx '(or "0" "1" "3" "7" "8" "9" "g" "I" "h" "i")) + (desc-rx '(* (not "|"))) + (path-rx '(* (not "|"))) + (host-rx '(* (not "|"))) + (port-rx '(+ digit)) + (link-rx `(: line-start "[" ,type-rx "|" ,desc-rx "|" ,path-rx "|" ,host-rx "|" ,port-rx "]")) + (badlink-rx `(: line-start "[" (* anything)))) + `((,(rx-to-string link-rx) 0 font-lock-doc-markup-face) + (,(rx-to-string badlink-rx) 0 font-lock-warning-face)))) + +(defvar gph-mode-hook nil + "Hook for `gph-mode'. Is run whenever the mode is entered.") + +(defvar gph-mode-map + (let ((map (make-keymap))) + map) + "Keymap for `gph-mode'.") + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.gph" . gph-mode)) + +;;;###autoload +(define-derived-mode gph-mode text-mode "gph" + "Major mode for .gph files as used by geomyidae." + (setq-local paragraph-start (concat "^\\[|\\|[ \t]*$\\|" page-delimiter)) + (setq-local paragraph-separate (concat "^\\[\\|[ \t]*$\\|" page-delimiter)) + (setq-local font-lock-defaults '(gph--font-lock-defaults))) + +(provide 'gph-mode) + +;;; gph-mode.el ends here