Next: Use CLOS-style config.

master
Pierre Neidhardt 2019-11-17 14:01:06 +01:00
parent c077c74184
commit 62f5f7c69a
1 changed files with 47 additions and 64 deletions

View File

@ -82,6 +82,7 @@ Videos are downloaded with `+youtube-dl-command+'."
(defun auto-proxy-handler (url)
(let* ((uri (quri:uri url))
(domain (and uri (quri:uri-domain uri))))
;; TODO: Turn on/off proxy, not mode.
(when domain
(next/proxy-mode:proxy-mode
:activate
@ -97,36 +98,27 @@ Videos are downloaded with `+youtube-dl-command+'."
"m.media-amazon.com")))
(defun no-cookies-handler (buffer)
;; TODO: Disable cookies for known hosts.
(setf (cookies-path buffer) #P""))
(defun my-buffer-defaults (buffer)
(define-mode my-blocker-mode (next/blocker-mode:blocker-mode)
"Blocker mode with custom hosts from `*my-blocked-hosts*'."
((next/blocker-mode::hostlists :initform (list *my-blocked-hosts* next/blocker-mode:*default-host-list*))))
(setf (zoom-ratio-default buffer) 1.0)
(unzoom-page :buffer buffer) ; Needed for non-web-mode buffers.
(defclass my-buffer (buffer)
((default-modes :initform (append
'(my-mode vi-normal-mode
my-blocker-mode
proxy-mode)
(get-default 'buffer 'default-modes)))
(load-hook :initform (list #'old-reddit-handler
#'auto-proxy-handler))))
(dolist (mode '(vi-normal-mode proxy-mode my-mode))
(pushnew mode (default-modes buffer)))
;; TODO: Pros and cons of the following approach to mode init?
;; The problem with DEFAULT-MODES is that it does not allow for configuring
;; the modes.
(next/blocker-mode:blocker-mode
:hostlists (list *my-blocked-hosts* next/blocker-mode:*default-host-list*)
:buffer buffer)
(dolist (handler (list #'old-reddit-handler #'auto-proxy-handler))
(hooks:add-to-hook (hooks:object-hook buffer 'load-hook)
handler)))
(setf *buffer-class* 'my-buffer)
(defun my-window-defaults (window)
(setf (minibuffer-open-height window) 200))
(defun my-minibuffer-defaults (minibuffer)
(setf
(minibuffer-line-height minibuffer) "1.0em"
(minibuffer-font-size minibuffer) "1.0em"))
(defun my-interface-defaults ()
(defclass my-remote-interface (remote-interface)
;; TODO: Fetch from Emacs' engine.el automatically?
(setf (search-engines *interface*)
((search-engines :initform
(append
'(("aa" . "https://aur.archlinux.org/packages.php?O=0&K=~a&do_Search=Go")
("ap" . "https://www.archlinux.org/packages/?sort=&q=~a&maintainer=&flagged=")
@ -155,19 +147,10 @@ Videos are downloaded with `+youtube-dl-command+'."
("wk" . "http://en.wiktionary.org/wiki/Special:Search?search=~a")
("wa" . "http://www.winehq.org/search/?q=~a")
("yt" . "https://www.youtube.com/results?search_query=~a"))
(search-engines *interface*)))
(setf (download-directory *interface*) "~/temp")
;; (setf (history-path *interface*) "/home/ambrevar/temp/next/history.lisp")
;; (hooks:add-to-hook (hooks:object-hook *interface* 'buffer-before-make-hook)
;; #'no-cookies-handler)
(hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
#'my-buffer-defaults)
(hooks:add-to-hook (hooks:object-hook *interface* 'minibuffer-make-hook)
#'my-minibuffer-defaults)
(hooks:add-to-hook (hooks:object-hook *interface* 'window-make-hook)
#'my-window-defaults))
(get-default 'remote-interface 'search-engines)))
(download-directory :initform "~/temp")))
(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)
(setf *remote-interface-class* 'my-remote-interface)
(defmethod deserialize-bookmarks (stream)
"This version of deserialize-bookmarks is compatibly with Ambrevar's EWW