Skip to content

Commit 02b7a81

Browse files
authored
Adding variable to define Custom browser to use (#18)
Added custom variable `grip-url-browser` to specify another browser to be used instead of default one, and `grip-url-args` to pass to `grip-url-browser`. Added function grip--browser which will load preview either by using grip-url-browser or default browser
1 parent 31e72e7 commit 02b7a81

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ Run `M-x customize-group RET grip RET` or set the variables.
7676
;; Path to the grip binary
7777
(setq grip-binary-path "/path/to/grip")
7878
79+
;; You can use this variable to define another browser
80+
;; to use when loading previews. By default this value is `nil`
81+
;; meaning use default browser defined by your system
82+
(setq grip-url-browser "custom_browser")
83+
84+
;; If you want to pass arguements to your custom browser then use
85+
(setq grip-url-args '("arg1" "arg2" "etc"))
86+
7987
;; A GitHub username for API authentication
8088
(setq grip-github-user "")
8189

grip-mode.el

+22-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
:type 'file
5757
:group 'grip)
5858

59+
(defcustom grip-url-browser nil
60+
"Browser to launch Markdown/Org previews.
61+
Use default browser if nil."
62+
:type '(choice (const :tag "None" nil) string)
63+
:group 'grip)
64+
65+
(defcustom grip-url-args nil
66+
"A list of strings defining options for `grip-url-browser'."
67+
:type '(repeat (string :tag "Argument")))
68+
5969
(defcustom grip-github-user ""
6070
"A GitHub username for API authentication."
6171
:type 'string
@@ -81,7 +91,6 @@ option."
8191
:type 'boolean
8292
:group 'grip)
8393

84-
8594

8695
;; Externals
8796
(declare-function xwidget-buffer 'xwidget)
@@ -98,6 +107,17 @@ option."
98107
(defvar-local grip--preview-file nil
99108
"The preview file for grip process.")
100109

110+
(defun grip--browser (url)
111+
"Use browser specified by user to load URL.
112+
Use default browser if nil."
113+
(if grip-url-browser
114+
(let ((browse-url-generic-program grip-url-browser)
115+
(browse-url-generic-args grip-url-args))
116+
(ignore browse-url-generic-program)
117+
(ignore browse-url-generic-args)
118+
(browse-url-generic url))
119+
(browse-url url)))
120+
101121
(defun grip--browse-url (url)
102122
"Ask the browser to load URL.
103123
@@ -110,7 +130,7 @@ Use default browser unless `xwidget' is available."
110130
(when (buffer-live-p buf)
111131
(and (eq buf (current-buffer)) (quit-window))
112132
(pop-to-buffer buf))))
113-
(browse-url url)))
133+
(grip--browser url)))
114134

115135
(defun grip--preview-url ()
116136
"Return grip preview url."

0 commit comments

Comments
 (0)