Skip to content

Commit

Permalink
Rename REPLACEME to "user".
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrevar committed Aug 31, 2020
1 parent 464a6bc commit 269352b
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 43 deletions.
2 changes: 1 addition & 1 deletion source/browser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ editor executable."))
(:export-accessor-names-p t)
(:accessor-name-transformer #'class*:name-identity))

(define-REPLACEME-class browser)
(define-user-class browser)

(defmethod get-containing-window-for-buffer ((buffer buffer)
(browser browser))
Expand Down
12 changes: 6 additions & 6 deletions source/buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ Must be one of `:always' (accept all cookies), `:never' (reject all cookies),
(:export-accessor-names-p t)
(:accessor-name-transformer #'class*:name-identity))

(define-REPLACEME-class buffer)
(define-user-class buffer)

(defclass internal-buffer (REPLACEME-buffer)
(defclass internal-buffer (user-buffer)
((default-modes :accessor default-modes
:initarg :default-modes
:type list-of-symbols
Expand Down Expand Up @@ -229,9 +229,9 @@ The mode instances are stored in the `modes' slot.")
(|.button:active|
:color "white"))))))

(define-REPLACEME-class internal-buffer)
(define-user-class internal-buffer)

(defclass status-buffer (REPLACEME-internal-buffer)
(defclass status-buffer (user-internal-buffer)
((height :accessor height :initform 16
:type integer
:documentation "The height of the status buffer in pixels.")
Expand Down Expand Up @@ -259,7 +259,7 @@ The mode instances are stored in the `modes' slot.")
(|.button:hover|
:color "white"))))))

(define-REPLACEME-class status-buffer)
(define-user-class status-buffer)

(defmethod internal-buffer-p ((buffer buffer))
nil)
Expand Down Expand Up @@ -425,7 +425,7 @@ If DEAD-BUFFER is a dead buffer, recreate its web view and give it a new ID."
;; Dead buffer ID must be renewed before calling `ffi-buffer-make'.
(setf (id dead-buffer) (get-unique-buffer-identifier *browser*))
(ffi-buffer-make dead-buffer))
(apply #'make-instance (if internal-buffer-p 'REPLACEME-internal-buffer 'REPLACEME-buffer)
(apply #'make-instance (if internal-buffer-p 'user-internal-buffer 'user-buffer)
:id (get-unique-buffer-identifier *browser*)
(append (when title `(:title ,title))
(when default-modes `(:default-modes ,default-modes)))))))
Expand Down
26 changes: 13 additions & 13 deletions source/configuration.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ from a binary) then any condition is logged instead of triggering the debugger."
(log:error "In ~a: ~a" f c)
nil))))

(defun REPLACEME-class-name (class-sym)
(intern (str:concat "REPLACEME-" (string class-sym))
(defun user-class-name (class-sym)
(intern (str:concat "USER-" (string class-sym))
(symbol-package class-sym)))

(defmacro define-REPLACEME-class (name &optional superclasses)
"Define the REPLACEME class of NAME.
(defmacro define-user-class (name &optional superclasses)
"Define the user class of NAME.
This helper function is useful to compose the customizations of a class.
This may be called multiple times.
NAME must be an existing class.
NAME is automatically append to SUPERCLASSES, so that REPLACEME-name inherits
NAME is automatically append to SUPERCLASSES, so that user-name inherits
from NAME last."
(let ((REPLACEME-name (REPLACEME-class-name name))
(let ((user-name (user-class-name name))
(superclasses-with-original (remove-duplicates
(append superclasses (list name)))))
`(progn
(export-always ',REPLACEME-name (symbol-package ',REPLACEME-name))
(export-always ',user-name (symbol-package ',user-name))
;; Probably no need to call the defclass macro if we just need to
;; set the superclasses.
(closer-mop:ensure-class ',REPLACEME-name
(closer-mop:ensure-class ',user-name
:direct-superclasses ',superclasses-with-original))))

(export-always '%slot-default)
Expand All @@ -43,7 +43,7 @@ from NAME last."
"Helper macro to customize NAME class slots.
Classes can be modes or a core class like `browser', `buffer', `minibuffer',
`window'. Note that the classes must _not_ be prefixed by 'REPLACEME-'.
`window'. Note that the classes must _not_ be prefixed by 'user-'.
The `%slot-default' variable is replaced by the slot initform.
Expand All @@ -61,14 +61,14 @@ To discover the default value of a slot or all slots of a class, use the
Example to get the `blocker-mode' command to use a new default hostlists:
\(define-configuration nyxt/blocker-mode:REPLACEME-blocker-mode
\(define-configuration nyxt/blocker-mode:user-blocker-mode
((nyxt/blocker-mode:hostlists (append (list *my-blocked-hosts*) %slot-default))))
The above defines `nyxt/blocker-mode:REPLACEME-blocker-mode' to inherit from a
The above defines `nyxt/blocker-mode:user-blocker-mode' to inherit from a
generated class containing the specialized hostlists and the original
`blocker-mode'."

(let* ((final-name (REPLACEME-class-name name))
(let* ((final-name (user-class-name name))
(temp-name (gentemp (string final-name) (symbol-package name))))
(dolist (name (list name final-name))
(unless (find-class name nil)
Expand All @@ -90,7 +90,7 @@ generated class containing the specialized hostlists and the original
else do
(log:warn "Undefined slot ~a in ~a" (first slot) final-name))
(:accessor-name-transformer #'class*:name-identity))
(define-REPLACEME-class ,name ,(cons temp-name
(define-user-class ,name ,(cons temp-name
(mapcar #'class-name
(mopu:direct-superclasses final-name)))))))

Expand Down
2 changes: 1 addition & 1 deletion source/global.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ close the connection.")
"The entry-point object to a complete instance of Nyxt.
It can be initialized with
(setf *browser* (make-instance 'REPLACEME-browser))
(setf *browser* (make-instance 'user-browser))
It's possible to run multiple interfaces of Nyxt at the same time. You can
let-bind *browser* to temporarily switch interface.")
Expand Down
2 changes: 1 addition & 1 deletion source/help.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ The version number is stored in the clipboard."
;; instantiated after the buffer web view, which is not possible if there is
;; no *browser*.
(let ((keymaps (cons (override-map (or (current-buffer)
(make-instance 'REPLACEME-buffer)))
(make-instance 'user-buffer)))
(delete nil (mapcar #'keymap modes)))))
(or (first (keymap:binding-keys fn keymaps))
"UNBOUND")))
Expand Down
6 changes: 3 additions & 3 deletions source/minibuffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

(in-package :nyxt)

(define-class minibuffer (REPLACEME-buffer)
(define-class minibuffer (user-buffer)
((default-modes '(minibuffer-mode))
(suggestion-function nil
:type (or function null)
Expand Down Expand Up @@ -128,7 +128,7 @@ A minibuffer query is typically done as follows:
;; Write form here in which `tags' is bound to the resulting element(s).
)"))

(define-REPLACEME-class minibuffer)
(define-user-class minibuffer)

(export-always 'make-minibuffer)
(defun make-minibuffer
Expand All @@ -152,7 +152,7 @@ A minibuffer query is typically done as follows:
(cluffer:attach-cursor tmp-input-cursor tmp-input-buffer)
(when explicit-input-buffer
(text-buffer::insert-string tmp-input-cursor input-buffer))
(apply #'make-instance 'REPLACEME-minibuffer
(apply #'make-instance 'user-minibuffer
`(:input-buffer ,tmp-input-buffer
:input-cursor ,tmp-input-cursor
,@(if explicit-default-modes
Expand Down
8 changes: 4 additions & 4 deletions source/mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Example:
(:export-class-name-p t)
(:export-accessor-names-p t)
(:accessor-name-transformer #'class*:name-identity)))
(configurable-class-name (REPLACEME-class-name name)))
(configurable-class-name (user-class-name name)))
(when docstring
(setf class-args (append class-args
`((:documentation ,docstring)))))
`(progn
(define-class ,@class-args)
(define-REPLACEME-class ,name)
(define-user-class ,name)
;; TODO: Can we delete the last mode? What does it mean to have no mode?
;; Should probably always have root-mode.
,(unless (eq name 'root-mode)
Expand Down Expand Up @@ -171,9 +171,9 @@ It may be MODE-SYMBOL itself."
(mapcar #'sym *command-list*)))

(defun original-class (class-sym)
"When CLASS-SYM is a REPLACEME class, return its original class."
"When CLASS-SYM is a user class, return its original class."
;; REVIEW: Is the original class always the last one? What if the user
;; decides to mix in another class, e.g. (defclass REPLACEME-buffer
;; decides to mix in another class, e.g. (defclass user-buffer
;; (user-buffer buffer unrelated-class))?
(first (last (mopu:direct-superclasses class-sym))))

Expand Down
12 changes: 6 additions & 6 deletions source/renderer-gtk.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ See https://github.com/atlas-engineer/nyxt/issues/740")
:orientation :vertical
:spacing 0))
(setf key-string-buffer (make-instance 'gtk:gtk-entry))
(setf active-buffer (make-instance 'REPLACEME-buffer))
(setf active-buffer (make-instance 'user-buffer))

;; Add the views to the box layout and to the window
(gtk:gtk-box-pack-start box-layout (gtk-object active-buffer))
Expand All @@ -162,7 +162,7 @@ See https://github.com/atlas-engineer/nyxt/issues/740")
(setf (gtk:gtk-widget-size-request message-container)
(list -1 (message-buffer-height window)))

(setf status-buffer (make-instance 'REPLACEME-status-buffer))
(setf status-buffer (make-instance 'user-status-buffer))
(gtk:gtk-box-pack-end box-layout status-container :expand nil)
(gtk:gtk-box-pack-start status-container (gtk-object status-buffer) :expand t)
(setf (gtk:gtk-widget-size-request status-container)
Expand Down Expand Up @@ -582,7 +582,7 @@ Warning: This behaviour may change in the future."

(defmethod ffi-window-make ((browser gtk-browser))
"Make a window."
(make-instance 'REPLACEME-window))
(make-instance 'user-window))

(defmethod ffi-window-to-foreground ((window gtk-window))
"Show window in foreground."
Expand Down Expand Up @@ -880,8 +880,8 @@ As a second value, return the current buffer index starting from 0."
(webkit-history-entry-gtk-object history-entry)))

(defun set-renderer ()
(define-REPLACEME-class window (gtk-window))
(define-REPLACEME-class buffer (gtk-buffer))
(define-REPLACEME-class browser (gtk-browser)))
(define-user-class window (gtk-window))
(define-user-class buffer (gtk-buffer))
(define-user-class browser (gtk-browser)))

(set-renderer)
6 changes: 3 additions & 3 deletions source/renderer-qt.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(setf id (get-unique-window-identifier *browser*))
(setf qt-object (qt:new-q-widget))
(setf box-layout (qt:new-qv-box-layout))
(setf active-buffer (make-instance 'REPLACEME-buffer))
(setf active-buffer (make-instance 'user-buffer))
(setf minibuffer-view (qt:new-q-web-engine-view))
;; Add views to window, configure window widget
(qt:widget-set-layout qt-object box-layout)
Expand Down Expand Up @@ -115,7 +115,7 @@

(defmethod ffi-window-make ((browser qt-browser))
"Make a window."
(make-instance 'REPLACEME-window))
(make-instance 'user-window))

(defmethod ffi-window-to-foreground ((window qt-window))
"Show window in foreground."
Expand Down Expand Up @@ -143,7 +143,7 @@
(qt:widget-set-fixed-height (minibuffer-view window) height))

(defmethod ffi-buffer-make ((browser qt-browser))
(make-instance 'REPLACEME-buffer))
(make-instance 'user-buffer))

(defmethod ffi-buffer-delete ((buffer qt-buffer)))

Expand Down
2 changes: 1 addition & 1 deletion source/start.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ Finally,run the `*after-init-hook*'."
(notify (str:concat message "."))
(error-in-new-window "*Init file errors*" full-message))))))
(load-or-eval :remote nil)
(setf *browser* (make-instance 'REPLACEME-browser
(setf *browser* (make-instance 'user-browser
:startup-error-reporter-function startup-error-reporter
:startup-timestamp startup-timestamp))
(log:info "Using data profile ~s." (name (data-profile *browser*)))
Expand Down
10 changes: 7 additions & 3 deletions source/status.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
(let ((buffer (current-buffer window)))
(markup:markup
(:span (format nil "[~{~a~^ ~}]"
(mapcar (lambda (m) (str:replace-all "-mode" ""
(str:downcase
(class-name (class-of m)))))
(mapcar (lambda (m)
(str:replace-all
"user-" ""
(str:replace-all
"-mode" ""
(str:downcase
(class-name (class-of m))))))
(modes buffer))))
(:a :class "button" :title "Backwards" :href (lisp-url '(nyxt/web-mode:history-backwards)) "")
(:a :class "button" :title "Forwards" :href (lisp-url '(nyxt/web-mode:history-forwards)) "")
Expand Down
2 changes: 1 addition & 1 deletion source/window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The handlers take the window as argument."))
(:export-accessor-names-p t)
(:accessor-name-transformer #'class*:name-identity))

(define-REPLACEME-class window)
(define-user-class window)

(defmethod (setf active-buffer) (buffer (window window))
(setf (slot-value window 'active-buffer) buffer)
Expand Down

0 comments on commit 269352b

Please sign in to comment.