Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOS-style configuration #484

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/base.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ useful when Next starts up)."
If INTERACTIVE is t, allow the debugger on errors. If :running, show an error but don't quit the lisp process.
"
(with-result (file-name-input (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Load file:")))
(make-minibuffer
:input-prompt "Load file:")))
(load-lisp-file file-name-input :interactive :running)))

(define-command load-init-file (&key (init-file (init-file-path))
Expand Down Expand Up @@ -234,10 +234,10 @@ Finally, run the `*after-init-hook*'."
(when *interface*
(kill-interface *interface*)
;; It's important to set it to nil or else if we re-run this function,
;; (make-instance 'remote-interface) will be run while an existing
;; (make-instance *remote-interface-class*) will be run while an existing
;; *interface* is still floating around.
(setf *interface* nil))
(setf *interface* (make-instance 'remote-interface
(setf *interface* (make-instance *remote-interface-class*
:non-interactive non-interactive
:startup-timestamp startup-timestamp))
;; Start the port after the interface so that we don't overwrite the log when
Expand Down
42 changes: 21 additions & 21 deletions source/bookmark.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ This can be useful to let the user select no tag when returning directly."
"Bookmark the URL of BUFFER."
(if (url buffer)
(with-result (tags (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Space-separated tag(s):"
:multi-selection-p t
:completion-function (tag-completion-filter :with-empty-tag t)
:empty-complete-immediate t)))
(make-minibuffer
:input-prompt "Space-separated tag(s):"
:multi-selection-p t
:completion-function (tag-completion-filter :with-empty-tag t)
:empty-complete-immediate t)))
(when tags
;; Turn tags with spaces into multiple tags.
(setf tags (alexandria:flatten
Expand All @@ -155,36 +155,36 @@ This can be useful to let the user select no tag when returning directly."
(define-command bookmark-page ()
"Bookmark the currently opened page(s) in the active buffer."
(with-result (buffers (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Bookmark URL from buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(make-minibuffer
:input-prompt "Bookmark URL from buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(mapcar #'bookmark-current-page buffers)))

(define-command bookmark-url ()
"Allow the user to bookmark a URL via minibuffer input."
(with-result (url (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Bookmark URL:")))
(make-minibuffer
:input-prompt "Bookmark URL:")))
(bookmark-add url)))

(define-command bookmark-delete ()
"Delete bookmark(s)."
(with-result (entries (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Delete bookmark(s):"
:multi-selection-p t
:completion-function (bookmark-completion-filter))))
(make-minibuffer
:input-prompt "Delete bookmark(s):"
:multi-selection-p t
:completion-function (bookmark-completion-filter))))
(setf (bookmarks-data *interface*)
(set-difference (bookmarks-data *interface*) entries :test #'equals))))

(define-command bookmark-hint ()
"Show link hints on screen, and allow the user to bookmark one"
(with-result* ((links-json (add-link-hints))
(selected-hint (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Bookmark hint:"
:cleanup-function #'remove-link-hints))))
(make-minibuffer
:input-prompt "Bookmark hint:"
:cleanup-function #'remove-link-hints))))
(let* ((link-hints (cl-json:decode-json-from-string links-json))
(selected-link (cadr (assoc selected-hint link-hints :test #'equalp))))
(when selected-link
Expand All @@ -197,9 +197,9 @@ This can be useful to let the user select no tag when returning directly."
(define-command set-url-from-bookmark ()
"Set the URL for the current buffer from a bookmark."
(with-result (entry (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Open bookmark:"
:completion-function (bookmark-completion-filter))))
(make-minibuffer
:input-prompt "Open bookmark:"
:completion-function (bookmark-completion-filter))))
;; TODO: Add support for multiple bookmarks?
(set-url (url entry) :buffer (current-buffer) :raw-url-p t)))

Expand Down
66 changes: 33 additions & 33 deletions source/buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ MODES is a list of mode symbols."
(define-command switch-buffer ()
"Switch the active buffer in the current window."
(with-result (buffer (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Switch to buffer:"
;; For commodity, the current buffer shouldn't be the first one on the list.
:completion-function (buffer-completion-filter :current-is-last-p t))))
(make-minibuffer
:input-prompt "Switch to buffer:"
;; For commodity, the current buffer shouldn't be the first one on the list.
:completion-function (buffer-completion-filter :current-is-last-p t))))
(set-current-buffer buffer)))

(define-command make-buffer-focus ()
Expand All @@ -67,10 +67,10 @@ MODES is a list of mode symbols."
(define-command delete-buffer ()
"Delete the buffer(s) via minibuffer input."
(with-result (buffers (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Delete buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(make-minibuffer
:input-prompt "Delete buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(mapcar #'rpc-buffer-delete buffers)))

(define-command delete-current-buffer (&optional (buffer (current-buffer)))
Expand Down Expand Up @@ -113,11 +113,11 @@ URL is first transformed by `parse-url', then by BUFFER's `load-hook'."
(when history
(ring:insert history (url (current-buffer))))
(with-result (url (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Open URL in buffer:"
:completion-function (history-completion-filter)
:history history
:empty-complete-immediate t)))
(make-minibuffer
:input-prompt "Open URL in buffer:"
:completion-function (history-completion-filter)
:history history
:empty-complete-immediate t)))
(when (typep url 'history-entry)
;; In case read-from-minibuffer returned a string upon
;; empty-complete-immediate.
Expand All @@ -135,10 +135,10 @@ URL is first transformed by `parse-url', then by BUFFER's `load-hook'."
(define-command reload-buffer ()
"Reload queried buffer(s)."
(with-result (buffers (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Reload buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(make-minibuffer
:input-prompt "Reload buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(mapcar #'reload-current-buffer buffers)))

(defmethod get-active-buffer-index ((active-buffer buffer) buffers)
Expand Down Expand Up @@ -190,10 +190,10 @@ item in the list, jump to the first item."
(define-command disable-mode-for-current-buffer (&key (buffers (list (current-buffer))))
"Disable queried mode(s)."
(with-result (modes (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Disable mode(s):"
:multi-selection-p t
:completion-function (active-mode-completion-filter buffers))))
(make-minibuffer
:input-prompt "Disable mode(s):"
:multi-selection-p t
:completion-function (active-mode-completion-filter buffers))))
(dolist (buffer buffers)
(dolist (mode modes)
(funcall (sym (mode-command mode))
Expand All @@ -202,19 +202,19 @@ item in the list, jump to the first item."
(define-command disable-mode-for-buffer ()
"Disable queried mode(s) for select buffer(s)."
(with-result (buffers (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Disable mode(s) for buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(make-minibuffer
:input-prompt "Disable mode(s) for buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(disable-mode-for-current-buffer :buffers buffers)))

(define-command enable-mode-for-current-buffer (&key (buffers (list (current-buffer))))
"Enable queried mode(s)."
(with-result (modes (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Enable mode(s):"
:multi-selection-p t
:completion-function (inactive-mode-completion-filter buffers))))
(make-minibuffer
:input-prompt "Enable mode(s):"
:multi-selection-p t
:completion-function (inactive-mode-completion-filter buffers))))
(dolist (buffer buffers)
(dolist (mode modes)
(funcall (sym (mode-command mode))
Expand All @@ -223,8 +223,8 @@ item in the list, jump to the first item."
(define-command enable-mode-for-buffer ()
"Enable queried mode(s) for select buffer(s)."
(with-result (buffers (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Enable mode(s) for buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(make-minibuffer
:input-prompt "Enable mode(s) for buffer(s):"
:multi-selection-p t
:completion-function (buffer-completion-filter))))
(enable-mode-for-current-buffer :buffers buffers)))
6 changes: 3 additions & 3 deletions source/command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ This function can be `funcall'ed."
(define-command execute-command ()
"Execute a command by name."
(with-result (command (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Execute command:"
:completion-function 'command-completion-filter)))
(make-minibuffer
:input-prompt "Execute command:"
:completion-function 'command-completion-filter)))
(setf (access-time command) (get-internal-real-time))
(run command)))
6 changes: 3 additions & 3 deletions source/download-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
Ask the user to choose one of the downloaded files of the current session.
See also `open-file'."
(with-result (filename (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Open file:"
:completion-function (downloaded-files-completion-filter))))
(make-minibuffer
:input-prompt "Open file:"
:completion-function (downloaded-files-completion-filter))))
(next/file-manager-mode:open-file-function filename)))
8 changes: 4 additions & 4 deletions source/file-manager-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ Note: this feature is alpha, get in touch for more!"
(let ((directory next/file-manager-mode::*current-directory*))
;; Allow the current minibuffer to recognize our keybindings.
(with-result (filename (read-from-minibuffer
(make-instance 'minibuffer
:default-modes '(next/file-manager-mode::file-manager-mode minibuffer-mode)
:input-prompt (file-namestring directory)
:completion-function #'next/file-manager-mode::open-file-from-directory-completion-filter)))
(make-minibuffer
:default-modes '(next/file-manager-mode::file-manager-mode minibuffer-mode)
:input-prompt (file-namestring directory)
:completion-function #'next/file-manager-mode::open-file-from-directory-completion-filter)))

(funcall next/file-manager-mode::*open-file-function* (namestring filename)))))
2 changes: 1 addition & 1 deletion source/global.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"The entry-point object to a complete instance of Next.
It can be initialized with

(setf *interface* (make-instance 'remote-interface))
(setf *interface* (make-instance *remote-interface-class*))

It's possible to run multiple interfaces of Next at the same time. You can
let-bind *interface* to temporarily switch interface.")
Expand Down
18 changes: 9 additions & 9 deletions source/help.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
(define-command variable-inspect ()
"Inspect a variable and show it in a help buffer."
(with-result (input (read-from-minibuffer
(make-instance 'minibuffer
:completion-function #'variable-completion-filter
:input-prompt "Inspect variable:")))
(make-minibuffer
:completion-function #'variable-completion-filter
:input-prompt "Inspect variable:")))
(let* ((help-buffer (make-buffer
:title (str:concat "*Help-" (symbol-name input) "*")
:modes (cons 'help-mode
Expand All @@ -48,15 +48,15 @@
(insert-help (ps:ps (setf (ps:@ document Body |innerHTML|)
(ps:lisp help-contents)))))
(rpc-buffer-evaluate-javascript help-buffer insert-help)
(set-current-buffer help-buffer))))
(set-current-buffer help-buffer))))

;; TODO: Have both "function-inspect" and "command-inspect"?
(define-command command-inspect ()
"Inspect a function and show it in a help buffer."
(with-result (input (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Inspect command:"
:completion-function #'function-completion-filter)))
(make-minibuffer
:input-prompt "Inspect command:"
:completion-function #'function-completion-filter)))
(let* ((help-buffer (make-buffer
:title (str:concat "*Help-" (symbol-name (sym input)) "*")
:modes (cons 'help-mode
Expand Down Expand Up @@ -85,8 +85,8 @@ This does not use an implicit PROGN to allow evaluating top-level expressions."
(define-command command-evaluate ()
"Evaluate a form."
(with-result (input (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Evaluate Lisp:")))
(make-minibuffer
:input-prompt "Evaluate Lisp:")))
(let* ((result-buffer (make-buffer
:title "*List Evaluation*" ; TODO: Reuse buffer / create REPL mode.
:modes (cons 'help-mode
Expand Down
10 changes: 5 additions & 5 deletions source/history.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ The history is sorted by last access."
(define-command delete-history-entry ()
"Delete queried history entries."
(with-result (entries (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Delete entries:"
:completion-function (history-completion-filter)
:history (minibuffer-set-url-history *interface*)
:multi-selection-p t)))
(make-minibuffer
:input-prompt "Delete entries:"
:completion-function (history-completion-filter)
:history (minibuffer-set-url-history *interface*)
:multi-selection-p t)))
(dolist (entry entries)
(remhash (url entry) (history-data *interface*)))
;; Use accessor to ensure store function is called.
Expand Down
12 changes: 6 additions & 6 deletions source/jump-heading.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ For example, Wikipedia ones end with '[edit]'. We strip what comes after the fir
"Jump to a particular heading, of type h1, h2, h3, h4, h5, or h6."
(with-result* ((headings (get-headings))
(heading (read-from-minibuffer
(make-instance 'minibuffer
:input-prompt "Jump to heading:"
:completion-function (lambda (input)
(fuzzy-match
input
(make-headings (cl-json:decode-json-from-string headings))))))))
(make-minibuffer
:input-prompt "Jump to heading:"
:completion-function (lambda (input)
(fuzzy-match
input
(make-headings (cl-json:decode-json-from-string headings))))))))
(paren-jump-to-heading :heading-inner-text (inner-text heading))))
Loading