-
Notifications
You must be signed in to change notification settings - Fork 1
/
про-интернет-сервисы.el
196 lines (157 loc) · 6.46 KB
/
про-интернет-сервисы.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;;; про-интернет-сервисы.el --- Сеть и Интернет -*- lexical-binding: t -*-
;;; Commentary:
;; Конфигурация сетевых сервисов, браузеров и мессенджеров
;;; Code:
(require 'use-package)
;;;; Tor proxy
(require 'url)
(use-package use-proxy
:ensure t
:config
;; Set up proxy settings here
(setq use-proxy-http-proxy "socks5h://127.0.0.1:9050")
(setq use-proxy-https-proxy "socks5h://127.0.0.1:9050")
(setq use-proxy-no-proxy "localhost|127.0.0.1|::1")
(use-proxy-mode 1)
;; Key bindings to toggle proxy settings
(global-set-key (kbd "C-c C-g") 'use-proxy-toggle-proxies-global))
;; Set the proxy for HTTP and HTTPS
;; (setq url-proxy-services
;; '(("no_proxy" . "localhost, 127.0.0.1") ; Not to proxy local addresses
;; ("http" . "socks5://127.0.0.1:9050")
;; ("https" . "socks5://127.0.0.1:9050")))
;(setq url-http-timeout 30)
;;;; Ускорение работы SSH
(require 'tramp)
(require 'tramp-sh)
(setq tramp-ssh-controlmaster-options t)
(setq tramp-chunksize 500)
(setq tramp-default-method "ssh")
(setq vc-ignore-dir-regexp
(format "\\(%s\\)\\|\\(%s\\)"
vc-ignore-dir-regexp
tramp-file-name-regexp))
;;;; URL открывается в текстовом браузере в новой вкладке или в Хроме.
(setq-default browse-url-browser-function 'eww-browse-url
browse-url-new-window-flag t
browse-url-generic-program "chromium")
;;;; EWW - Браузер на ELISP
(use-package eww
:defer t
:config)
;;;;; Нумерация ссылков
(use-package ace-link
:defer t
:ensure t
:after eww
:defer t
:commands (eww-back-url eww-forward-url ace-link-eww)
:bind (:map eww-mode-map
("<" . eww-back-url)
(">" . eww-forward-url)
("C-c f" . ace-link-eww)))
(use-package eww-lnum
:defer t
:ensure t
:demand t
:after eww
:bind (
:map eww-mode-map
("C-f" . forward-char)
("f" . eww-lnum-follow)
("F" . eww-lnum-follow)))
;;;; W3M - альтернативный текстовый браузер
(use-package w3m
:defer t
:ensure t
:hook (w3m-mode . w3m-lnum-mode)
:bind (:map w3m-mode-map
("C-<tab>" . w3m-tab-next-buffer)
("C-<iso-lefttab>" . w3m-tab-previous-buffer)
("C-w" . w3m-delete-buffer)
("M-n" . w3m-tab-next-buffer)
("M-p" . w3m-tab-previous-buffer)
("<S-return>" . w3m-view-this-url-background-session)
("<M-return>" . w3m-view-this-url-background-session)
("B" . w3m-view-previous-page)
("F" . w3m-view-next-page)
("<M-left>" . w3m-view-previous-page)
("<M-right>" . w3m-view-previous-page)
("F" . w3m-view-next-page)
("M-s" . nil)
("<XF86Back>" . nil)
("<XF86Forward>" . nil)
("C-r" . w3m-reload-this-page)
("C-S-R" . w3m-reload-this-page))
:config
(autoload 'w3m-browse-url "w3m" ">" t)
(setq-default w3m-use-cookies t
browse-url-new-window-flag t
w3m-show-graphic-icons-in-header-line t
w3m-display-inline-images t
w3m-show-graphic-icons-in-mode-line t
w3m-user-agent "Mozilla/5.0 (Linux; U; Android 2.3.3; zh-tw; HTC_Pyramid Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533."
w3m-session-load-always t
w3m-session-autosave t
w3m-session-load-last-sessions t))
;;;; Карты OSM
(use-package osm
:defer t
:ensure t)
;;;; Погода
(use-package wttrin
:defer t
:ensure t
:defines (wttrin-default-accept-language wttrin-default-cities)
:commands (wttrin)
:bind (("<f1> W" . wttrin))
:init
(setq wttrin-default-accept-language '("Accept-Language" . "ru-RU,ru")
wttrin-default-cities '("Moscow"
"Novosibirsk"
"Krasnoyarsk"
"Irkutsk"
"Angarsk"
"Voronezh"
"Rossosh")))
;;;; Перевод валют
(require 'url)
(defun usd-to-rub (sum)
"Преобразует сумму в долларах SUM в рубли.
используя текущий обменный курс с сервера."
(progn
(message "aaa %f" sum)
(url-retrieve "https://api.exchangerate-api.com/v4/latest/USD"
(lambda (status res)
(message "bbb %f" sum)
;; Обработка возможных ошибок при запросе.
(if (plist-get status :error)
(message "Не удалось получить данные о курсе валют.")
(goto-char url-http-end-of-headers)
;; Парсинг JSON-ответа
(let* ((json-object-type 'hash-table)
(json-array-type 'list)
(json-key-type 'string)
(response (json-read))
(rates (gethash "rates" response))
(rub-rate (gethash "RUB" rates)))
(if rub-rate
(message "Сумма в RUB: %.2f" (* sum rub-rate))
(message "Не найден курс RUB в ответе.")))))
(list sum))))
(defun my-browse-url-at-mouse (event)
"Open URL at mouse point with Alt or Shift key modifier.
Use Firefox if Alt is pressed, Chrome if Shift is pressed."
(interactive "e")
(let* ((mouse-pos (event-start event))
(url (thing-at-point 'url)))
(cond
((and (equal (event-modifiers event) '(alt)) url) ;; Alt pressed
(start-process "firefox" nil "firefox" url))
((and (equal (event-modifiers event) '(shift)) url) ;; Shift pressed
(start-process "chrome" nil "google-chrome" url))
(url
(browse-url-default-browser url))))) ;; Open in default browser if no modifier
(global-set-key [mouse-1] 'my-browse-url-at-mouse) ;; Настраиваем левую кнопку мыши
(provide 'про-интернет-сервисы)
;;; про-интернет-сервисы.el ends here