igph-mode.el - geomyidae - A small C-based gopherd. Err bitreich.org 70 hgit clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ URL:git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ bitreich.org 70 1Log /scm/geomyidae/log.gph bitreich.org 70 1Files /scm/geomyidae/files.gph bitreich.org 70 1Refs /scm/geomyidae/refs.gph bitreich.org 70 1Tags /scm/geomyidae/tag bitreich.org 70 1README /scm/geomyidae/file/README.gph bitreich.org 70 1LICENSE /scm/geomyidae/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 igph-mode.el (2267B) Err bitreich.org 70 i--- Err bitreich.org 70 i 1 ;;; gph-mode.el --- major mode for gph files -*- lexical-binding: t; -*- Err bitreich.org 70 i 2 Err bitreich.org 70 i 3 ;; Copyright (C) Troels Henriksen (athas@sigkill.dk) 2022 Err bitreich.org 70 i 4 ;; Err bitreich.org 70 i 5 ;; URL: gopher://sigkill.dk/1/programming Err bitreich.org 70 i 6 ;; Keywords: gopher Err bitreich.org 70 i 7 ;; Version: 1.1 Err bitreich.org 70 i 8 ;; Package-Requires: ((emacs "25.1")) Err bitreich.org 70 i 9 Err bitreich.org 70 i 10 ;; This file is not part of GNU Emacs. Err bitreich.org 70 i 11 Err bitreich.org 70 i 12 ;;; License: Err bitreich.org 70 i 13 ;; GPL-3+ Err bitreich.org 70 i 14 Err bitreich.org 70 i 15 ;;; Commentary: Err bitreich.org 70 i 16 ;; .gph is the map file format used by the geomyidae Gopher daemon. Err bitreich.org 70 i 17 ;; This Emacs mode provides basic understanding of the link syntax, Err bitreich.org 70 i 18 ;; such that highlighting and folding works properly. It also Err bitreich.org 70 i 19 ;; highlights tab characters in pink because these are not allowed in Err bitreich.org 70 i 20 ;; .gph files. Err bitreich.org 70 i 21 ;; Err bitreich.org 70 i 22 ;; Files with the ".gph" extension are automatically handled by this mode. Err bitreich.org 70 i 23 ;; Err bitreich.org 70 i 24 ;; For extensions: Define local keybindings in `gph-mode-map'. Add Err bitreich.org 70 i 25 ;; startup functions to `gph-mode-hook'. Err bitreich.org 70 i 26 Err bitreich.org 70 i 27 ;;; Code: Err bitreich.org 70 i 28 Err bitreich.org 70 i 29 (eval-when-compile Err bitreich.org 70 i 30 (require 'rx)) Err bitreich.org 70 i 31 Err bitreich.org 70 i 32 (defface gph-tabs-face Err bitreich.org 70 i 33 '((((class color)) (:background "hotpink")) Err bitreich.org 70 i 34 (t (:reverse-video t))) Err bitreich.org 70 i 35 "Face to use for highlighting tabs in Font-Lock mode.") Err bitreich.org 70 i 36 Err bitreich.org 70 i 37 (defvar gph-tabs 'gph-tabs-face Err bitreich.org 70 i 38 "Face to use for highlighting tabs in Font-Lock mode.") Err bitreich.org 70 i 39 Err bitreich.org 70 i 40 (defvar gph--font-lock-defaults Err bitreich.org 70 i 41 (let* ((type-rx '(or "0" "1" "3" "7" "8" "9" "g" "I" "h" "i")) Err bitreich.org 70 i 42 (desc-rx '(* (not "|"))) Err bitreich.org 70 i 43 (path-rx '(* (not "|"))) Err bitreich.org 70 i 44 (host-rx '(* (not "|"))) Err bitreich.org 70 i 45 (port-rx '(+ digit)) Err bitreich.org 70 i 46 (link-rx `(: line-start "[" ,type-rx "|" ,desc-rx "|" ,path-rx "|" ,host-rx "|" ,port-rx "]")) Err bitreich.org 70 i 47 (badlink-rx `(: line-start "[" (* anything)))) Err bitreich.org 70 i 48 `((,(rx-to-string link-rx) 0 font-lock-doc-markup-face) Err bitreich.org 70 i 49 (,(rx-to-string badlink-rx) 0 font-lock-warning-face) Err bitreich.org 70 i 50 ("\t" 0 gph-tabs)))) Err bitreich.org 70 i 51 Err bitreich.org 70 i 52 (defvar gph-mode-hook nil Err bitreich.org 70 i 53 "Hook for `gph-mode'. Is run whenever the mode is entered.") Err bitreich.org 70 i 54 Err bitreich.org 70 i 55 (defvar gph-mode-map Err bitreich.org 70 i 56 (let ((map (make-keymap))) Err bitreich.org 70 i 57 map) Err bitreich.org 70 i 58 "Keymap for `gph-mode'.") Err bitreich.org 70 i 59 Err bitreich.org 70 i 60 ;;;###autoload Err bitreich.org 70 i 61 (add-to-list 'auto-mode-alist '("\\.gph" . gph-mode)) Err bitreich.org 70 i 62 Err bitreich.org 70 i 63 ;;;###autoload Err bitreich.org 70 i 64 (define-derived-mode gph-mode text-mode "gph" Err bitreich.org 70 i 65 "Major mode for .gph files as used by geomyidae." Err bitreich.org 70 i 66 (setq-local paragraph-start (concat "^\\[|\\|[ \t]*$\\|" page-delimiter)) Err bitreich.org 70 i 67 (setq-local paragraph-separate (concat "^\\[\\|[ \t]*$\\|" page-delimiter)) Err bitreich.org 70 i 68 (setq-local font-lock-defaults '(gph--font-lock-defaults))) Err bitreich.org 70 i 69 Err bitreich.org 70 i 70 (provide 'gph-mode) Err bitreich.org 70 i 71 Err bitreich.org 70 i 72 ;;; gph-mode.el ends here Err bitreich.org 70 .