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