Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Last active December 30, 2017 08:00
Show Gist options
  • Save twlz0ne/b01ad4f4f726d9f98b7245d4a6abcfac to your computer and use it in GitHub Desktop.
Save twlz0ne/b01ad4f4f726d9f98b7245d4a6abcfac to your computer and use it in GitHub Desktop.
test helm-find-files with el-get
;;; Date: 2017-12-28_23.12.21
;;; Usage:
;; $ mkdir helm-test-files && cd helm-test-files/
;; $ printf '%04d\n' {1..1000} | xargs touch
;; $ /path/to/emacs -nw -Q -l /path/to/test-helm-find-files-with-el-get.el
(toggle-debug-on-error)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "<f1>") 'help-command)
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
;; ------------------------------------------------------------------
(setq el-get-dir (concat user-emacs-directory (format "el-get--%s/%s" (file-name-base load-file-name) emacs-version)))
(add-to-list 'load-path (concat el-get-dir "/el-get"))
(setq el-get-git-shallow-clone t)
(setq el-get-byte-compile nil)
(setq el-get-bundle-byte-compile nil)
(setq el-get-install-skip-emacswiki-recipes t)
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
(goto-char (point-max))
(eval-print-last-sexp)))
(remove-hook 'el-get-post-install-hooks 'el-get-post-install-notification)
;; ------------------------------------------------------------------
(el-get-bundle helm
(require 'helm))
(defun test-helm-find-files (path)
(setq abs-path (expand-file-name path))
(setq begin-time (current-time))
(setq time-elapsed nil)
(defun after-helm-update (&rest arg)
(setq time-elapsed (- (float-time (current-time)) (float-time begin-time))))
(defun after-helm-check-new-input (&rest arg)
(when (and helm-input (string= abs-path helm-input)
;; quite when "~/path/" changed to "$HOME/path/"
(keyboard-quit))))
(advice-add 'helm-update :after 'after-helm-update)
(advice-add 'helm-check-new-input :after 'after-helm-check-new-input)
(helm-find-files-1 path)
(advice-remove 'helm-check-new-input 'after-helm-check-new-input)
(advice-remove 'helm-update 'after-helm-update)
(message "%fs" time-elapsed))
(add-hook 'after-init-hook
(lambda ()
(switch-to-buffer "*scratch*")
(require 'helm-config)
(helm-mode 1)
(setq helm-debug t)
(setq-default helm-boring-file-regexp-list
(append '("\\.DS_Store$"
"\\.svn$"
"\\.svn-base$"
"\\.swp$") helm-boring-file-regexp-list))
(setq helm-ff-skip-boring-files t)
(message "---------- helm-ff-skip-boring-files: %s ----------" helm-ff-skip-boring-files)
(message "---------- tilde path")
(dotimes (i 10) (test-helm-find-files "~/helm-test-files/"))
(message "---------- abs path")
(dotimes (i 10) (test-helm-find-files (concat (getenv "HOME") "/helm-test-files/")))
(message "---------- tilde path")
(dotimes (i 10) (message "%s" (with-helm-time-after-update (helm-find-files-1 "~/helm-test-files/"))))
(message "---------- abs path")
(dotimes (i 10) (message "%s" (with-helm-time-after-update (helm-find-files-1 (concat (getenv "HOME") "/helm-test-files/")))))
(setq helm-ff-skip-boring-files nil)
(message "---------- helm-ff-skip-boring-files: %s ----------" helm-ff-skip-boring-files)
(message "---------- tilde path")
(dotimes (i 10) (test-helm-find-files "~/helm-test-files/"))
(message "---------- abs path")
(dotimes (i 10) (test-helm-find-files (concat (getenv "HOME") "/helm-test-files/")))
(message "---------- tilde path")
(dotimes (i 10) (message "%s" (with-helm-time-after-update (helm-find-files-1 "~/helm-test-files/"))))
(message "---------- abs path")
(dotimes (i 10) (message "%s" (with-helm-time-after-update (helm-find-files-1 (concat (getenv "HOME") "/helm-test-files/")))))
(switch-to-buffer "*Messages*")
))
(run-hooks 'after-init-hook)
;;; test-helm-find-files-with-el-get.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment