EXWM: Generalize helm-pass-for-page

master
Pierre Neidhardt 2018-06-28 00:34:37 +02:00
parent 8acbe879ea
commit 4cc7f0fdfb
1 changed files with 20 additions and 3 deletions

View File

@ -113,9 +113,26 @@
(domain (split-string url "\\.")))
(concat (nth (- (length domain) 2) domain) "." (nth (1- (length domain)) domain))))
((and (derived-mode-p 'exwm-mode) exwm-title)
(let* ((url (car (last (split-string exwm-title " "))))
(domain (split-string url "\\.")))
(concat (nth (- (length domain) 2) domain) "." (nth (1- (length domain)) domain)))))
(let* ((title exwm-title) url domain)
(with-temp-buffer
(insert title)
(goto-char (point-min))
(while (and (not (eobp))
(not (thing-at-point-url-at-point)))
(forward-word))
(setq url (thing-at-point-url-at-point)))
(if (not url)
""
(if (not (string-match (rx "//"
(group
(* (not (any "/")))
"."
(* (not (any "." "/"))))
"/")
url))
""
(setq domain (split-string (match-string 1 url) "\\."))
(concat (nth (- (length domain) 2) domain) "." (nth (1- (length domain)) domain)))))))
:buffer "*helm-pass*"))
(exwm-input-set-key (kbd "s-p") #'ambrevar/helm-pass-for-page))