(in-package :next) ;; Use development platform port. (setf (get-default 'port 'path) "~/common-lisp/next/ports/gtk-webkit/next-gtk-webkit") (setf (get-default 'remote-interface 'download-directory) "~/temp") (add-to-default-list 'vi-normal-mode 'buffer 'default-modes) ;; ;; (setf (cdr (last (eval (get-default 'window 'search-engines)))) ;; ;; '(("yt" . "https://www.youtube.com/results?search_query=~a"))) (nconc (get-default 'window 'search-engines) '(("q" . "http://quickdocs.org/search?q=~a") ("yt" . "https://www.youtube.com/results?search_query=~a"))) (add-to-default-list (make-instance 'hostlist :hosts '("platform.twitter.com" "syndication.twitter.com" "m.media-amazon.com")) 'blocker-mode 'hostlists) (defun eval-in-emacs (&rest s-exps) "Evaluate S-exps with `emacsclient'." (let ((s-exps-string (cl-strings:replace-all (write-to-string `(progn ,@s-exps) :case :downcase) ;; Discard the package prefix. "next::" ""))) (log:debug "Sending to Emacs: ~a" s-exps-string) (ignore-errors (uiop:run-program (list "emacsclient" "--eval" s-exps-string))))) (define-command org-capture () "Org-capture current page." (with-result* ((url (buffer-get-url)) (title (buffer-get-title))) (eval-in-emacs `(org-link-set-parameters "next" :store (lambda () (org-store-link-props :type "next" :link ,url :description ,title))) `(org-capture)))) (define-key "C-M-o" #'org-capture) (define-key :scheme :vi-normal "C-M-o" #'org-capture) (define-command youtube-dl-current-page () "Download a video in the currently open buffer." (with-result (url (buffer-get-url)) (eval-in-emacs (if (search "youtu" url) `(progn (youtube-dl ,url) (youtube-dl-list)) `(ambrevar/youtube-dl-url ,url))))) (define-key "C-M-c d" 'youtube-dl-current-page) (define-command play-video-in-current-page () "Play video in the currently open buffer." (with-result (url (buffer-get-url)) (uiop:run-program (list "mpv" url)))) (define-key "C-M-c v" 'play-video-in-current-page) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-mode shell-mode () "A basic shell prompt." ((keymap-schemes :initform (let ((map (make-keymap))) (define-key :keymap map "c" 'run-shell-command "k" 'clear-shell) (list :emacs map :vi-normal map))))) (define-parenscript clear-shell-output () (setf (ps:chain document body inner-h-t-m-l) "")) (define-command clear-shell (shell-mode) "Clear the output in the shell buffer." (rpc-buffer-evaluate-javascript *interface* (active-buffer *interface*) (clear-shell-output))) (define-parenscript append-output (output) (setf (ps:chain document body inner-h-t-m-l) (ps:chain document body inner-h-t-m-l (concat (ps:lisp (format nil "
~a

" output)))))) (define-command run-shell-command (shell-mode) "Run a shell command." (with-result (input (read-from-minibuffer (minibuffer *interface*) :input-prompt "Run in shell:")) (rpc-buffer-evaluate-javascript *interface* (active-buffer *interface*) (append-output :output (uiop:run-program input :force-shell t :output :string))))) (define-command shell () "Open a shell buffer." (set-active-buffer *interface* (make-buffer :name "*shell*" :default-modes (cons 'shell-mode (get-default 'buffer 'default-modes))))) (define-key "C-x s" #'shell)