aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2022-01-31 00:51:03 -0800
committerGravatar Tom Willemse2022-01-31 00:51:03 -0800
commitadda08ef4a09ae0370b031eba489199a8ec09eb4 (patch)
tree2b24cf14b6c8749d60875f49de96b97d3c47c09b
parent9b7417f6c69360273e82b41130992c44fe373101 (diff)
downloadnew-dotfiles-adda08ef4a09ae0370b031eba489199a8ec09eb4.tar.gz
new-dotfiles-adda08ef4a09ae0370b031eba489199a8ec09eb4.zip
Add nyxt configuration
-rw-r--r--GNUmakefile6
-rw-r--r--nyxt/.config/nyxt/init.lisp.org66
2 files changed, 71 insertions, 1 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 5d25714..ace2246 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-MODULES=xmodmap emacs xdg shepherd dunst zsh mcron mbsync
+MODULES=xmodmap emacs xdg shepherd dunst zsh mcron mbsync nyxt
STOW = stow
EMACS = emacs
@@ -120,6 +120,10 @@ mbsync: mbsync/.config/cron/mbsync.guile
zsh: zsh/.profile zsh/.zshrc zsh/.zsh/functions/unzip.zwc \
zsh/.zsh/functions/x-yank.zwc zsh/.zsh/functions/x-copy-region-as-kill.zwc
+## Nyxt
+
+nyxt: nyxt/.config/nyxt/init.lisp
+
## Helper
%.el: %.org
diff --git a/nyxt/.config/nyxt/init.lisp.org b/nyxt/.config/nyxt/init.lisp.org
new file mode 100644
index 0000000..33dcf84
--- /dev/null
+++ b/nyxt/.config/nyxt/init.lisp.org
@@ -0,0 +1,66 @@
+Always restore the previous session when the browser starts.
+
+#+begin_src lisp
+ (define-configuration browser
+ ((session-restore-prompt :always-restore)))
+#+end_src
+
+I want the keys to function more like Emacs, so I enable =emacs-mode= for all buffers. I also want my downloads to go to =~/downloads= instead of =~/Downloads=.
+
+#+begin_src lisp
+ (define-configuration buffer
+ ((default-modes (append '(emacs-mode) %slot-default%))
+ (download-path (make-instance 'data-path :dirname "~/downloads"))
+ ;; Bind org-capture to `C-c o c', but only in emacs-mode.
+ (override-map
+ (let ((map (make-keymap "override-map")))
+ (define-key map "C-c o c" 'org-capture)))))
+#+end_src
+
+Set up capturing URLs with org-capture in Emacs. From https://ag91.github.io/blog/2021/07/09/org-capture-in-nyxt-taking-notes-while-browsing/.
+
+#+begin_src lisp
+(defun replace-all (string part replacement &key (test #'char=))
+ "Return a new string in which all the occurences of the part is replaced with replacement."
+ (with-output-to-string (out)
+ (loop with part-length = (length part)
+ for old-pos = 0 then (+ pos part-length)
+ for pos = (search part string
+ :start2 old-pos
+ :test test)
+ do (write-string string out
+ :start old-pos
+ :end (or pos (length string)))
+ when pos do (write-string replacement out)
+ while pos)))
+
+(defun eval-in-emacs (&rest s-exps)
+ "Evaluate S-EXPS with emacsclient."
+ (let ((s-exps-string (replace-all
+ (write-to-string
+ `(progn ,@s-exps) :case :downcase)
+ ;; Discard the package prefix.
+ "nyxt::" "")))
+ (format *error-output* "Sending to Emacs:~%~a~%" s-exps-string)
+ (uiop:run-program
+ (list "emacsclient" "--eval" s-exps-string))))
+
+(define-command-global org-capture ()
+ "Org-capture current page."
+ (eval-in-emacs
+ `(org-link-set-parameters
+ "nyxt"
+ :store (lambda ()
+ (org-store-link-props
+ :type "nyxt"
+ :link ,(quri:render-uri (url (current-buffer)))
+ :description ,(title (current-buffer)))))
+ `(org-capture nil "U"))
+ (echo "Note stored!"))
+#+end_src
+
+Start Swank so I can connect to it through Emacs.
+
+#+begin_src lisp
+ (start-swank)
+#+end_src