Skip to content
Branch: master
Find file Copy path
Find file Copy path
3 contributors

Users who have contributed to this file

@jmercouris @Ambrevar @cjohansson
130 lines (105 sloc) 4.08 KB

Next Extension Exposé

This Document is a place for users of Next to share useful customizations as a community. If you have something you wish to add, please feel free to open a PR with your customization.


Setting the start page

Setting the start page can easily be achieved in the following manner:

(setf (get-default 'remote-interface 'start-page-url) "about:blank")

Creating your own Parenscript

You can call any parenscript within the browser through the convient define-parenscript macro. A really simple example below shows how you could set the body with the URL of the current page.

(define-parenscript hello-url ()
  (defun set-body (text)
    (setf (ps:chain document body inner-text) text)
    ;; return nil to avoid json decode errors
  (set-body (ps:chain document -u-r-l)))

A define-parenscript without arguments will automatically generate a defparameter named hello-url with the actual Javascript, and a function (hello-url) that you can invoke to act upon the currently active buffer.

Running shell commands within Next

Shell mode is an extension for running simple one liner shell commands and seeing the output. There is no history or variables. Use C-x s to enter a *shell* buffer, c to enter a command and k to clear the command output.

(define-mode shell-mode ()
    "A basic shell prompt."
      (let ((map (make-keymap)))
        (define-key (key "M-f") 'history-forwards-query
          (key "c") #'run-shell-command
          (key "k") #'run-shell-command
          :keymap map)

(define-parenscript clear-shell-output ()
    (setf (ps:chain document body inner-h-t-m-l) ""))

(define-command clear-shell (shell-mode)
   *interface* (active-buffer *interface*)

(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 "<pre><code>~a</code></pre><br/>" output))))))

(define-command run-shell-command (shell-mode)
      (input (read-from-minibuffer
              (minibuffer *interface*)
              :input-prompt "Run in shell:"))
     *interface* (active-buffer *interface*)
      (uiop:run-program input :force-shell t :output :string)))))

(define-command shell ()
  (set-active-buffer *interface* (make-buffer "*shell*" 'shell-mode)))

(define-key (key "C-x s") #'shell)

Reloading the page

The following function provides a way to reload the current page.

;; Reload page with C-r
(define-parenscript %reload-page ()
  (ps:chain location (reload)))

(define-command reload-page ()
  "Reload page."

(define-key (key "C-r") #'reload-page)

Scroll the page up and down by a screen

You can use the following functions to scroll the page up or down by one screen.

(define-parenscript %scroll-page-down ()
  (ps:chain window (scroll-by 0 (ps:@ window inner-height))))

(define-parenscript %scroll-page-up ()
  (ps:chain window (scroll-by 0 (- (ps:@ window inner-height)))))

(define-command scroll-page-down ()
  "Scroll down by one page height."

(define-command scroll-page-up ()
  "Scroll up by one page height."

;; bind the new functions
(define-key (key "C-v") #'scroll-page-down)
(define-key (key "M-v") #'scroll-page-up)
You can’t perform that action at this time.