summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lisp/bandali-dired.el51
-rw-r--r--lisp/bandali-eshell.el50
-rw-r--r--lisp/bandali-ibuffer.el77
-rw-r--r--lisp/bandali-ido.el49
-rw-r--r--lisp/bandali-ivy.el54
5 files changed, 281 insertions, 0 deletions
diff --git a/lisp/bandali-dired.el b/lisp/bandali-dired.el
new file mode 100644
index 0000000..537ea24
--- /dev/null
+++ b/lisp/bandali-dired.el
@@ -0,0 +1,51 @@
+(use-package dired
+ :config
+ (setq dired-dwim-target t
+ dired-listing-switches "-alh"
+ ls-lisp-use-insert-directory-program nil)
+
+ ;; easily diff 2 marked files
+ ;; https://oremacs.com/2017/03/18/dired-ediff/
+ (defun dired-ediff-files ()
+ (interactive)
+ (require 'dired-aux)
+ (defvar ediff-after-quit-hook-internal)
+ (let ((files (dired-get-marked-files))
+ (wnd (current-window-configuration)))
+ (if (<= (length files) 2)
+ (let ((file1 (car files))
+ (file2 (if (cdr files)
+ (cadr files)
+ (read-file-name
+ "file: "
+ (dired-dwim-target-directory)))))
+ (if (file-newer-than-file-p file1 file2)
+ (ediff-files file2 file1)
+ (ediff-files file1 file2))
+ (add-hook 'ediff-after-quit-hook-internal
+ (lambda ()
+ (setq ediff-after-quit-hook-internal nil)
+ (set-window-configuration wnd))))
+ (error "no more than 2 files should be marked"))))
+
+ (require 'dired-x)
+ (setq dired-guess-shell-alist-user
+ '(("\\.pdf\\'" "evince" "zathura" "okular")
+ ("\\.doc\\'" "libreoffice")
+ ("\\.docx\\'" "libreoffice")
+ ("\\.ppt\\'" "libreoffice")
+ ("\\.pptx\\'" "libreoffice")
+ ("\\.xls\\'" "libreoffice")
+ ("\\.xlsx\\'" "libreoffice")
+ ("\\.flac\\'" "mpv")))
+ :bind (:map dired-mode-map
+ ("b" . dired-up-directory)
+ ("E" . dired-ediff-files)
+ ("e" . dired-toggle-read-only)
+ ("\\" . dired-hide-details-mode)
+ ("z" . (lambda ()
+ (interactive)
+ (b/dired-start-process "zathura"))))
+ :hook (dired-mode . dired-hide-details-mode))
+
+(provide 'bandali-dired)
diff --git a/lisp/bandali-eshell.el b/lisp/bandali-eshell.el
new file mode 100644
index 0000000..07ed623
--- /dev/null
+++ b/lisp/bandali-eshell.el
@@ -0,0 +1,50 @@
+(use-package eshell
+ :commands eshell
+ :bind ("C-c a s e" . eshell)
+ :config
+ (eval-when-compile (defvar eshell-prompt-regexp))
+ (defun b/eshell-quit-or-delete-char (arg)
+ (interactive "p")
+ (if (and (eolp) (looking-back eshell-prompt-regexp nil))
+ (eshell-life-is-too-much)
+ (delete-char arg)))
+
+ (defun b/eshell-clear ()
+ (interactive)
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ (eshell-send-input))
+
+ (defun b/eshell-setup ()
+ (make-local-variable 'company-idle-delay)
+ (defvar company-idle-delay)
+ (setq company-idle-delay nil)
+ (bind-keys :map eshell-mode-map
+ ("C-d" . b/eshell-quit-or-delete-char)
+ ("C-S-l" . b/eshell-clear)
+ ("M-r" . counsel-esh-history)
+ ;; ([tab] . company-complete)
+ :map eshell-hist-mode-map
+ ("M-r" . counsel-esh-history)))
+
+ (setq
+ eshell-prompt-regexp "\\(.*\n\\)*[$#] "
+ eshell-prompt-function
+ (lambda ()
+ (concat
+ (propertize (format "%s@%s:" (user-login-name) (system-name))
+ 'face 'default)
+ (propertize (abbreviate-file-name default-directory)
+ 'face 'font-lock-comment-face)
+ (propertize "\n" 'face 'default)
+ (if (= (user-uid) 0)
+ (propertize "#" 'face 'red)
+ (propertize "$" 'face 'default))
+ (propertize " " 'face 'default))))
+
+ :hook (eshell-mode . b/eshell-setup)
+ :custom
+ (eshell-hist-ignoredups t)
+ (eshell-input-filter 'eshell-input-filter-initial-space))
+
+(provide 'bandali-eshell)
diff --git a/lisp/bandali-ibuffer.el b/lisp/bandali-ibuffer.el
new file mode 100644
index 0000000..9b1b9b3
--- /dev/null
+++ b/lisp/bandali-ibuffer.el
@@ -0,0 +1,77 @@
+(use-package ibuffer
+ :bind
+ (("C-x C-b" . ibuffer)
+ :map ibuffer-mode-map
+ ("P" . ibuffer-backward-filter-group)
+ ("N" . ibuffer-forward-filter-group)
+ ("M-p" . ibuffer-do-print)
+ ("M-n" . ibuffer-do-shell-command-pipe-replace))
+ :config
+ ;; Use human readable Size column instead of original one
+ (define-ibuffer-column size-h
+ (:name "Size" :inline t)
+ (cond
+ ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
+ ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
+ ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
+ (t (format "%8d" (buffer-size)))))
+ :custom
+ (ibuffer-saved-filter-groups
+ '(("default"
+ ("dired" (mode . dired-mode))
+ ("org" (mode . org-mode))
+ ("gnus"
+ (or
+ (mode . gnus-group-mode)
+ (mode . gnus-summary-mode)
+ (mode . gnus-article-mode)
+ ;; not really, but...
+ (mode . message-mode)))
+ ("web"
+ (or
+ ;; (mode . web-mode)
+ (mode . mhtml-mode)
+ (mode . css-mode)
+ (mode . scss-mode)
+ (mode . js2-mode)))
+ ("shell"
+ (or
+ (mode . eshell-mode)
+ (mode . shell-mode)
+ (mode . term-mode)))
+ ("programming"
+ (or
+ (mode . python-mode)
+ (mode . c-mode)
+ (mode . c++-mode)
+ (mode . java-mode)
+ (mode . emacs-lisp-mode)
+ (mode . scheme-mode)
+ (mode . haskell-mode)
+ (mode . lean-mode)
+ ;; (mode . go-mode)
+ (mode . alloy-mode)))
+ ("tex"
+ (or
+ (mode . bibtex-mode)
+ (mode . latex-mode)))
+ ("emacs"
+ (or
+ (name . "^\\*scratch\\*$")
+ (name . "^\\*Messages\\*$")))
+ ("exwm" (mode . exwm-mode))
+ ("erc" (mode . erc-mode)))))
+ (ibuffer-formats
+ '((mark modified read-only locked " "
+ (name 72 72 :left :elide)
+ " "
+ (size-h 9 -1 :right)
+ " "
+ (mode 16 16 :left :elide)
+ " " filename-and-process)
+ (mark " "
+ (name 16 -1)
+ " " filename)))
+ :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
+
+(provide 'bandali-ibuffer)
diff --git a/lisp/bandali-ido.el b/lisp/bandali-ido.el
new file mode 100644
index 0000000..2639888
--- /dev/null
+++ b/lisp/bandali-ido.el
@@ -0,0 +1,49 @@
+(use-package ido
+ :demand
+ :bind
+ (:map ido-common-completion-map
+ ([escape] . minibuffer-keyboard-quit)
+ ("DEL" . b/ido-backspace))
+ :config
+ (require 'delsel)
+ (defun b/ido-backspace ()
+ "Forward to `backward-delete-char'. On error (read-only), quit."
+ (interactive)
+ (condition-case nil
+ (backward-delete-char 1)
+ (error
+ (minibuffer-keyboard-quit))))
+ (ido-mode 1)
+ (ido-everywhere 1)
+ :custom
+ (ido-enable-flex-matching t)
+ ;; (ido-enable-regexp t)
+ ;; (ido-enable-prefix t)
+ (ido-max-window-height 10)
+ (ido-use-virtual-buffers t))
+
+(use-package ido-vertical-mode
+ :defer 0.3
+ :config
+ (ido-vertical-mode 1)
+ :custom
+ (ido-vertical-define-keys 'C-n-C-p-up-and-down)
+ (ido-vertical-show-count t))
+
+(use-package ido-completing-read+
+ :defer 0.3
+ :after ido
+ :config
+ (ido-ubiquitous-mode 1))
+
+(use-package crm-custom
+ :defer 0.3
+ :config
+ (crm-custom-mode 1))
+
+(use-package icomplete
+ :defer 0.3
+ :config
+ (icomplete-mode 1))
+
+(provide 'bandali-ido)
diff --git a/lisp/bandali-ivy.el b/lisp/bandali-ivy.el
new file mode 100644
index 0000000..763168b
--- /dev/null
+++ b/lisp/bandali-ivy.el
@@ -0,0 +1,54 @@
+(use-package ivy
+ :defer 0.3
+ :bind
+ (:map ivy-minibuffer-map
+ ([escape] . keyboard-escape-quit)
+ ([S-up] . ivy-previous-history-element)
+ ([S-down] . ivy-next-history-element)
+ ("DEL" . ivy-backward-delete-char))
+ :config
+ (setq ivy-wrap t
+ ;; ivy-height 14
+ ivy-use-virtual-buffers t
+ ivy-virtual-abbreviate 'abbreviate
+ ivy-count-format "%d/%d ")
+
+ (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
+ (defun b/ivy-ignore-buffer-p (str)
+ "Return non-nil if str names a buffer with a major mode
+derived from one of `b/ivy-ignore-buffer-modes'.
+
+This function is intended for use with `ivy-ignore-buffers'."
+ (let* ((buf (get-buffer str))
+ (mode (and buf (buffer-local-value 'major-mode buf))))
+ (and mode
+ (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
+ (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
+
+ (ivy-mode 1)
+ :custom-face
+ (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
+ (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
+ (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
+ (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
+ (ivy-current-match ((((class color) (background light))
+ :background "#d7d7d7" :foreground "black")
+ (((class color) (background dark))
+ :background "#65a7e2" :foreground "black"))))
+
+(use-package swiper
+ :demand
+ :after ivy
+ :bind (("C-S-s" . swiper-isearch)))
+
+(use-package counsel
+ :demand
+ :after ivy
+ :bind (("C-c f r" . counsel-recentf)
+ :map minibuffer-local-map
+ ("C-r" . counsel-minibuffer-history))
+ :config
+ (counsel-mode 1)
+ (defalias 'locate #'counsel-locate))
+
+(provide 'bandali-ivy)