From 02bee7f8655c8d7121a45ace26a7aeaeec82b533 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Tue, 11 Aug 2020 18:30:30 +0900 Subject: [PATCH] Add my-fzf --- emacs.el | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index 2be2630..ef785f7 100644 --- a/emacs.el +++ b/emacs.el @@ -1144,8 +1144,49 @@ THEM are function and its args." (not (file-remote-p default-directory))) (let ((process-environment (cl-copy-list process-environment))) (setenv "FZF_DEFAULT_COMMAND" my-fzf-default-command) - (fzf)) + (my-fzf)) (call-interactively 'find-file))) + +(defvar fzf/position-bottom) +(defun my-fzf () + "Invoke `fzf' with my configurations." + (require 'fzf) + (let ((dir (or (ignore-errors + (require 'projectile) + (projectile-project-root)) + default-directory))) + (set-variable 'fzf/window-height 12) + (set-variable 'fzf/args + (concat "--print-query " + "--ansi " + "--color='bg+:-1' " + "--inline-info " + "--cycle " + "--reverse " + (format "--prompt='[%s]> ' " + dir))) + (fzf/start dir) + (let* ((buf (or (get-buffer "*fzf*") + (error "FZF buffer not found"))) + (current-window (or (get-buffer-window buf) + (error "FZF window not found"))) + (height (window-height current-window)) + (root-window nil) + (new-window nil)) + (with-current-buffer buf + (setq mode-line-format nil)) + (jump-to-register :fzf-windows) + ;; (delete-window current-window) + (setq root-window (frame-root-window)) + (setq new-window (split-window root-window + (- height) + 'below)) + (select-window new-window) + (switch-to-buffer buf) + (term-reset-size (window-height) + (window-width)) + ))) + (define-key ctl-x-map "f" 'my-fzf-or-find-file) (defun my-fzf-all-lines ()