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

Adding variable to define Custom browser to use #18

Merged
merged 7 commits into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Run `M-x customize-group RET grip RET` or set the variables.
;; Path to the grip binary
(setq grip-binary-path "/path/to/grip")

;; You can use this variable to define another browser
;; to use when loading previews. By default this value is `nil`
;; meaning use default browser defined by your system
(setq grip-url-browser "custom_browser")

;; A GitHub username for API authentication
(setq grip-github-user "")

Expand Down
19 changes: 17 additions & 2 deletions grip-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
:type 'file
:group 'grip)

(defcustom grip-url-browser nil
"Browser to launch Markdown/Org previews.
Use default browser if nil."
:type 'string
seagle0128 marked this conversation as resolved.
Show resolved Hide resolved
:group 'grip)

seagle0128 marked this conversation as resolved.
Show resolved Hide resolved
(defcustom grip-github-user ""
"A GitHub username for API authentication."
:type 'string
Expand All @@ -81,7 +87,6 @@ option."
:type 'boolean
:group 'grip)



;; Externals
(declare-function xwidget-buffer 'xwidget)
Expand All @@ -98,6 +103,16 @@ option."
(defvar-local grip--preview-file nil
"The preview file for grip process.")

(defun grip--browser (url)
"Use browser specified by user to load URL.
Use default browser if nil."
(if grip-url-browser
(progn
(setq-local browse-url-generic-program grip-url-browser
seagle0128 marked this conversation as resolved.
Show resolved Hide resolved
browse-url-browser-function 'browse-url-generic)
(browse-url url))
(browse-url url)))

(defun grip--browse-url (url)
"Ask the browser to load URL.

Expand All @@ -110,7 +125,7 @@ Use default browser unless `xwidget' is available."
(when (buffer-live-p buf)
(and (eq buf (current-buffer)) (quit-window))
(pop-to-buffer buf))))
(browse-url url)))
(grip--browser url)))

(defun grip--preview-url ()
"Return grip preview url."
Expand Down