re-config nyxt

This commit is contained in:
ry
2022-01-27 17:29:08 -08:00
parent 00c53c0d12
commit 4619b45675
2 changed files with 113 additions and 113 deletions

View File

@@ -1,9 +1,9 @@
(in-package :nyxt)
(load "~/quicklisp/setup.lisp")
(ql:quickload 'slynk)
;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; (asdf:load-system :slynk)
;; (slynk:create-server :port 4008)
;; (in-package :nyxt)
;; (load "~/quicklisp/setup.lisp")
;; (ql:quickload 'slynk)
;; ;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; ;; (asdf:load-system :slynk)
;; ;; (slynk:create-server :port 4008)
(load-after-system :slynk (nyxt-init-file "my-slink.lisp"))
;; (load-after-system :slynk "~/.config/nyxt/my-slynk.lisp")
@@ -133,46 +133,46 @@
(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 (&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)))))
;; (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
@@ -192,15 +192,15 @@
;; (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.
;; (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*)))
;; 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*)))

114
nyxt.org
View File

@@ -1,16 +1,16 @@
#+TITLE: Nyxt Configuration
#+PROPERTY: header-args:lisp :tangle ~/dotfiles/guix/home/files/nyxt/init.lisp :mkdirp yes
#+PROPERTY: header-args:lisp :tangle ~/dotfiles/.config/nyxt/init.lisp :mkdirp yes
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.
* Load Quicklisp & Slynk
#+begin_src lisp
(in-package :nyxt)
(load "~/quicklisp/setup.lisp")
(ql:quickload 'slynk)
;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; (asdf:load-system :slynk)
;; (slynk:create-server :port 4008)
;; (in-package :nyxt)
;; (load "~/quicklisp/setup.lisp")
;; (ql:quickload 'slynk)
;; ;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; ;; (asdf:load-system :slynk)
;; ;; (slynk:create-server :port 4008)
#+end_src
* Import Functions
#+begin_src lisp
@@ -156,46 +156,46 @@ Password managers are an essential feature and thankfully Nyxt allows me to inte
** Show bookmarks first
I've ripped these functions out of the source code and swapped the sources in order to have bookmarks show up first upon executing set-url or set-url-new-buffer.
#+begin_src lisp
(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 (&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)))))
;; (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
@@ -223,16 +223,16 @@ I would like to keep expanding on these redirection functions so I can have nati
#+end_src
* Testing
#+begin_src lisp
(defun nyxt-init-file (&optional subpath)
"Return SUBPATH relative to `*init-file-path*'.
Return nil if `*init-file-path*' is nil.
;; (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*)))
;; 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*)))
#+end_src