From a2934872baedf5874f0f882fe6bcd24529fbc2a4 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sat, 20 Jul 2024 14:26:28 +1200 Subject: [PATCH 01/10] esv.el: accept one package argument --- esv.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/esv.el b/esv.el index 7935696..fbd1ba2 100644 --- a/esv.el +++ b/esv.el @@ -69,31 +69,37 @@ (read-only-mode)) -(defun esv (book verses) +(defun esv (passage) "Fetch the Bible passage identified by BOOK and VERSES. The result will be redirected to a buffer named after the passage. Requires the esv command line tool to be in the system's PATH. esv can be acquired at ." - (interactive "MBook: \nMVerses: ") - (let - ((buffer (concat book " " verses)) + (interactive "MPassage: ") + (let* + ((slices (split-string passage)) + (verses (car (last slices))) + (book (mapconcat #'(lambda (e) e) + (take (1- (length slices)) slices) " ")) + (buffer (concat book " " verses)) (arg-list (append esv-arguments - (list (format "-l%d" esv-columns))))) + (list (format "-l%d" esv-columns)) + (list book) (list verses)))) + (add-to-list 'arg-list book) + (add-to-list 'arg-list verses) (catch 'buffer-exists (when (get-buffer buffer) (unless esv-close-existing-buffers (message "Buffer `%s' already exists" buffer) (throw 'buffer-exists nil)) - (kill-buffer buffer)) - (apply #'call-process esv-program nil buffer t - (append arg-list (list book) (list verses))) - (display-buffer buffer) - (with-current-buffer buffer - (esv-mode) - (goto-char (point-min))) - (set-window-start (get-buffer-window buffer) (point-min)) - t))) + (kill-buffer buffer))) + (apply #'call-process esv-program nil buffer t arg-list) + (display-buffer buffer) + (with-current-buffer buffer + (esv-mode) + (goto-char (point-min))) + (set-window-start (get-buffer-window buffer) (point-min))) + t) (provide 'esv) From b4358c84f95e8bd26dd22ed9ced8d9e7274ecba9 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sat, 20 Jul 2024 19:44:24 +1200 Subject: [PATCH 02/10] esv.el: add newlines between defcustoms --- esv.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esv.el b/esv.el index fbd1ba2..74ca353 100644 --- a/esv.el +++ b/esv.el @@ -43,18 +43,22 @@ "Whether to close an existing `esv' buffer if one already exists." :type 'boolean :group 'esv) + (defcustom esv-columns 72 "Length of each line output by `esv'." :type 'natnum :group 'esv) + (defcustom esv-mode-hook nil "Hook run after entering `esv-mode'." :type 'hook :group 'esv) + (defcustom esv-process "esv" "Name of the process created by `esv'." :type 'string :group 'esv) + (defcustom esv-program "esv" "Path to or name of the program started by `esv'." :type 'string From 59c161560ad146123d9941cb1a22e04a39146364 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 22 Jul 2024 17:19:07 +1200 Subject: [PATCH 03/10] catchup.el: init --- catchup.el | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 catchup.el diff --git a/catchup.el b/catchup.el new file mode 100644 index 0000000..aeb7509 --- /dev/null +++ b/catchup.el @@ -0,0 +1,106 @@ +;;; catchup.el --- catch up with system stats -*- lexical-binding:t -*- + +;; Copyright (C) 2024 Jeremy Baxter + +;; Author: Jeremy Baxter +;; Maintainer: Jeremy Baxter +;; Created: July 2024 + +;; This file is not part of GNU Emacs. + +;; catchup.el 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 of the License, or +;; (at your option) any later version. +;; +;; catchup.el 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 catchup.el. If not, see . + +;;; Commentary: + +;; catchup.el provides `catchup', a command for fetching system +;; stats or other information. Custom shell commands can be run +;; or a file can be read, and that information is then formatted +;; and displayed in the minibuffer. The output style and look can +;; be customized with `catchup-spec' and `catchup-separator'. + +;; TODO: add a memory statistic using `memory-info' + +;;; Code: + +(defvar catchup-buffer "*Catchup*" + "Temporary buffer used by `catchup' types.") + +(defvar catchup-separator "\t" + "Separator between `catchup' data.") + +(defvar catchup-spec '((format-time-string "%Y/%m/%d\n%T")) + "List representing data to show in `catchup'. + +Each element is a list: the car of each sublist being a symbol representing +the function to call, and the cdr being the rest of the arguments to pass +to said function. + +catchup.el provides some helper functions you can use; `catchup-file' and +`catchup-shell', which are primitives, and `catchup-battery', a helper +function built from the primitives. + +The default value represents a call to `format-time-string', which shows +the current date and time.") + +(defun catchup--strip (str) + (string-match "\\`\\s-*\\(.*?\\)\\s-*\n?\\'" str) + (match-string 1 str)) + +(defun catchup-file (file-name) + "Return the contents of the file FILE-NAME." + (let* + ((result nil) + (exists (get-file-buffer file-name)) + (buffer (if exists exists (find-file-noselect file-name)))) + (with-current-buffer buffer + (setq result (buffer-string)) + (unless exists + (kill-this-buffer))) + (catchup--strip result))) + +(defun catchup-battery (&optional battery-format) + "Return the battery capacity formatted according to BATTERY-FORMAT." + (format (or battery-format "%s") + (catchup-file "/sys/class/power_supply/BAT0/capacity"))) + +(defun catchup-shell (command) + "Return the output of running COMMAND in the shell." + (let ((result nil)) + (shell-command command catchup-buffer) + (with-current-buffer catchup-buffer + (setq result (buffer-string)) + (kill-this-buffer)) + result)) + +(defun catchup () + "Display system statistics. + +Only information in `catchup-spec' is displayed; see its documentation for +more information on configuring it. + +A separator or divider to divide information can be provided with +`catchup-separator'. This string is placed between every result." + (interactive) + (let + ((final "")) + (dolist (sublist catchup-spec) + (setq final + (concat final (catchup--strip + (apply (car sublist) (cdr sublist))) + catchup-separator))) + (message "%s" (catchup--strip final)))) + +(provide 'catchup) + +;;; catchup.el ends here From ab1fce78d8e70f1c937b230e56cde5b767fdf32c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Mon, 22 Jul 2024 19:25:13 +1200 Subject: [PATCH 04/10] tree: remove defcustom :group keywords --- esv.el | 15 +++++---------- phobos.el | 4 ---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/esv.el b/esv.el index 74ca353..e5d4778 100644 --- a/esv.el +++ b/esv.el @@ -41,28 +41,23 @@ (defcustom esv-close-existing-buffers nil "Whether to close an existing `esv' buffer if one already exists." - :type 'boolean - :group 'esv) + :type 'boolean) (defcustom esv-columns 72 "Length of each line output by `esv'." - :type 'natnum - :group 'esv) + :type 'natnum) (defcustom esv-mode-hook nil "Hook run after entering `esv-mode'." - :type 'hook - :group 'esv) + :type 'hook) (defcustom esv-process "esv" "Name of the process created by `esv'." - :type 'string - :group 'esv) + :type 'string) (defcustom esv-program "esv" "Path to or name of the program started by `esv'." - :type 'string - :group 'esv) + :type 'string) (defvar esv-arguments '() "List of additional arguments passed to `esv-program'.") diff --git a/phobos.el b/phobos.el index d480bd5..c19c2b7 100644 --- a/phobos.el +++ b/phobos.el @@ -43,19 +43,15 @@ (defcustom phobos-browser "xdg-open" "Web browser to use when opening documentation with `phobos'." - :group 'phobos :type 'string) (defcustom phobos-root "https://dlang.org/library" "Root URL to use when viewing documentation with `phobos'." - :group 'phobos :type 'string) (defcustom phobos-dpldocs-domain "dpldocs.info" "Root domain to use when viewing documentation on dub packages with `dub-doc'." - :group 'phobos :type 'string) (defcustom phobos-registry-root "https://code.dlang.org" "Root URL of the D package registry used with `describe-dub-package'." - :group 'phobos :type 'string) (defun phobos--visit (&rest format-args) From b3a94e40132fa32aa89bc209c7ddb4a759e9b908 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 09:52:19 +1200 Subject: [PATCH 05/10] esv.el: trim tagline --- esv.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esv.el b/esv.el index e5d4778..bcd6010 100644 --- a/esv.el +++ b/esv.el @@ -1,4 +1,4 @@ -;;; esv.el --- read the Bible from Emacs -*- lexical-binding:t -*- +;;; esv.el --- read the Bible -*- lexical-binding:t -*- ;; Copyright (C) 2024 Jeremy Baxter From d1533e0048e4565172c5eff0ae38ba480a032d97 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 09:52:34 +1200 Subject: [PATCH 06/10] ini-mode.el: init --- ini-mode.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ini-mode.el diff --git a/ini-mode.el b/ini-mode.el new file mode 100644 index 0000000..c5a70b9 --- /dev/null +++ b/ini-mode.el @@ -0,0 +1,51 @@ +;;; ini-mode.el --- major mode for INI -*- lexical-binding:t -*- + +;; Copyright (C) 2024 Jeremy Baxter + +;; Author: Jeremy Baxter +;; Maintainer: Jeremy Baxter +;; Created: July 2024 +;; Keywords: ini + +;; This file is not part of GNU Emacs. + +;; ini-mode.el 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 of the License, or +;; (at your option) any later version. +;; +;; ini-mode.el 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 ini-mode.el. If not, see . + +;;; Commentary: + +;; ini-mode.el provides `ini-mode', an implementation of a simple +;; font-locking major mode for INI. + +;; TODO: fix section keys refusing to highlight initially + +;;; Code: + +(require 'font-lock) + +(defvar ini-mode-font-lock-keywords + '(("\\([#;].*$\\)" . font-lock-comment-face) + ("[ \t]*\\[\\(.+\\)\\]" . 'font-lock-type-face) + ("\\(^[^=]+\\)" . 'font-lock-keyword-face) + ("=\\(.+$\\)" 1 'font-lock-string-face)) + "Keywords for font locking in `ini-mode'.") + +(define-derived-mode ini-mode nil "INI" + "Major mode for editing INI." + + (font-lock-mode) + (font-lock-add-keywords nil ini-mode-font-lock-keywords)) + +(provide 'ini-mode) + +;;; ini-mode.el ends here From 79c7ccf762c24de9964649c547898b3ace1757cc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 10:07:57 +1200 Subject: [PATCH 07/10] ini-mode.el: fix key highlighting --- ini-mode.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ini-mode.el b/ini-mode.el index c5a70b9..b5a12d1 100644 --- a/ini-mode.el +++ b/ini-mode.el @@ -27,16 +27,14 @@ ;; ini-mode.el provides `ini-mode', an implementation of a simple ;; font-locking major mode for INI. -;; TODO: fix section keys refusing to highlight initially - ;;; Code: (require 'font-lock) (defvar ini-mode-font-lock-keywords '(("\\([#;].*$\\)" . font-lock-comment-face) - ("[ \t]*\\[\\(.+\\)\\]" . 'font-lock-type-face) - ("\\(^[^=]+\\)" . 'font-lock-keyword-face) + ("\\[\\(.+\\)\\]" 1 'font-lock-type-face) + ("\\(^.+\\)=" 1 'font-lock-variable-name-face) ("=\\(.+$\\)" 1 'font-lock-string-face)) "Keywords for font locking in `ini-mode'.") From 226cf355714c221934a8013ce5453edbdae52005 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 10:29:08 +1200 Subject: [PATCH 08/10] ini-mode.el: add reference font-locking Highlight ${var}, {var} and %var% constructs. --- ini-mode.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ini-mode.el b/ini-mode.el index b5a12d1..e9b3997 100644 --- a/ini-mode.el +++ b/ini-mode.el @@ -35,7 +35,15 @@ '(("\\([#;].*$\\)" . font-lock-comment-face) ("\\[\\(.+\\)\\]" 1 'font-lock-type-face) ("\\(^.+\\)=" 1 'font-lock-variable-name-face) - ("=\\(.+$\\)" 1 'font-lock-string-face)) + ("=\\(.+$\\)" 1 'font-lock-string-face) + ("\\(\\$?{\\)\\(.+\\)\\(}\\)" + (1 'font-lock-bracket-face t) + (2 'font-lock-variable-use-face t) + (3 'font-lock-bracket-face t)) + ("\\(%\\)\\(.+\\)\\(%\\)" + (1 'font-lock-bracket-face t) + (2 'font-lock-variable-use-face t) + (3 'font-lock-bracket-face t))) "Keywords for font locking in `ini-mode'.") (define-derived-mode ini-mode nil "INI" From 0836d2efd4ed96f436341b65fc0663d4e19e1c02 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 11:02:28 +1200 Subject: [PATCH 09/10] esv.el: fix duplicate arguments --- esv.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/esv.el b/esv.el index bcd6010..e8b16a7 100644 --- a/esv.el +++ b/esv.el @@ -84,8 +84,6 @@ esv can be acquired at ." (arg-list (append esv-arguments (list (format "-l%d" esv-columns)) (list book) (list verses)))) - (add-to-list 'arg-list book) - (add-to-list 'arg-list verses) (catch 'buffer-exists (when (get-buffer buffer) (unless esv-close-existing-buffers From 615f0e4ca59278f78d01b8fe7a13dd0c435a3737 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 23 Jul 2024 11:02:20 +1200 Subject: [PATCH 10/10] tree: checkdoc --- catchup.el | 6 +++--- enotify.el | 11 ++++++++--- erc-highlight-nicknames.el | 11 +++++------ esv.el | 4 ++-- phobos.el | 9 +++++---- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/catchup.el b/catchup.el index aeb7509..b199ce8 100644 --- a/catchup.el +++ b/catchup.el @@ -24,9 +24,9 @@ ;;; Commentary: ;; catchup.el provides `catchup', a command for fetching system -;; stats or other information. Custom shell commands can be run +;; stats or other information. Custom shell commands can be run ;; or a file can be read, and that information is then formatted -;; and displayed in the minibuffer. The output style and look can +;; and displayed in the minibuffer. The output style and look can ;; be customized with `catchup-spec' and `catchup-separator'. ;; TODO: add a memory statistic using `memory-info' @@ -90,7 +90,7 @@ Only information in `catchup-spec' is displayed; see its documentation for more information on configuring it. A separator or divider to divide information can be provided with -`catchup-separator'. This string is placed between every result." +`catchup-separator'. This string is placed between every result." (interactive) (let ((final "")) diff --git a/enotify.el b/enotify.el index 9f1000e..3779a86 100644 --- a/enotify.el +++ b/enotify.el @@ -22,14 +22,19 @@ ;; You should have received a copy of the GNU General Public License ;; along with enotify.el. If not, see . +;;; Commentary: + +;; enotify.el provides `enotify', a command for connecting to an IRC +;; server, joining a channel, sending a message, and then leaving. + ;;; Code: (defvar enotify-buffer "*enotify*" - "Name of the enotify process buffer") + "Name of the `enotify' process buffer.") (defvar enotify-proc "enotify-process" - "Name of the enotify socket process") + "Name of the `enotify' socket process.") (defvar enotify-realname "enotify-client" - "enotify's IRC realname that shows up in /whois") + "IRC realname for `enotify' that shows up in /whois.") (defun enotify-send-string (proc string) (process-send-string proc (concat string "\r\n"))) diff --git a/erc-highlight-nicknames.el b/erc-highlight-nicknames.el index 4b9f170..0f125fd 100644 --- a/erc-highlight-nicknames.el +++ b/erc-highlight-nicknames.el @@ -28,7 +28,7 @@ ;;; Commentary: ;; This is a modified version of erc-highlight-nicknames.el from -;; . It has been +;; . It has been ;; extended to use the configured ERC colour palette, using the faces ;; with names beginning with `fg:erc-color-face'. ;; @@ -36,7 +36,7 @@ ;; for a list of these faces. ;; Originally authored by André Riemann in 2007 and updated from 2008-2014 -;; by Andy Stewart. ERC face support was added by Jeremy Baxter in 2023. +;; by Andy Stewart. ERC face support was added by Jeremy Baxter in 2023. ;; To use erc-highlight-nicknames.el, put this in your init file: ;; @@ -108,8 +108,7 @@ (defface erc-highlight-nick-base-face '((t nil)) - "Base face used for highlighting nicknames in ERC before the -color is added." + "Face used for highlighting nicknames before color is added." :group 'erc-faces) (defvar erc-highlight-face-table @@ -117,7 +116,7 @@ color is added." "Hash table containing unique ERC nickname faces.") (defun hexcolor-luminance (color) - "Returns the luminance of color COLOR. COLOR is a string \(e.g. + "Return the luminance of color COLOR. COLOR is a string \(e.g. \"#ffaa00\", \"blue\"\) `color-values' accepts. Luminance is a value of 0.299 red + 0.587 green + 0.114 blue and is always between 0 and 255." @@ -128,7 +127,7 @@ between 0 and 255." (floor (+ (* 0.299 r) (* 0.587 g) (* 0.114 b)) 256))) (defun invert-color (color) - "Returns the inverted color of COLOR." + "Return the inverted color of COLOR." (let* ((values (x-color-values color)) (r (car values)) (g (car (cdr values))) diff --git a/esv.el b/esv.el index e8b16a7..2f49a8b 100644 --- a/esv.el +++ b/esv.el @@ -69,8 +69,8 @@ (read-only-mode)) (defun esv (passage) - "Fetch the Bible passage identified by BOOK and VERSES. -The result will be redirected to a buffer named after the passage. + "Fetch the Bible passage identified by PASSAGE. +The result will be redirected to a buffer named after PASSAGE. Requires the esv command line tool to be in the system's PATH. esv can be acquired at ." diff --git a/phobos.el b/phobos.el index c19c2b7..0afdd6a 100644 --- a/phobos.el +++ b/phobos.el @@ -1,4 +1,4 @@ -;;; phobos.el --- view Phobos documentation from within Emacs -*- lexical-binding:t -*- +;;; phobos.el --- view Phobos documentation -*- lexical-binding:t -*- ;; Copyright (C) 2024 Jeremy Baxter @@ -25,7 +25,7 @@ ;;; Commentary: ;; phobos.el provides several functions for viewing Phobos documentation -;; and documentation for other D libraries. These functions open the +;; and documentation for other D libraries. These functions open the ;; documentation in a web browser, calling the process `phobos-browser'. ;; These functions are provided: @@ -55,6 +55,7 @@ :type 'string) (defun phobos--visit (&rest format-args) + "Call `format' with FORMAT-ARGS and pass the result to a web browser." (let ((url (apply #'format format-args))) (shell-command (concat phobos-browser " " url)) (message url))) @@ -67,7 +68,7 @@ SYMBOL can be a module (e.g. std.sumtype), a submodule (e.g. std.algorithm.searching), a function or type (e.g. std.stdio.File) or any other symbol part of a standard module, such as object.Exception. -Phobos is the standard library for the D programming language. For more +Phobos is the standard library for the D programming language. For more information on Phobos and the D programming language, see ." (interactive "MModule or symbol: ") (phobos--visit "%s/%s.html" phobos-root (string-replace "." "/" symbol))) @@ -77,7 +78,7 @@ information on Phobos and the D programming language, see ." "View the documentation on SYMBOL from the dub package PACKAGE. PACKAGE is the name of a package listed on the code.dlang.org registry. -For more information on SYMBOL, see the documentation for `phobos'. If +For more information on SYMBOL, see the documentation for `phobos'. If SYMBOL is not provided, the contents of PACKAGE is displayed instead. Support for dub package documentation is provided by Adam Ruppe's