summaryrefslogtreecommitdiff
path: root/.emacs.d/snippets/exwm-holyK-firefox.el
blob: 519f8c19263c288363954c8fe1c4bb0f6e648cd9 (about) (plain)
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
;;; exwm-holyK-firefox --- Emacs keybinding implemention of exwm-firefox-core
;; Author: Thanos Apollo
;; URL: --
;; Version: 1.0
;; Package-Requires: ((emacs "24.4") (exwm "0.16") (exwm-firefox-core "1.0"))
;; Keywords: extensions

;;; Commentary:

;; This package implements exwm-firefox-core to allow navigation and editing in firefox
;; using default-like Emacs keybindings

;;; Code:

(require 'exwm-firefox-core)

(defvar exwm-firefox-class-names
  '("firefox-default" "firefox" "Firefox" "Nightly" "Icecat" "Iceweasel")
  "The class name used for detecting if current buffer is a firefox browser.")

(define-minor-mode exwm-firefox-holyK-mode
  "Get Emacs keybindings in Firefox with EXWM."
  :lighter " Firefox/EXWM"
  :keymap (let ((map (make-sparse-keymap)))
	    (define-key map (kbd "C-n") 'exwm-firefox-core-down)
	    (define-key map (kbd "C-p") 'exwm-firefox-core-up)
	    (define-key map (kbd "C-f") 'exwm-firefox-core-tab-next)
	    (define-key map (kbd "C-b") 'exwm-firefox-core-tab-previous)
	    (define-key map (kbd "C-y") 'exwm-firefox-core-paste)
	    (define-key map (kbd "C-s") 'exwm-firefox-core-quick-find)
	    (define-key map (kbd "C-c C-c") 'exwm-firefox-core-copy)
	    (define-key map (kbd "C-c C-n") 'exwm-firefox-core-tab-new)
	    (define-key map (kbd "C-c C-k") 'exwm-firefox-core-tab-close)
	    (define-key map (kbd "C-c C-d") 'exwm-firefox-core-tab-close)
	    (define-key map (kbd "C-c C-b") 'exwm-firefox-core-history-back)
	    (define-key map (kbd "C-c C-f") 'exwm-firefox-core-history-forward)
	    (define-key map (kbd "C-l")'exwm-firefox-core-focus-search-bar)
	    map))

(defun holyK-activate-if-firefox ()
  "Activates firefox-holyK-mode mode when buffer is firefox.
Firefox variant can be assigned in 'exwm-firefox-class-names`"
  (interactive)
  (if (member exwm-class-name exwm-firefox-class-names)
      (list (exwm-firefox-holyK-mode 1)
	    (setq-local exwm-input-line-mode-passthrough nil)
	    ;;if exwm-input-line-mode-passthroug t mouse will stop working properly
	    )))