From 0f419973b2ce220b54a6f673e282af92e2dc1306 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 12:55:46 +0100 Subject: [PATCH] update engine-mode Signed-off-by: Andreas Gerler --- .../engine-mode-autoloads.el | 76 ------- .../engine-mode-pkg.el | 2 - elpa/engine-mode-20191105.750/engine-mode.el | 178 --------------- .../engine-mode-autoloads.el | 97 +++++++++ .../engine-mode-pkg.el | 9 + elpa/engine-mode-20240906.453/engine-mode.el | 206 ++++++++++++++++++ elpa/engine-mode-readme.txt | 23 -- 7 files changed, 312 insertions(+), 279 deletions(-) delete mode 100644 elpa/engine-mode-20191105.750/engine-mode-autoloads.el delete mode 100644 elpa/engine-mode-20191105.750/engine-mode-pkg.el delete mode 100644 elpa/engine-mode-20191105.750/engine-mode.el create mode 100644 elpa/engine-mode-20240906.453/engine-mode-autoloads.el create mode 100644 elpa/engine-mode-20240906.453/engine-mode-pkg.el create mode 100644 elpa/engine-mode-20240906.453/engine-mode.el delete mode 100644 elpa/engine-mode-readme.txt diff --git a/elpa/engine-mode-20191105.750/engine-mode-autoloads.el b/elpa/engine-mode-20191105.750/engine-mode-autoloads.el deleted file mode 100644 index 8b5a02a4..00000000 --- a/elpa/engine-mode-20191105.750/engine-mode-autoloads.el +++ /dev/null @@ -1,76 +0,0 @@ -;;; engine-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "engine-mode" "engine-mode.el" (0 0 0 0)) -;;; Generated autoloads from engine-mode.el - -(defvar engine-mode nil "\ -Non-nil if Engine mode is enabled. -See the `engine-mode' command -for a description of this minor mode.") - -(custom-autoload 'engine-mode "engine-mode" nil) - -(autoload 'engine-mode "engine-mode" "\ -Minor mode for defining and querying search engines through Emacs. - -\\{engine-mode-map} - -\(fn &optional ARG)" t nil) - -(autoload 'defengine "engine-mode" "\ -Define a custom search engine. - -`engine-name' is a symbol naming the engine. -`search-engine-url' is the url to be queried, with a \"%s\" -standing in for the search term. -The optional keyword argument `docstring' assigns a docstring to -the generated function. A reasonably sensible docstring will be -generated if a custom one isn't provided. -The optional keyword argument `browser` assigns the browser -function to be used when opening the URL. -The optional keyword argument `term-transformation-hook' is a -function that will be applied to the search term before it's -substituted into `search-engine-url'. For example, if we wanted -to always upcase our search terms, we might use: - -\(defengine duckduckgo - \"https://duckduckgo.com/?q=%s\" - :term-transformation-hook 'upcase) - -In this case, searching for \"foobar\" will hit the url -\"https://duckduckgo.com/?q=FOOBAR\". - -The optional keyword argument `keybinding' is a string describing -the key to bind the new function. - -Keybindings are in the `engine-mode-map', so they're prefixed. - -For example, to search Wikipedia, use: - - (defengine wikipedia - \"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s\" - :keybinding \"w\" - :docstring \"Search Wikipedia!\") - -Hitting \"C-x / w\" will be bound to the newly-defined -`engine/search-wikipedia' function. - -\(fn ENGINE-NAME SEARCH-ENGINE-URL &key KEYBINDING DOCSTRING (BROWSER \\='engine/browser-function) (TERM-TRANSFORMATION-HOOK \\='identity))" nil t) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "engine-mode" '("engine"))) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; engine-mode-autoloads.el ends here diff --git a/elpa/engine-mode-20191105.750/engine-mode-pkg.el b/elpa/engine-mode-20191105.750/engine-mode-pkg.el deleted file mode 100644 index 64bde47d..00000000 --- a/elpa/engine-mode-20191105.750/engine-mode-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "engine-mode" "20191105.750" "Define and query search engines from within Emacs." '((cl-lib "0.5")) :commit "96b3488a6de2f50b8ba3a101e04ebcbe9821a989" :authors '(("Harry R. Schwartz" . "hello@harryrschwartz.com")) :maintainer '("Harry R. Schwartz" . "hello@harryrschwartz.com") :url "https://github.com/hrs/engine-mode") diff --git a/elpa/engine-mode-20191105.750/engine-mode.el b/elpa/engine-mode-20191105.750/engine-mode.el deleted file mode 100644 index 229de5f6..00000000 --- a/elpa/engine-mode-20191105.750/engine-mode.el +++ /dev/null @@ -1,178 +0,0 @@ -;;; engine-mode.el --- Define and query search engines from within Emacs. - -;; Author: Harry R. Schwartz -;; Version: 2.1.1 -;; Package-Version: 20191105.750 -;; URL: https://github.com/hrs/engine-mode -;; Package-Requires: ((cl-lib "0.5")) - -;; This file is NOT part of GNU Emacs. - -;;; Commentary: - -;; `engine-mode' is a global minor mode for Emacs. It enables you to -;; easily define search engines, bind them to keybindings, and query -;; them from the comfort of your editor. - -;; For example, suppose we want to be able to easily search GitHub: - -;; (defengine github -;; "https://github.com/search?ref=simplesearch&q=%s") - -;; This defines an interactive function `engine/search-github'. When -;; executed it will take the selected region (or prompt for input, if -;; no region is selected) and search GitHub for it, displaying the -;; results in your default browser. - -;; The `defengine' macro can also take an optional key combination, -;; prefixed with "C-x /": - -;; (defengine duckduckgo -;; "https://duckduckgo.com/?q=%s" -;; :keybinding "d") - -;; `C-x / d' is now bound to the new function -;; engine/search-duckduckgo'! Nifty. - -;;; License: - -;; This program 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. - -;; This program 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 this program. If not, see . - -;;; Code: -(eval-when-compile (require 'cl-macs)) - -(defcustom engine/keybinding-prefix "C-x /" - "The default engine-mode keybindings prefix." - :group 'engine-mode - :type 'string) - -(define-prefix-command 'engine-mode-prefixed-map) -(defvar engine-mode-prefixed-map) - -(defvar engine-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd engine/keybinding-prefix) engine-mode-prefixed-map) - map) - "Keymap for `engine-mode'.") - -;;;###autoload -(define-minor-mode engine-mode - "Minor mode for defining and querying search engines through Emacs. - -\\{engine-mode-map}" - :global t - :keymap engine-mode-map) - -(defun engine/set-keymap-prefix (prefix-key) - "Bind the engine-mode keymap to a new prefix. -For example, to use \"C-c s\" instead of the default \"C-x /\": - -\(engine/set-keymap-prefix (kbd \"C-c s\"))" - (define-key engine-mode-map (kbd engine/keybinding-prefix) nil) - (define-key engine-mode-map prefix-key engine-mode-prefixed-map)) - -(defcustom engine/browser-function nil - "The default browser function used when opening a URL in an engine. -Defaults to `nil' which means to go with `browse-url-browser-function'." - :group 'engine-mode - :type 'symbol) - -(defun engine/search-prompt (engine-name default-word) - (if (string= default-word "") - (format "Search %s: " (capitalize engine-name)) - (format "Search %s (%s): " (capitalize engine-name) default-word))) - -(defun engine/prompted-search-term (engine-name) - (let ((current-word (or (thing-at-point 'symbol 'no-properties) ""))) - (read-string (engine/search-prompt engine-name current-word) - nil nil current-word))) - -(defun engine/get-query (engine-name) - "Return the selected region (if any) or prompt the user for a query." - (if (use-region-p) - (buffer-substring (region-beginning) (region-end)) - (engine/prompted-search-term engine-name))) - -(defun engine/execute-search (search-engine-url browser-function search-term) - "Display the results of the query." - (interactive) - (let ((browse-url-browser-function (or browser-function - browse-url-browser-function))) - (browse-url - (format-spec search-engine-url - (format-spec-make ?s (url-hexify-string search-term)))))) - -(defun engine/function-name (engine-name) - (intern (concat "engine/search-" (downcase (symbol-name engine-name))))) - -(defun engine/docstring (engine-name) - (concat "Search " - (capitalize (symbol-name engine-name)) - " for the selected text. Prompt for input if none is selected.")) - -(defun engine/bind-key (engine-name keybinding) - (when keybinding - `(define-key engine-mode-prefixed-map (kbd ,keybinding) - (quote ,(engine/function-name engine-name))))) - -;;;###autoload -(cl-defmacro defengine (engine-name search-engine-url &key keybinding docstring (browser 'engine/browser-function) (term-transformation-hook 'identity)) - "Define a custom search engine. - -`engine-name' is a symbol naming the engine. -`search-engine-url' is the url to be queried, with a \"%s\" -standing in for the search term. -The optional keyword argument `docstring' assigns a docstring to -the generated function. A reasonably sensible docstring will be -generated if a custom one isn't provided. -The optional keyword argument `browser` assigns the browser -function to be used when opening the URL. -The optional keyword argument `term-transformation-hook' is a -function that will be applied to the search term before it's -substituted into `search-engine-url'. For example, if we wanted -to always upcase our search terms, we might use: - -\(defengine duckduckgo - \"https://duckduckgo.com/?q=%s\" - :term-transformation-hook 'upcase) - -In this case, searching for \"foobar\" will hit the url -\"https://duckduckgo.com/?q=FOOBAR\". - -The optional keyword argument `keybinding' is a string describing -the key to bind the new function. - -Keybindings are in the `engine-mode-map', so they're prefixed. - -For example, to search Wikipedia, use: - - (defengine wikipedia - \"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s\" - :keybinding \"w\" - :docstring \"Search Wikipedia!\") - -Hitting \"C-x / w\" will be bound to the newly-defined -`engine/search-wikipedia' function." - - (cl-assert (symbolp engine-name)) - `(prog1 - (defun ,(engine/function-name engine-name) (search-term) - ,(or docstring (engine/docstring engine-name)) - (interactive - (list (engine/get-query ,(symbol-name engine-name)))) - (engine/execute-search ,search-engine-url ,browser (,term-transformation-hook search-term))) - ,(engine/bind-key engine-name keybinding))) - -(provide 'engine-mode) -;;; engine-mode.el ends here diff --git a/elpa/engine-mode-20240906.453/engine-mode-autoloads.el b/elpa/engine-mode-20240906.453/engine-mode-autoloads.el new file mode 100644 index 00000000..e196628f --- /dev/null +++ b/elpa/engine-mode-20240906.453/engine-mode-autoloads.el @@ -0,0 +1,97 @@ +;;; engine-mode-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from engine-mode.el + +(defvar engine-mode nil "\ +Non-nil if Engine mode is enabled. +See the `engine-mode' command +for a description of this minor mode.") +(custom-autoload 'engine-mode "engine-mode" nil) +(autoload 'engine-mode "engine-mode" "\ +Minor mode for defining and querying search engines through Emacs. + +\\{engine-mode-map} + +This is a global minor mode. If called interactively, toggle the +`Engine mode' mode. If the prefix argument is positive, enable the +mode, and if it is zero or negative, disable the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='engine-mode)'. + +The mode's hook is called both when the mode is enabled and when it is +disabled. + +(fn &optional ARG)" t) +(autoload 'defengine "engine-mode" "\ +Define a custom engine ENGINE-NAME searching SEARCH-ENGINE-URL. + +ENGINE-NAME is a symbol naming the engine. + +SEARCH-ENGINE-URL is the url to be queried, with a \"%s\" +standing in for the search term. + +The optional keyword argument DOCSTRING assigns a docstring to +the generated function. A reasonably sensible docstring will be +generated if a custom one isn't provided. + +The optional keyword argument BROWSER assigns the browser +function to be used when opening the URL. + +The optional keyword argument TERM-TRANSFORMATION-HOOK is a +function that will be applied to the search term before it's +substituted into SEARCH-ENGINE-URL. For example, if we wanted to +always upcase our search terms, we might use: + +(defengine duckduckgo + \"https://duckduckgo.com/?q=%s\" + :term-transformation-hook upcase) + +In this case, searching for \"foobar\" will hit the url +\"https://duckduckgo.com/?q=FOOBAR\". + +The optional keyword argument KEYBINDING is a string describing +the key to bind the new function. + +Keybindings are in `engine-mode-map', so they're prefixed. + +For example, to search Wikipedia, use: + + (defengine wikipedia + \"https://www.wikipedia.org/search-redirect.php?search=%s\" + :keybinding \"w\" + :docstring \"Search Wikipedia!\") + +Hitting \"C-x / w\" will be bound to the newly-defined +`engine/search-wikipedia' function. + +(fn ENGINE-NAME SEARCH-ENGINE-URL &key KEYBINDING DOCSTRING (BROWSER \\='engine/browser-function) (TERM-TRANSFORMATION-HOOK \\='identity))" nil t) +(function-put 'defengine 'lisp-indent-function 1) +(register-definition-prefixes "engine-mode" '("engine")) + +;;; End of scraped data + +(provide 'engine-mode-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; engine-mode-autoloads.el ends here diff --git a/elpa/engine-mode-20240906.453/engine-mode-pkg.el b/elpa/engine-mode-20240906.453/engine-mode-pkg.el new file mode 100644 index 00000000..e4ee7527 --- /dev/null +++ b/elpa/engine-mode-20240906.453/engine-mode-pkg.el @@ -0,0 +1,9 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "engine-mode" "20240906.453" + "Define and query search engines." + '((emacs "24.4")) + :url "https://github.com/hrs/engine-mode" + :commit "1cfdaef7e019aecc1b648036c3434c99d6d308bc" + :revdesc "1cfdaef7e019" + :authors '(("Robin Schwartz" . "hello@robinschwartz.me")) + :maintainers '(("Robin Schwartz" . "hello@robinschwartz.me"))) diff --git a/elpa/engine-mode-20240906.453/engine-mode.el b/elpa/engine-mode-20240906.453/engine-mode.el new file mode 100644 index 00000000..17d8b0f3 --- /dev/null +++ b/elpa/engine-mode-20240906.453/engine-mode.el @@ -0,0 +1,206 @@ +;;; engine-mode.el --- Define and query search engines + +;; Author: Robin Schwartz +;; Maintainer: Robin Schwartz +;; Package-Version: 20240906.453 +;; Package-Revision: 1cfdaef7e019 +;; URL: https://github.com/hrs/engine-mode +;; Package-Requires: ((emacs "24.4")) + +;; This file is NOT part of GNU Emacs. + +;; This program 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. + +;; This program 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 +;; this program. If not, see . + +;;; Commentary: + +;; `engine-mode' is a global minor mode for Emacs. It enables you to easily +;; define search engines, bind them to keybindings, and query them from the +;; comfort of your editor. + +;; For example, suppose we want to be able to easily search GitHub: + +;; (defengine github +;; "https://github.com/search?ref=simplesearch&q=%s") + +;; This defines an interactive function `engine/search-github'. When executed it +;; will take the selected region (or prompt for input, if no region is selected) +;; and search GitHub for it, displaying the results in your default browser. + +;; The `defengine' macro can also take an optional key combination, +;; prefixed with "C-x /": + +;; (defengine duckduckgo +;; "https://duckduckgo.com/?q=%s" +;; :keybinding "d") + +;; `C-x / d' is now bound to the new function +;; engine/search-duckduckgo'! Nifty. + +;;; Code: +(eval-when-compile (require 'cl-lib)) +(require 'format-spec) + +(defgroup engine nil + "Define search engines, bind them to keybindings, and query them." + :group 'external) + +(defcustom engine/keybinding-prefix "C-x /" + "The default `engine-mode' keybindings prefix." + :group 'engine + :type '(choice (string :tag "Key") + (const :tag "No keybinding" nil))) + +(define-prefix-command 'engine-mode-prefixed-map) +(defvar engine-mode-prefixed-map) + +(defvar engine-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd engine/keybinding-prefix) engine-mode-prefixed-map) + map) + "Keymap for `engine-mode'.") + +;;;###autoload +(define-minor-mode engine-mode + "Minor mode for defining and querying search engines through Emacs. + +\\{engine-mode-map}" + :global t + :keymap engine-mode-map) + +(defun engine/set-keymap-prefix (prefix-key) + "Bind the engine-mode keymap to PREFIX-KEY. +For example, to use \"C-c s\" instead of the default \"C-x /\": + +\(engine/set-keymap-prefix (kbd \"C-c s\"))" + (when engine/keybinding-prefix + (define-key engine-mode-map (kbd engine/keybinding-prefix) nil)) + (define-key engine-mode-map prefix-key engine-mode-prefixed-map)) + +(defcustom engine/browser-function browse-url-browser-function + "The default browser function used when opening a URL in an engine. +Defaults to `browse-url-browser-function'." + :group 'engine + :type 'symbol) + +(defun engine--search-prompt (engine-name default-word) + "Return a search prompt for ENGINE-NAME, defaulting to DEFAULT-WORD." + (if (string= default-word "") + (format "Search %s: " (capitalize engine-name)) + (format "Search %s (%s): " (capitalize engine-name) default-word))) + +(defun engine--prompted-search-term (engine-name) + "Prompt the user for a search term for ENGINE-NAME. +Default to the symbol at point." + (let ((current-word (or (thing-at-point 'symbol 'no-properties) ""))) + (read-string (engine--search-prompt engine-name current-word) + nil nil current-word))) + +(defun engine--get-query (engine-name) + "Return the selected region or prompt the user for a query for ENGINE-NAME." + (if (use-region-p) + (buffer-substring (region-beginning) (region-end)) + (engine--prompted-search-term engine-name))) + +(defun engine--execute-search (search-engine-url browser-function search-term) + "Search SEARCH-ENGINE-URL for SEARCH-TERM. +Display the resulting URL with BROWSER-FUNCTION." + (interactive) + (let ((browse-url-browser-function browser-function)) + (browse-url + (format-spec search-engine-url + (format-spec-make ?s (url-hexify-string search-term)))))) + +(defun engine--function-name (engine-name) + "Return the name of the function for ENGINE-NAME. + +For example, if ENGINE-NAME is the symbol `github', return +`engine/search-github'." + (intern (concat "engine/search-" (downcase (symbol-name engine-name))))) + +(defun engine--docstring (engine-name) + "Construct and return a default docstring for ENGINE-NAME." + (format "Search %s for the selected text.\nPrompt for input if none is selected." + (capitalize (symbol-name engine-name)))) + +(defun engine--bind-key (engine-name keybinding) + "Bind KEYBINDING to ENGINE-NAME in the `engine-mode-prefixed-map'. + +Do nothing if KEYBINDING is nil. + +Use `keymap-set' instead of `define-key' if it's available, since +it permits multiple keys in KEYBINDING." + (when keybinding + (if (fboundp 'keymap-set) + `(keymap-set engine-mode-prefixed-map ,keybinding + (quote ,(engine--function-name engine-name))) + `(define-key engine-mode-prefixed-map (kbd ,keybinding) + (quote ,(engine--function-name engine-name)))))) + +;;;###autoload +(cl-defmacro defengine (engine-name search-engine-url + &key keybinding docstring + (browser 'engine/browser-function) + (term-transformation-hook 'identity)) + "Define a custom engine ENGINE-NAME searching SEARCH-ENGINE-URL. + +ENGINE-NAME is a symbol naming the engine. + +SEARCH-ENGINE-URL is the url to be queried, with a \"%s\" +standing in for the search term. + +The optional keyword argument DOCSTRING assigns a docstring to +the generated function. A reasonably sensible docstring will be +generated if a custom one isn't provided. + +The optional keyword argument BROWSER assigns the browser +function to be used when opening the URL. + +The optional keyword argument TERM-TRANSFORMATION-HOOK is a +function that will be applied to the search term before it's +substituted into SEARCH-ENGINE-URL. For example, if we wanted to +always upcase our search terms, we might use: + +\(defengine duckduckgo + \"https://duckduckgo.com/?q=%s\" + :term-transformation-hook upcase) + +In this case, searching for \"foobar\" will hit the url +\"https://duckduckgo.com/?q=FOOBAR\". + +The optional keyword argument KEYBINDING is a string describing +the key to bind the new function. + +Keybindings are in `engine-mode-map', so they're prefixed. + +For example, to search Wikipedia, use: + + (defengine wikipedia + \"https://www.wikipedia.org/search-redirect.php?search=%s\" + :keybinding \"w\" + :docstring \"Search Wikipedia!\") + +Hitting \"C-x / w\" will be bound to the newly-defined +`engine/search-wikipedia' function." + (declare (indent 1)) + (cl-assert (symbolp engine-name)) + `(prog1 + (defun ,(engine--function-name engine-name) (search-term) + ,(or docstring (engine--docstring engine-name)) + (interactive + (list (engine--get-query ,(symbol-name engine-name)))) + (engine--execute-search ,search-engine-url ,browser (,term-transformation-hook search-term))) + ,(engine--bind-key engine-name keybinding))) + +(provide 'engine-mode) +;;; engine-mode.el ends here diff --git a/elpa/engine-mode-readme.txt b/elpa/engine-mode-readme.txt deleted file mode 100644 index b6774c3d..00000000 --- a/elpa/engine-mode-readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -`engine-mode' is a global minor mode for Emacs. It enables you to -easily define search engines, bind them to keybindings, and query -them from the comfort of your editor. - -For example, suppose we want to be able to easily search GitHub: - -(defengine github - "https://github.com/search?ref=simplesearch&q=%s") - -This defines an interactive function `engine/search-github'. When -executed it will take the selected region (or prompt for input, if -no region is selected) and search GitHub for it, displaying the -results in your default browser. - -The `defengine' macro can also take an optional key combination, -prefixed with "C-x /": - -(defengine duckduckgo - "https://duckduckgo.com/?q=%s" - :keybinding "d") - -`C-x / d' is now bound to the new function -engine/search-duckduckgo'! Nifty. -- 2.47.3