bunch of stuff

This commit is contained in:
opal
2021-12-24 20:29:45 -08:00
parent a3c2b64294
commit d9ed862089
6 changed files with 422 additions and 94 deletions

View File

@@ -1,4 +1,9 @@
(load-after-system :slynk "~/.config/nyxt/my-slynk.lisp")
(in-package :nyxt)
(load "~/quicklisp/setup.lisp")
(ql:quickload 'slynk)
(load-after-system :slynk (nyxt-init-file "my-slink.lisp"))
;; (load-after-system :slynk "~/.config/nyxt/my-slynk.lisp")
;; Vim-normal mode by default
(define-configuration buffer
@@ -125,6 +130,47 @@
(define-configuration buffer
((password-interface (make-instance 'password:user-keepassxc-interface))))
(define-command set-url (&key (prefill-current-url-p t))
"Set the URL for the current buffer, completing with history."
(let ((history (set-url-history *browser*))
(actions (list (make-command buffer-load* (suggestion-values)
"Load first selected URL in current buffer and the rest in new buffer(s)."
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(buffer-load (url (first suggestion-values))))
(make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)."
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer)))
(prompt
:prompt "Open URL"
:input (if prefill-current-url-p
(render-url (url (current-buffer))) "")
:history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-source :actions actions)))))
(define-command set-url-new-buffer (&key (prefill-current-url-p t))
"Prompt for a URL and set it in a new focused buffer."
(let ((history (set-url-history *browser*))
(actions (list (make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)"
(mapc (lambda (suggestion) (make-buffer :url (url suggestion)))
(rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer)))
(prompt
:prompt "Open URL in new buffer"
:input (if prefill-current-url-p
(render-url (url (current-buffer))) "")
:history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-source :actions actions)))))
;; I would like to implement redirection, or some extension to handle it for me.
;; todo: Redirect reddit to teddit
;; (defun old-reddit-handler (request-data)
@@ -142,3 +188,16 @@
;; ((request-resource-hook
;; (hooks:add-hook %slot-default% (make-handler-resource #'old-reddit-handler)))))
;; (See url-dispatching-handler for a simpler way to achieve the same result.)
(defun nyxt-init-file (&optional subpath)
"Return SUBPATH relative to `*init-file-path*'.
Return nil if `*init-file-path*' is nil.
Example:
If we want to load a define-command procedure that lives in ~/path/to/nyxt/config/dir/my-slink.lisp
(load-after-system :slynk (nyxt-init-file \"my-slink.lisp\"))"
(if subpath
(uiop:subpathname* (uiop:pathname-directory-pathname
(expand-path *init-file-path*))
subpath)
(expand-path *init-file-path*)))