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/
|
||||
.org-id-locations
|
||||
bookmarks
|
||||
request/
|
||||
|
||||
# Custom file
|
||||
custom.el
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@
|
|||
;; Transient
|
||||
(use-package transient)
|
||||
|
||||
;; Request is generally useful and a dependency for other packages
|
||||
(use-package request)
|
||||
|
||||
(provide 'shared-packages)
|
||||
|
||||
;;; shared-packages.el ends here
|
||||
|
|
|
|||
|
|
@ -22,37 +22,10 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(defcustom theurgy-city
|
||||
"Perth"
|
||||
"The city used for fetching weather from wttr.in."
|
||||
:type 'string
|
||||
: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))))
|
||||
(defun rename-eww-hook ()
|
||||
"Rename eww browser's buffer so sites open in new page."
|
||||
(rename-buffer "eww" t))
|
||||
(add-hook 'eww-mode-hook #'rename-eww-hook)
|
||||
|
||||
(provide 'browser)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue