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,77 +98,59 @@ 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*)
(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=")
("aw" . "https://wiki.archlinux.org/index.php?search=~a")
("ctan" . "http://www.ctan.org/search?phrase=~a")
("dd" . "http://devdocs.io/#q=~a")
("dg" . "https://duckduckgo.com/?q=~a")
("eb" . "https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject%3A~a;repeatmerged=on;archive=both")
("ed" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emacs-devel&submit=Search&query=~a")
("ee" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emms-help&submit=Search!&query=~a")
("ge" . "https://wiki.gentoo.org/index.php?title=Special%3ASearch&search=~a&go=Go")
("gh" . "https://github.com/search?ref=simplesearch&q=~a")
("gr" . "https://www.goodreads.com/search?q=~a")
("gm" . "https://maps.google.com/maps?q=~a")
("gud" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=guix-devel&submit=Search&query=~a")
("guh" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=help-guix&submit=Search!&query=~a")
("gup" . "https://guix-hpc.bordeaux.inria.fr/package/~a")
("i" . "http://www.imdb.com/find?q=~a&s=all")
("mba" . "http://musicbrainz.org/search?query=~a&type=artist&method=indexed")
("mbr" . "http://musicbrainz.org/search?query=~a&type=release&method=indexed")
("osm" . "https://www.openstreetmap.org/search?query=~a")
("q" . "http://quickdocs.org/search?q=~a")
("s" . "http://stackoverflow.com/search?q=~a")
("wp" . "http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=~a")
("wb" . "http://en.wikibooks.org/wiki/Special:Search?search=~a")
("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))
((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=")
("aw" . "https://wiki.archlinux.org/index.php?search=~a")
("ctan" . "http://www.ctan.org/search?phrase=~a")
("dd" . "http://devdocs.io/#q=~a")
("dg" . "https://duckduckgo.com/?q=~a")
("eb" . "https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject%3A~a;repeatmerged=on;archive=both")
("ed" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emacs-devel&submit=Search&query=~a")
("ee" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emms-help&submit=Search!&query=~a")
("ge" . "https://wiki.gentoo.org/index.php?title=Special%3ASearch&search=~a&go=Go")
("gh" . "https://github.com/search?ref=simplesearch&q=~a")
("gr" . "https://www.goodreads.com/search?q=~a")
("gm" . "https://maps.google.com/maps?q=~a")
("gud" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=guix-devel&submit=Search&query=~a")
("guh" . "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=help-guix&submit=Search!&query=~a")
("gup" . "https://guix-hpc.bordeaux.inria.fr/package/~a")
("i" . "http://www.imdb.com/find?q=~a&s=all")
("mba" . "http://musicbrainz.org/search?query=~a&type=artist&method=indexed")
("mbr" . "http://musicbrainz.org/search?query=~a&type=release&method=indexed")
("osm" . "https://www.openstreetmap.org/search?query=~a")
("q" . "http://quickdocs.org/search?q=~a")
("s" . "http://stackoverflow.com/search?q=~a")
("wp" . "http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=~a")
("wb" . "http://en.wikibooks.org/wiki/Special:Search?search=~a")
("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"))
(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