added stuff

This commit is contained in:
opal
2021-12-24 11:30:30 -08:00
parent 05ee135243
commit 2f4f1f4127
2 changed files with 57 additions and 6 deletions

View File

@@ -3,6 +3,17 @@
Nyxt is a browser written in Common Lisp that follows the same philosophy of extensibility as Emacs. This makes it a perfect companion to an Emacs centered eco-system when you need a browser with more features than Eww or w3m.
* Start Slynk server
#+begin_src lisp
(ql:quickload 'slynk)
(define-command-global start-slynk (&optional (slynk-port *swank-port*))
"Start a Slynk server."
(slynk:create-server :port slynk-port :dont-close t)
(echo "Slynk server started at port ~a" slynk-port))
#+end_src
* Keybindings
#+begin_src lisp
;; Vim-normal mode by default
@@ -137,7 +148,51 @@ Password managers are an essential feature and thankfully Nyxt allows me to inte
(define-configuration buffer
((password-interface (make-instance 'password:user-keepassxc-interface))))
#+end_src
* Functions
#+begin_src emacs-lisp
(in-package :nyxt)
(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)))))
#+end_src
* Misc
** Redirection
I would like to keep expanding on these redirection functions so I can have native redirection away from sites that don't respect user privacy.