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
+56 -56
View File
@@ -1,9 +1,9 @@
(in-package :nyxt) ;; (in-package :nyxt)
(load "~/quicklisp/setup.lisp") ;; (load "~/quicklisp/setup.lisp")
(ql:quickload 'slynk) ;; (ql:quickload 'slynk)
;; (push #p"~/common-lisp/sly/" asdf:*central-registry*) ;; ;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; (asdf:load-system :slynk) ;; ;; (asdf:load-system :slynk)
;; (slynk:create-server :port 4008) ;; ;; (slynk:create-server :port 4008)
(load-after-system :slynk (nyxt-init-file "my-slink.lisp")) (load-after-system :slynk (nyxt-init-file "my-slink.lisp"))
;; (load-after-system :slynk "~/.config/nyxt/my-slynk.lisp") ;; (load-after-system :slynk "~/.config/nyxt/my-slynk.lisp")
@@ -133,46 +133,46 @@
(define-configuration buffer (define-configuration buffer
((password-interface (make-instance 'password:user-keepassxc-interface)))) ((password-interface (make-instance 'password:user-keepassxc-interface))))
(define-command set-url (&key (prefill-current-url-p t)) ;; (define-command set-url (&key (prefill-current-url-p t))
"Set the URL for the current buffer, completing with history." ;; "Set the URL for the current buffer, completing with history."
(let ((history (set-url-history *browser*)) ;; (let ((history (set-url-history *browser*))
(actions (list (make-command buffer-load* (suggestion-values) ;; (actions (list (make-command buffer-load* (suggestion-values)
"Load first selected URL in current buffer and the rest in new buffer(s)." ;; "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)) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(buffer-load (url (first suggestion-values)))) ;; (buffer-load (url (first suggestion-values))))
(make-command new-buffer-load (suggestion-values) ;; (make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)." ;; "Load URL(s) in new buffer(s)."
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values)) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values))))))) ;; (make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer))) ;; (pushnew-url-history history (url (current-buffer)))
(prompt ;; (prompt
:prompt "Open URL" ;; :prompt "Open URL"
:input (if prefill-current-url-p ;; :input (if prefill-current-url-p
(render-url (url (current-buffer))) "") ;; (render-url (url (current-buffer))) "")
:history history ;; :history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions) ;; :sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions) ;; (make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions) ;; (make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-source :actions actions))))) ;; (make-instance 'search-engine-url-source :actions actions)))))
(define-command set-url-new-buffer (&key (prefill-current-url-p t)) ;; (define-command set-url-new-buffer (&key (prefill-current-url-p t))
"Prompt for a URL and set it in a new focused buffer." ;; "Prompt for a URL and set it in a new focused buffer."
(let ((history (set-url-history *browser*)) ;; (let ((history (set-url-history *browser*))
(actions (list (make-command new-buffer-load (suggestion-values) ;; (actions (list (make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)" ;; "Load URL(s) in new buffer(s)"
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion)))
(rest suggestion-values)) ;; (rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values))))))) ;; (make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer))) ;; (pushnew-url-history history (url (current-buffer)))
(prompt ;; (prompt
:prompt "Open URL in new buffer" ;; :prompt "Open URL in new buffer"
:input (if prefill-current-url-p ;; :input (if prefill-current-url-p
(render-url (url (current-buffer))) "") ;; (render-url (url (current-buffer))) "")
:history history ;; :history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions) ;; :sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions) ;; (make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions) ;; (make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-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. ;; I would like to implement redirection, or some extension to handle it for me.
;; todo: Redirect reddit to teddit ;; todo: Redirect reddit to teddit
@@ -192,15 +192,15 @@
;; (hooks:add-hook %slot-default% (make-handler-resource #'old-reddit-handler))))) ;; (hooks:add-hook %slot-default% (make-handler-resource #'old-reddit-handler)))))
;; (See url-dispatching-handler for a simpler way to achieve the same result.) ;; (See url-dispatching-handler for a simpler way to achieve the same result.)
(defun nyxt-init-file (&optional subpath) ;; (defun nyxt-init-file (&optional subpath)
"Return SUBPATH relative to `*init-file-path*'. ;; "Return SUBPATH relative to `*init-file-path*'.
Return nil if `*init-file-path*' is nil. ;; Return nil if `*init-file-path*' is nil.
Example: ;; Example:
If we want to load a define-command procedure that lives in ~/path/to/nyxt/config/dir/my-slink.lisp ;; 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\"))" ;; (load-after-system :slynk (nyxt-init-file \"my-slink.lisp\"))"
(if subpath ;; (if subpath
(uiop:subpathname* (uiop:pathname-directory-pathname ;; (uiop:subpathname* (uiop:pathname-directory-pathname
(expand-path *init-file-path*)) ;; (expand-path *init-file-path*))
subpath) ;; subpath)
(expand-path *init-file-path*))) ;; (expand-path *init-file-path*)))
+57 -57
View File
@@ -1,16 +1,16 @@
#+TITLE: Nyxt Configuration #+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. 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 * Load Quicklisp & Slynk
#+begin_src lisp #+begin_src lisp
(in-package :nyxt) ;; (in-package :nyxt)
(load "~/quicklisp/setup.lisp") ;; (load "~/quicklisp/setup.lisp")
(ql:quickload 'slynk) ;; (ql:quickload 'slynk)
;; (push #p"~/common-lisp/sly/" asdf:*central-registry*) ;; ;; (push #p"~/common-lisp/sly/" asdf:*central-registry*)
;; (asdf:load-system :slynk) ;; ;; (asdf:load-system :slynk)
;; (slynk:create-server :port 4008) ;; ;; (slynk:create-server :port 4008)
#+end_src #+end_src
* Import Functions * Import Functions
#+begin_src lisp #+begin_src lisp
@@ -156,46 +156,46 @@ Password managers are an essential feature and thankfully Nyxt allows me to inte
** Show bookmarks first ** 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. 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 #+begin_src lisp
(define-command set-url (&key (prefill-current-url-p t)) ;; (define-command set-url (&key (prefill-current-url-p t))
"Set the URL for the current buffer, completing with history." ;; "Set the URL for the current buffer, completing with history."
(let ((history (set-url-history *browser*)) ;; (let ((history (set-url-history *browser*))
(actions (list (make-command buffer-load* (suggestion-values) ;; (actions (list (make-command buffer-load* (suggestion-values)
"Load first selected URL in current buffer and the rest in new buffer(s)." ;; "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)) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(buffer-load (url (first suggestion-values)))) ;; (buffer-load (url (first suggestion-values))))
(make-command new-buffer-load (suggestion-values) ;; (make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)." ;; "Load URL(s) in new buffer(s)."
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values)) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion))) (rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values))))))) ;; (make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer))) ;; (pushnew-url-history history (url (current-buffer)))
(prompt ;; (prompt
:prompt "Open URL" ;; :prompt "Open URL"
:input (if prefill-current-url-p ;; :input (if prefill-current-url-p
(render-url (url (current-buffer))) "") ;; (render-url (url (current-buffer))) "")
:history history ;; :history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions) ;; :sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions) ;; (make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions) ;; (make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-source :actions actions))))) ;; (make-instance 'search-engine-url-source :actions actions)))))
(define-command set-url-new-buffer (&key (prefill-current-url-p t)) ;; (define-command set-url-new-buffer (&key (prefill-current-url-p t))
"Prompt for a URL and set it in a new focused buffer." ;; "Prompt for a URL and set it in a new focused buffer."
(let ((history (set-url-history *browser*)) ;; (let ((history (set-url-history *browser*))
(actions (list (make-command new-buffer-load (suggestion-values) ;; (actions (list (make-command new-buffer-load (suggestion-values)
"Load URL(s) in new buffer(s)" ;; "Load URL(s) in new buffer(s)"
(mapc (lambda (suggestion) (make-buffer :url (url suggestion))) ;; (mapc (lambda (suggestion) (make-buffer :url (url suggestion)))
(rest suggestion-values)) ;; (rest suggestion-values))
(make-buffer-focus :url (url (first suggestion-values))))))) ;; (make-buffer-focus :url (url (first suggestion-values)))))))
(pushnew-url-history history (url (current-buffer))) ;; (pushnew-url-history history (url (current-buffer)))
(prompt ;; (prompt
:prompt "Open URL in new buffer" ;; :prompt "Open URL in new buffer"
:input (if prefill-current-url-p ;; :input (if prefill-current-url-p
(render-url (url (current-buffer))) "") ;; (render-url (url (current-buffer))) "")
:history history ;; :history history
:sources (list (make-instance 'user-new-url-or-search-source :actions actions) ;; :sources (list (make-instance 'user-new-url-or-search-source :actions actions)
(make-instance 'bookmark-source :actions actions) ;; (make-instance 'bookmark-source :actions actions)
(make-instance 'user-global-history-source :actions actions) ;; (make-instance 'user-global-history-source :actions actions)
(make-instance 'search-engine-url-source :actions actions))))) ;; (make-instance 'search-engine-url-source :actions actions)))))
#+end_src #+end_src
* Misc * Misc
@@ -223,16 +223,16 @@ I would like to keep expanding on these redirection functions so I can have nati
#+end_src #+end_src
* Testing * Testing
#+begin_src lisp #+begin_src lisp
(defun nyxt-init-file (&optional subpath) ;; (defun nyxt-init-file (&optional subpath)
"Return SUBPATH relative to `*init-file-path*'. ;; "Return SUBPATH relative to `*init-file-path*'.
Return nil if `*init-file-path*' is nil. ;; Return nil if `*init-file-path*' is nil.
Example: ;; Example:
If we want to load a define-command procedure that lives in ~/path/to/nyxt/config/dir/my-slink.lisp ;; 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\"))" ;; (load-after-system :slynk (nyxt-init-file \"my-slink.lisp\"))"
(if subpath ;; (if subpath
(uiop:subpathname* (uiop:pathname-directory-pathname ;; (uiop:subpathname* (uiop:pathname-directory-pathname
(expand-path *init-file-path*)) ;; (expand-path *init-file-path*))
subpath) ;; subpath)
(expand-path *init-file-path*))) ;; (expand-path *init-file-path*)))
#+end_src #+end_src