From 88239c51ba4a8e2eda1e68b419452980811903c6 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 2 Feb 2024 17:53:54 +0200 Subject: nyxt: Update handl-url --- .config/nyxt/commands.lisp | 36 +++++++++++++++++++----------------- .config/nyxt/config.lisp | 3 +-- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to '.config') diff --git a/.config/nyxt/commands.lisp b/.config/nyxt/commands.lisp index e89bea0..1739793 100644 --- a/.config/nyxt/commands.lisp +++ b/.config/nyxt/commands.lisp @@ -1,3 +1,5 @@ +(in-package #:nyxt-user) + (defvar *thanos/search-engines* (list '("google" "https://google.com/search?q=~a") @@ -25,23 +27,23 @@ t if so and nil otherwise. The URL must not contain spaces." Applies `func` to the query`. Requires the variable `*thanos/search-engines*` for search queries." (cond - ((or (str:starts-with-p "localhost" query)) - (funcall func (str:concat "http://" query))) - ((direct-url-p query) - (funcall func (str:concat "https://" query))) - ((str:starts-with-p "http" query) - (funcall func query)) - ((let ((split-result (str:split #\Space query))) - (find (first split-result) *thanos/search-engines* :key #'first :test #'string=)) - (let* ((engine-tag (subseq query 0 (position #\Space query))) - (query (subseq query (+ 1 (position #\Space query)))) - (engine (find engine-tag *thanos/search-engines* :key #'first :test #'string=)) - (search-url (second engine))) - (funcall func (cl-ppcre:regex-replace "~a" search-url (quri:url-encode query))))) - (t - (let* ((engine (first (last *thanos/search-engines*))) - (search-url (second engine))) - (funcall func (cl-ppcre:regex-replace "~a" search-url (quri:url-encode query))))))) + ((or (str:starts-with-p "localhost" query)) + (funcall func (str:concat "http://" query))) + ((direct-url-p query) + (funcall func (str:concat "https://" query))) + ((str:starts-with-p "http" query) + (funcall func query)) + ((let ((split-result (str:split #\Space query))) + (find (first split-result) *thanos/search-engines* :key #'first :test #'string=)) + (let* ((engine-tag (subseq query 0 (position #\Space query))) + (query (subseq query (+ 1 (position #\Space query)))) + (engine (find engine-tag *thanos/search-engines* :key #'first :test #'string=)) + (search-url (second engine))) + (funcall func (cl-ppcre:regex-replace "~a" search-url (quri:url-encode query))))) + (t + (let* ((engine (first (last *thanos/search-engines*))) + (search-url (second engine))) + (funcall func (cl-ppcre:regex-replace "~a" search-url (quri:url-encode query))))))) (defun thanos/make-buffer-focus-url (url) (make-buffer-focus :url url)) diff --git a/.config/nyxt/config.lisp b/.config/nyxt/config.lisp index d7c8ca5..6540815 100644 --- a/.config/nyxt/config.lisp +++ b/.config/nyxt/config.lisp @@ -17,8 +17,7 @@ Extension files (like dark-reader.lisp) are to append to this list. Why the variable? Because it's too much hassle copying it everywhere.") (define-nyxt-user-system-and-load nyxt-user/basic-config - :components ("keybinds" "colorscheme" "commands")) - + :components ("keys" "colors" "commands")) (define-configuration (:modable-buffer :prompt-buffer :editor-buffer) "Set up Emacs keybindings everywhere possible." -- cgit v1.2.3