EXWM: Move ambrevar/helm-pass-for-page upstream

master
Pierre Neidhardt 2019-03-17 08:37:55 +01:00
parent fcce215ec8
commit d7e7572bbf
1 changed files with 1 additions and 34 deletions

View File

@ -112,40 +112,7 @@
(exwm-input-set-key (kbd "s-E") #'helm-eww-switch-other-window))
(when (fboundp 'helm-pass)
;; REVIEW: Shared upstream: https://gitlab.com/jabranham/helm-pass/issues/13.
(defun ambrevar/helm-pass-for-page ()
"Default prompt to current exwm-title"
(interactive)
(require 'helm-pass)
(helm :sources 'helm-pass-source-pass
:input (cond
((derived-mode-p 'eww-mode)
(let* ((url (replace-regexp-in-string ".*//\\([^/]*\\).*" "\\1" (eww-current-url)))
(domain (split-string url "\\.")))
(concat (nth (- (length domain) 2) domain) "." (nth (1- (length domain)) domain))))
((and (derived-mode-p 'exwm-mode) exwm-title)
(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))
(exwm-input-set-key (kbd "s-p") #'helm-pass))
;;; External application shortcuts.
(defun ambrevar/exwm-start (command)