From 703b58f3251cac6d28e1a1ae269167c3be743939 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 23 Jul 2019 00:07:14 +0200 Subject: [PATCH] term/*: conform to new conventions --- modules/term/eshell/autoload/eshell.el | 16 +++++----- modules/term/eshell/autoload/evil.el | 2 +- modules/term/eshell/autoload/prompts.el | 2 +- modules/term/eshell/config.el | 41 +++++++++++++------------ modules/term/vterm/config.el | 4 ++- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/modules/term/eshell/autoload/eshell.el b/modules/term/eshell/autoload/eshell.el index 52c23a52b..774ca6531 100644 --- a/modules/term/eshell/autoload/eshell.el +++ b/modules/term/eshell/autoload/eshell.el @@ -10,7 +10,7 @@ ;; -;; Helpers +;;; Helpers (defun +eshell--add-buffer (buf) (ring-remove+insert+extend +eshell-buffers buf 'grow)) @@ -75,7 +75,7 @@ ;; -;; Commands +;;; Commands ;;;###autoload (defun +eshell/toggle (arg &optional command) @@ -146,7 +146,7 @@ Once the eshell process is killed, the previous frame layout is restored." ;; -;; Keybinds +;;; Keybinds ;;;###autoload (defun +eshell/search-history () @@ -266,10 +266,10 @@ delete." ;; -;; Hooks +;;; Hooks ;;;###autoload -(defun +eshell|init () +(defun +eshell-init-h () "Initialize and track this eshell buffer in `+eshell-buffers'." (let ((current-buffer (current-buffer))) (dolist (buf (+eshell-buffers)) @@ -280,7 +280,7 @@ delete." (setq +eshell--last-buffer current-buffer))) ;;;###autoload -(defun +eshell|cleanup () +(defun +eshell-cleanup-h () "Close window (or workspace) on quit." (let ((buf (current-buffer))) (when (+eshell--remove-buffer buf) @@ -307,13 +307,13 @@ delete." return (select-window win)))))))))) ;;;###autoload -(defun +eshell|switch-workspace (type) +(defun +eshell-switch-workspace-fn (type) (when (eq type 'frame) (setq +eshell-buffers (or (persp-parameter 'eshell-buffers) (make-ring 25))))) ;;;###autoload -(defun +eshell|save-workspace (_workspace target) +(defun +eshell-save-workspace-fn (_workspace target) (when (framep target) (set-persp-parameter 'eshell-buffers +eshell-buffers))) diff --git a/modules/term/eshell/autoload/evil.el b/modules/term/eshell/autoload/evil.el index 49924ecb2..a3326e322 100644 --- a/modules/term/eshell/autoload/evil.el +++ b/modules/term/eshell/autoload/evil.el @@ -14,7 +14,7 @@ ((+eshell/open-popup nil command))))) ;;;###autoload -(defun +eshell*goto-prompt-on-insert () +(defun +eshell-goto-prompt-on-insert-a () "Move cursor to the prompt when switching to insert mode (if point isn't already there). diff --git a/modules/term/eshell/autoload/prompts.el b/modules/term/eshell/autoload/prompts.el index 7f6502df5..3a9638d09 100644 --- a/modules/term/eshell/autoload/prompts.el +++ b/modules/term/eshell/autoload/prompts.el @@ -20,7 +20,7 @@ ""))) ;;;###autoload -(defun +eshell-default-prompt () +(defun +eshell-default-prompt-fn () "Generate the prompt string for eshell. Use for `eshell-prompt-function'." (concat (if (bobp) "" "\n") (let ((pwd (eshell/pwd))) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 18b03bc39..077d0090e 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -67,7 +67,7 @@ You should use `set-eshell-alias!' to change this.") eshell-input-filter (lambda (input) (not (string-match-p "\\`\\s-+" input))) ;; em-prompt eshell-prompt-regexp "^.* λ " - eshell-prompt-function #'+eshell-default-prompt + eshell-prompt-function #'+eshell-default-prompt-fn ;; em-glob eshell-glob-case-insensitive t eshell-error-if-no-glob t) @@ -76,27 +76,27 @@ You should use `set-eshell-alias!' to change this.") (add-hook 'eshell-mode-hook #'doom-mark-buffer-as-real-h) ;; Keep track of open eshell buffers - (add-hook 'eshell-mode-hook #'+eshell|init) - (add-hook 'eshell-exit-hook #'+eshell|cleanup) + (add-hook 'eshell-mode-hook #'+eshell-init-h) + (add-hook 'eshell-exit-hook #'+eshell-cleanup-h) ;; Enable autopairing in eshell (add-hook 'eshell-mode-hook #'smartparens-mode) ;; Persp-mode/workspaces integration (when (featurep! :ui workspaces) - (add-hook 'persp-activated-functions #'+eshell|switch-workspace) - (add-hook 'persp-before-switch-functions #'+eshell|save-workspace)) + (add-hook 'persp-activated-functions #'+eshell-switch-workspace-fn) + (add-hook 'persp-before-switch-functions #'+eshell-save-workspace-fn)) ;; UI enhancements - (defun +eshell|remove-fringes () - (set-window-fringes nil 0 0) - (set-window-margins nil 1 nil)) - (add-hook 'eshell-mode-hook #'+eshell|remove-fringes) + (add-hook 'eshell-mode-hook + (defun +eshell-remove-fringes-h () + (set-window-fringes nil 0 0) + (set-window-margins nil 1 nil))) - (defun +eshell|enable-text-wrapping () - (visual-line-mode +1) - (set-display-table-slot standard-display-table 0 ?\ )) - (add-hook 'eshell-mode-hook #'+eshell|enable-text-wrapping) + (add-hook 'eshell-mode-hook + (defun +eshell-enable-text-wrapping-h () + (visual-line-mode +1) + (set-display-table-slot standard-display-table 0 ?\ ))) (add-hook 'eshell-mode-hook #'hide-mode-line-mode) @@ -109,15 +109,16 @@ You should use `set-eshell-alias!' to change this.") (after! em-term (pushnew! eshell-visual-commands "tmux" "htop" "vim" "nvim" "ncmpcpp")) - (defun +eshell|init-aliases () - (setq +eshell--default-aliases eshell-command-aliases-list - eshell-command-aliases-list - (append eshell-command-aliases-list - +eshell-aliases))) - (add-hook 'eshell-alias-load-hook #'+eshell|init-aliases) + (add-hook 'eshell-alias-load-hook + (defun +eshell-init-aliases-h () + (setq +eshell--default-aliases eshell-command-aliases-list + eshell-command-aliases-list + (append eshell-command-aliases-list + +eshell-aliases)))) (when (featurep! :editor evil +everywhere) - (advice-add #'evil-collection-eshell-next-prompt-on-insert :override #'+eshell*goto-prompt-on-insert)) + (advice-add #'evil-collection-eshell-next-prompt-on-insert + :override #'+eshell-goto-prompt-on-insert-a)) (add-hook 'eshell-first-time-mode-hook (defun +eshell-init-keymap-h () diff --git a/modules/term/vterm/config.el b/modules/term/vterm/config.el index 11913a41b..2faf42113 100644 --- a/modules/term/vterm/config.el +++ b/modules/term/vterm/config.el @@ -9,7 +9,9 @@ (add-hook 'vterm-mode-hook #'doom-mark-buffer-as-real-h) ;; Automatically kill buffer when vterm exits. - (add-to-list 'vterm-exit-functions (lambda (buffer) (if buffer (kill-buffer buffer)))) + (add-hook 'vterm-exit-functions + (defun +vterm-kill-buffer-on-quit-fn (buffer) + (if buffer (kill-buffer buffer)))) ;; Modeline serves no purpose in vterm (add-hook 'vterm-mode-hook #'hide-mode-line-mode) ;; Don't prompt about processes when killing vterm