|
99 | 99 | (define binary-type "python") |
100 | 100 | (define binary-path "") |
101 | 101 | (define warning-message "") |
102 | | -(define binary-list (list "python" "aspell" "conda" "convert" "goldfish" "ghostscript")) |
| 102 | +(define binary-list (list "python" "aspell" "conda" "convert" "goldfish" "ghostscript" "hunspell" "identify" "inkscape" "pandoc" "pdftocairo" "rsvg-convert")) |
103 | 103 |
|
104 | 104 | (define-format windows-executables |
105 | 105 | (:name "Executable") |
|
109 | 109 | (:name "Executable") |
110 | 110 | (:suffix "")) |
111 | 111 |
|
| 112 | +(tm-define (name-to-id name) |
| 113 | + (cond ((string=? name "python") "python3") |
| 114 | + ((string=? name "ghostcript") "gs") |
| 115 | + (else name))) |
| 116 | + |
112 | 117 | ; 更新路径信息,并刷新输入框让其显示新的路径信息 |
113 | 118 | (tm-define (update-path) |
114 | | - (let* ((this-opt (cond ((string=? binary-type "python") |
115 | | - (string-append "plugin:binary:" binary-type "3")) |
116 | | - ((string=? binary-type "ghostscript") |
117 | | - (string-append "plugin:binary:" "gs")) |
118 | | - (else |
119 | | - (string-append "plugin:binary:" binary-type)))) |
| 119 | + (let* ((this-opt (string-append "plugin:binary:" (name-to-id binary-type))) |
120 | 120 | (this-path (get-preference this-opt))) |
121 | 121 | (cond ((string=? this-path "default") |
122 | 122 | (set! binary-path "")) |
|
126 | 126 |
|
127 | 127 | ; 拼接字符串并传递给set-preference设置自定义路径 |
128 | 128 | (tm-define (set-binary-path) |
129 | | - (let* ((binary-opt (cond ((string=? binary-type "python") |
130 | | - "plugin:binary:python3") |
131 | | - ((string=? binary-type "ghostscript") |
132 | | - "plugin:binary:gs") |
133 | | - (else |
134 | | - (string-append "plugin:binary:" binary-type))))) |
135 | | - (set-preference binary-opt binary-path) |
136 | | - (display* (string-append binary-opt " " binary-path) "\n"))) |
| 129 | + (let* ((binary-opt (string-append "plugin:binary:" (name-to-id binary-type)))) |
| 130 | + (set-preference binary-opt binary-path))) |
137 | 131 |
|
138 | 132 | ; 验证路径是否符合要求 |
139 | 133 | (tm-define (find-binary-in-candidates) |
140 | 134 | (when (string=? binary-path "") |
141 | 135 | #f) |
142 | 136 | (let ((url (string->url binary-path)) |
143 | | - (binary-name (cond ((string=? binary-type "ghostscript") |
| 137 | + (binary-name (cond ((string=? binary-type "ghostscript") ;这里不能用(name-to-id)处理,如果使用了,则python插件无法适用于下面的判断逻辑 |
144 | 138 | "gs") |
145 | 139 | (else |
146 | 140 | binary-type)))) |
|
219 | 213 | (lambda (x) (apply make-session x)))) |
220 | 214 | ("Other" (interactive make-session)) |
221 | 215 | ("Manual path" (dialogue-window manual-path-widget |
222 | | - (lambda (args) |
223 | | - (display* args "\n") |
| 216 | + (lambda (args) |
224 | 217 | (when (!= args "cancel") ; 仅路径存在并点击确定时开始设置路径 |
225 | 218 | (if (not (find-binary-in-candidates)) ; 如果路径不合法,拒绝设置,弹出错误窗口 |
226 | 219 | (dialogue-window path-incorrect-widget |
227 | | - (lambda (args) (display* args "\n")) "Warning") |
| 220 | + (lambda (args) |
| 221 | + (set! binary-type (car binary-list))) |
| 222 | + "Warning") |
228 | 223 | (begin (set-binary-path) ; 路径合法,设置路径并弹出提示窗口 |
229 | 224 | (dialogue-window please-restart-widget |
230 | | - (lambda (args) (display* args "\n")) "Warning"))))) |
| 225 | + (lambda (args) |
| 226 | + (set! binary-type (car binary-list))) |
| 227 | + "Warning")))) |
| 228 | + (set! binary-type (car binary-list))) |
231 | 229 | "Set binary path")))) |
232 | 230 |
|
233 | 231 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
0 commit comments