Add request and remove wttr.in functions
This commit is contained in:
parent
d8cdf07279
commit
6b8993703c
3 changed files with 8 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -19,6 +19,7 @@ transient/
|
||||||
url/
|
url/
|
||||||
.org-id-locations
|
.org-id-locations
|
||||||
bookmarks
|
bookmarks
|
||||||
|
request/
|
||||||
|
|
||||||
# Custom file
|
# Custom file
|
||||||
custom.el
|
custom.el
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@
|
||||||
;; Transient
|
;; Transient
|
||||||
(use-package transient)
|
(use-package transient)
|
||||||
|
|
||||||
|
;; Request is generally useful and a dependency for other packages
|
||||||
|
(use-package request)
|
||||||
|
|
||||||
(provide 'shared-packages)
|
(provide 'shared-packages)
|
||||||
|
|
||||||
;;; shared-packages.el ends here
|
;;; shared-packages.el ends here
|
||||||
|
|
|
||||||
|
|
@ -22,37 +22,10 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defcustom theurgy-city
|
(defun rename-eww-hook ()
|
||||||
"Perth"
|
"Rename eww browser's buffer so sites open in new page."
|
||||||
"The city used for fetching weather from wttr.in."
|
(rename-buffer "eww" t))
|
||||||
:type 'string
|
(add-hook 'eww-mode-hook #'rename-eww-hook)
|
||||||
:group 'theurgy
|
|
||||||
:group 'theurgy-weather)
|
|
||||||
|
|
||||||
(defun theurgy-eww-rename-buffer ()
|
|
||||||
"Rename the eww buffer intelligently."
|
|
||||||
(when (eq major-mode 'eww-mode)
|
|
||||||
(let ((url (plist-get eww-data :url)))
|
|
||||||
(cond
|
|
||||||
((string-match-p "wttr.in" url) "*weather*")
|
|
||||||
(t "*eww*")))))
|
|
||||||
|
|
||||||
(setq eww-auto-rename-buffer #'theurgy-eww-rename-buffer)
|
|
||||||
|
|
||||||
(defun theurgy-show-weather ()
|
|
||||||
"Show wttr.in in an eww buffer."
|
|
||||||
(interactive)
|
|
||||||
(if (get-buffer "*weather*")
|
|
||||||
(switch-to-buffer "*weather*")
|
|
||||||
(eww (concat "wttr.in/" theurgy-city "?0"))))
|
|
||||||
|
|
||||||
(unless (equal system-type 'android)
|
|
||||||
(add-to-list 'display-buffer-alist
|
|
||||||
'("\\*weather\\*"
|
|
||||||
(display-buffer-in-side-window)
|
|
||||||
(side . left)
|
|
||||||
(slot . 4)
|
|
||||||
(window-width . 0.15))))
|
|
||||||
|
|
||||||
(provide 'browser)
|
(provide 'browser)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue