From 7d64c06589bad2e79f122adfb6887c5ec8f9843f Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 11 Jul 2024 16:45:20 +1200 Subject: [PATCH] phobos.el: init --- phobos.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 phobos.el diff --git a/phobos.el b/phobos.el new file mode 100644 index 0000000..179e472 --- /dev/null +++ b/phobos.el @@ -0,0 +1,41 @@ +;;; phobos.el --- view Phobos documentation from within Emacs -*- lexical-binding:t -*- + +;; Copyright (C) 2024 Jeremy Baxter + +;; Author: Jeremy Baxter +;; Created: July 2024 +;; Keywords: d + +;; This file is not part of GNU Emacs. + +;; phobos.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. +;; +;; phobos.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 phobos.el. If not, see . + +;;; Code: + +(defvar phobos-browser "xdg-open" + "Web browser to use when opening Phobos documentation.") +(defvar phobos-root "https://dlang.org/library" + "Root URL to use when viewing Phobos documentation.") + +(defun phobos (symbol-name) + "View the documentation on SYMBOL-NAME from the Phobos documentation. + +SYMBOL-NAME can be a module (e.g. std.algorithm), a submodule (e.g. +std.algorithm.searching), a function (e.g. std.algorithm.searching.findSplit) +or any other symbol part of a standard module, such as object.Exception." + (interactive "MModule or symbol: ") + (shell-command (concat phobos-browser " " phobos-root "/" + (string-replace "." "/" symbol-name) ".html"))) + +(provide 'phobos)