[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nftables-mode a207b02bd6 40/41: Lightly edited, adding
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nftables-mode a207b02bd6 40/41: Lightly edited, adding some of the normal conventions for .el files |
Date: |
Mon, 23 May 2022 09:27:25 -0400 (EDT) |
branch: externals/nftables-mode
commit a207b02bd63ff4c883f2bbce419788e18b41d779
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Lightly edited, adding some of the normal conventions for .el files
---
nftables-mode.el | 55 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 16 deletions(-)
diff --git a/nftables-mode.el b/nftables-mode.el
index ebb31b140b..2a39ac25ea 100644
--- a/nftables-mode.el
+++ b/nftables-mode.el
@@ -1,3 +1,28 @@
+;;; nftables-mode.el --- Major mode for editing nftables -*- lexical-binding:
t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc
+
+;; Author: trentbuck@gmail.com (Trent W. Buck)
+;; Maintainer: emacs-devel@gnu.org
+;; Version: 1.0
+;; Package-Requires: ((emacs "25.1"))
+;; Keywords: convenience
+
+;; This package is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This package is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
(require 'rx)
(require 'syntax) ; syntax-ppss, for indentation
@@ -41,9 +66,9 @@
;;; add table inet foo
;;; add chain inet foo bar { type filter hook input priority
filter; policy drop }
;;; add rule inet foo bar predicate [counter] [log]
<accept|drop|reject>
+
(defvar nftables-font-lock-keywords
- `(
- ;; include "foo"
+ `(;; include "foo"
;; list ruleset
;; flush ruleset
(,(rx bol
@@ -63,7 +88,7 @@
(,(rx bol
(group (or "define" "redefine" "undefine"))
" "
- (group (one-or-more (any alnum ?_ ?.)))
+ (group (one-or-more (any alnum ?_)))
eow)
(1 font-lock-type-face)
(2 font-lock-variable-name-face))
@@ -115,10 +140,7 @@
(3 font-lock-variable-name-face)
(4 font-lock-variable-name-face))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; REMAINING RULES NOT ANCHORED AT BEGINNING-OF-LINE
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Remaining rules not anchored at beginning-of-line.
;; << chain specification >>
;; { type filter hook input priority filter; }
@@ -228,7 +250,7 @@
;; @array
(,(rx (or "@" "$")
alpha
- (zero-or-more (any alnum ?_ ?.)))
+ (zero-or-more (any alnum ?_)))
. font-lock-variable-name-face)
;; Simplified because scanner.l is INSANE for IPv6.
@@ -268,18 +290,14 @@
" "
(group (one-or-more (any alnum ?_)))) ; chain_expr
(1 font-lock-function-name-face)
- (2 font-lock-variable-name-face))
-
-
- ))
-
+ (2 font-lock-variable-name-face))))
;;; Based on equivalent for other editors:
;;; * /usr/share/nano/nftables.nanorc
;;; * https://github.com/nfnty/vim-nftables
;;;###autoload
(define-derived-mode nftables-mode prog-mode "nft"
- "FIXME docstring"
+ "Major mode to edit nftables files."
(setq-local comment-start "#")
(setq-local font-lock-defaults
`(nftables-font-lock-keywords nil nil))
@@ -295,15 +313,20 @@
(save-excursion
(back-to-indentation)
(let ((depth (car (syntax-ppss))))
- (if (= ?\) (char-syntax (char-after)))
- (setq depth (1- depth)))
+ (when (= ?\) (char-syntax (char-after)))
+ (setq depth (1- depth)))
(indent-line-to (* depth tab-width)))
(setq old-point (point)))
(when (< (point) old-point)
(back-to-indentation))))
+;;;###autoload
(add-to-list 'auto-mode-alist '("\\.nft\\(?:ables\\)?\\'" . nftables-mode))
+;;;###autoload
(add-to-list 'auto-mode-alist '("/etc/nftables.conf" . nftables-mode))
+;;;###autoload
(add-to-list 'interpreter-mode-alist '("nft\\(?:ables\\)?" . nftables-mode))
(provide 'nftables-mode)
+
+;;; nftables-mode.el enads here.
- [elpa] externals/nftables-mode 14856f12c1 20/41: more notes, (continued)
- [elpa] externals/nftables-mode 14856f12c1 20/41: more notes, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 6fbf0a5557 01/41: Update iptab imports from twb's personal git repo., Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode e47799589c 16/41: add remaining allow/deny rules from alpha as an example, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode fb87ee1e07 24/41: Use stateful ICMP/ICMPv6 filtering by default (but leave the vmaps as documentation), Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode d04e123fc3 29/41: fixup! reference nftables ruleset, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 4974259919 30/41: typo fixes (thanks mattcen), Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 3e9c8cf907 32/41: fixup! typo fixes (thanks mattcen), Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 70910dbc2a 35/41: Merge remote-tracking branch 'KB/master', Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 109dfa382a 33/41: Remove "list ruleset" due to https://bugs.debian.org/982576, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 7f924acbac 37/41: basic README for github, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode a207b02bd6 40/41: Lightly edited, adding some of the normal conventions for .el files,
Stefan Monnier <=
- [elpa] externals/nftables-mode 1817c43fb9 02/41: Initial example nftables ruleset, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 242fae1e71 11/41: limit ICMP by type, tweak notes, expand on iif vs iifname, document "flush table" gotcha, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 794a6e6774 10/41: limit ICMP by type, tweak notes, expand on iif vs iifname, document "flush table" gotcha, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 8fcd04379c 08/41: bugfix and tweak, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode f00cf640fb 15/41: nftables - glob gotcha; HOW to rename ifaces; gateway (-i/-o) policy; mail reputation protection, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 6e908b1d67 17/41: Got the IPS working at last (inc IPv6), mua ha ha!, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 16adfabcec 21/41: add reminder re IPv6 ranges for SSH IPS, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 34ffd618ac 19/41: fixup! Got the IPS working at last (inc IPv6), mua ha ha!, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 166b789260 22/41: old comments, Stefan Monnier, 2022/05/23
- [elpa] externals/nftables-mode 9bc4a6f589 25/41: Don't do "flush ruleset" (i.e. expect auxiliary tables w/ race conditions), Stefan Monnier, 2022/05/23