commit daf1d2e8e554da08d562d64d96b611e08fa93f1e
parent 051c455f28067747a4cbd4a17cbd05b87a15c81b
Author: Mark Feller <mfeller@squareup.com>
Date: Mon, 15 Aug 2022 14:20:17 -0600
add emacs helper functions and vterm config
Diffstat:
4 files changed, 126 insertions(+), 91 deletions(-)
diff --git a/dots/.config/emacs/core/core-defuns.el b/dots/.config/emacs/core/core-defuns.el
@@ -202,6 +202,17 @@ is already narrowed."
(split-string
(shell-command-to-string "pash list") "\n"))
+(defun mjf/focused ()
+ (interactive)
+ (if (bound-and-true-p olivetti-mode)
+ (progn
+ (olivetti-mode -1)
+ (setq mode-line-format (default-value 'mode-line-format)))
+ (progn
+ (delete-other-windows)
+ (olivetti-mode 1)
+ (setq mode-line-format nil))))
+
(bind-keys ("M-P" . mjf/pash-copy))
(provide 'core-defuns)
diff --git a/dots/.config/emacs/core/core-packages.el b/dots/.config/emacs/core/core-packages.el
@@ -65,97 +65,104 @@
kept-old-versions 2
version-control t))
-(use-package ibuffer
- :bind (("C-x C-b" . ibuffer)
- :map ibuffer-mode-map
- ("/ p" . ibuffer-projectile-set-filter-groups))
+(use-package bufler
+ :bind (("C-x C-b" . bufler))
+
:config
- (setq ibuffer-default-sorting-mode 'major-mode)
- (setq ibuffer-display-summary nil)
- (setq ibuffer-expert t)
- (setq ibuffer-show-empty-filter-groups nil)
- (setq ibuffer-marked-char ?-)
-
- (add-hook 'ibuffer-mode-hook 'disable-line-numbers)
- (add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode 1)))
-
- (defun ibuffer-get-major-modes-ibuff-rules-list (mm-list result-list)
- (if mm-list
- (let* ((cur-mm (car mm-list))
- (next-res-list-el `(,(symbol-name cur-mm) (mode . ,cur-mm))))
- (ibuffer-get-major-modes-ibuff-rules-list
- (cdr mm-list) (cons next-res-list-el result-list)))
- result-list))
-
- (defun ibuffer-get-major-modes-list ()
- (mapcar
- (function (lambda (buffer)
- (buffer-local-value 'major-mode (get-buffer buffer))))
- (buffer-list (selected-frame))))
-
- (defun ibuffer-create-buffs-group ()
- (interactive)
- (let* ((ignore-modes '(Buffer-menu-mode
- compilation-mode
- minibuffer-inactive-mode
- ibuffer-mode
- magit-process-mode
- messages-buffer-mode
- fundamental-mode
- completion-list-mode
- help-mode
- Info-mode))
- (cur-bufs
- (list (cons "Home"
- (ibuffer-get-major-modes-ibuff-rules-list
- (cl-set-difference
- (remove-duplicates
- (ibuffer-get-major-modes-list))
- ignore-modes) '())))))
- (setq ibuffer-saved-filter-groups cur-bufs)
- (ibuffer-switch-to-saved-filter-groups "Home")))
-
- (autoload 'ibuffer "ibuffer" "List buffers." t)
-
- (defun ibuffer-group-by-modes ()
- "Group buffers by modes."
- (ibuffer-create-buffs-group))
-
-
- (defadvice ibuffer-update-title-and-summary (after remove-column-titles)
- (with-no-warnings
- (save-excursion
- (set-buffer "*Ibuffer*")
- (toggle-read-only 0)
- (goto-char 1)
- (search-forward "-\n" nil t)
- (delete-region 1 (point))
- ;; (let ((window-min-height 1))
- ;; ;; save a little screen estate
- ;; (shrink-window-if-larger-than-buffer))
- (toggle-read-only))))
-
- (ad-activate 'ibuffer-update-title-and-summary)
-
- ;; 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)))))
-
- ;; Modify the default ibuffer-formats
- (setq ibuffer-formats
- '((mark modified read-only " "
- (name 18 18 :left :elide)
- " "
- (size-h 9 -1 :right)
- " "
- (mode 16 16 :left :elide)
- " "
- filename-and-process))))
+ (add-to-list 'evil-emacs-state-modes 'bufler-list-mode))
+
+
+;; (use-package ibuffer
+;; :bind (("C-x C-b" . ibuffer)
+;; :map ibuffer-mode-map
+;; ("/ p" . ibuffer-projectile-set-filter-groups))
+;; :config
+;; (setq ibuffer-default-sorting-mode 'major-mode)
+;; (setq ibuffer-display-summary nil)
+;; (setq ibuffer-expert t)
+;; (setq ibuffer-show-empty-filter-groups nil)
+;; (setq ibuffer-marked-char ?-)
+
+;; (add-hook 'ibuffer-mode-hook 'disable-line-numbers)
+;; (add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode 1)))
+
+;; (defun ibuffer-get-major-modes-ibuff-rules-list (mm-list result-list)
+;; (if mm-list
+;; (let* ((cur-mm (car mm-list))
+;; (next-res-list-el `(,(symbol-name cur-mm) (mode . ,cur-mm))))
+;; (ibuffer-get-major-modes-ibuff-rules-list
+;; (cdr mm-list) (cons next-res-list-el result-list)))
+;; result-list))
+
+;; (defun ibuffer-get-major-modes-list ()
+;; (mapcar
+;; (function (lambda (buffer)
+;; (buffer-local-value 'major-mode (get-buffer buffer))))
+;; (buffer-list (selected-frame))))
+
+;; (defun ibuffer-create-buffs-group ()
+;; (interactive)
+;; (let* ((ignore-modes '(Buffer-menu-mode
+;; compilation-mode
+;; minibuffer-inactive-mode
+;; ibuffer-mode
+;; magit-process-mode
+;; messages-buffer-mode
+;; fundamental-mode
+;; completion-list-mode
+;; help-mode
+;; Info-mode))
+;; (cur-bufs
+;; (list (cons "Home"
+;; (ibuffer-get-major-modes-ibuff-rules-list
+;; (cl-set-difference
+;; (remove-duplicates
+;; (ibuffer-get-major-modes-list))
+;; ignore-modes) '())))))
+;; (setq ibuffer-saved-filter-groups cur-bufs)
+;; (ibuffer-switch-to-saved-filter-groups "Home")))
+
+;; (autoload 'ibuffer "ibuffer" "List buffers." t)
+
+;; (defun ibuffer-group-by-modes ()
+;; "Group buffers by modes."
+;; (ibuffer-create-buffs-group))
+
+
+;; (defadvice ibuffer-update-title-and-summary (after remove-column-titles)
+;; (with-no-warnings
+;; (save-excursion
+;; (set-buffer "*Ibuffer*")
+;; (toggle-read-only 0)
+;; (goto-char 1)
+;; (search-forward "-\n" nil t)
+;; (delete-region 1 (point))
+;; ;; (let ((window-min-height 1))
+;; ;; ;; save a little screen estate
+;; ;; (shrink-window-if-larger-than-buffer))
+;; (toggle-read-only))))
+
+;; (ad-activate 'ibuffer-update-title-and-summary)
+
+;; ;; 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)))))
+
+;; ;; Modify the default ibuffer-formats
+;; (setq ibuffer-formats
+;; '((mark modified read-only " "
+;; (name 18 18 :left :elide)
+;; " "
+;; (size-h 9 -1 :right)
+;; " "
+;; (mode 16 16 :left :elide)
+;; " "
+;; filename-and-process))))
(electric-pair-mode t)
(global-auto-revert-mode t)
@@ -240,7 +247,9 @@
((concat window-management-prefix "-t") . toggle-window-split)
((concat window-management-prefix "-<return>") . toggle-fullscreen)
- ((concat window-management-prefix "-c") . mjf/center-window))
+ ((concat window-management-prefix "-c") . mjf/center-window)
+ ((concat window-management-prefix "-W") . mjf/focused)
+ ((concat window-management-prefix "-n") . narrow-or-widen-dwim))
(delight 'subword-mode "" "subword")
(delight 'undo-tree-mode "" "undo-tree")
diff --git a/dots/.config/emacs/init.el b/dots/.config/emacs/init.el
@@ -114,6 +114,7 @@
(require 'module-projectile)
(require 'module-python)
(require 'module-restclient)
+(require 'module-vterm)
(require 'module-yaml)
(require 'module-yasnippet)
diff --git a/dots/.config/emacs/modules/module.vterm.el b/dots/.config/emacs/modules/module.vterm.el
@@ -0,0 +1,14 @@
+(use-package vterm
+ :config
+ (add-to-list 'evil-emacs-state-modes 'vterm-mode)
+ (add-to-list 'evil-emacs-state-modes 'compilation-mode)
+ (add-to-list 'vterm-mode-hook 'toggle-modeline))
+
+(use-package multi-vterm
+ :bind (("C-x p t" . multi-vterm-project)
+ ("H-T" . multi-vterm-dedicated-open)
+ ("H-u" . multi-vterm-next)
+ ("H-i" . multi-vterm-prev)
+ ("H-y" . multi-vterm)))
+
+(provide 'module-vterm)