diff options
Diffstat (limited to 'eb.el')
-rw-r--r-- | eb.el | 110 |
1 files changed, 105 insertions, 5 deletions
@@ -14,11 +14,6 @@ :group 'eb :type 'directory) -(defcustom eb-cppclean-argv (list "cppclean") - "Argument vector for cppclean." - :group 'eb - :type 'sexp) - ;;;###autoload (defun eb-run () "Launch built executable, displaying its output in a buffer." @@ -36,5 +31,110 @@ (start-process "EpisodeBrowser" buf exe) (display-buffer buf))) +;;;###autoload +(defun eb-compile () + "Compile without prompt." + (interactive) + (require 'projectile) + (let ((compilation-read-command nil)) + (call-interactively #'projectile-compile-project))) + +(defvar-local eb--list-buffers nil) + +;;;###autoload +(defun eb-list-buffers (&optional arg) + "List project buffers." + (interactive "P") + (require 'projectile) + (let ((buffer + (list-buffers-noselect (not arg) + (if arg + (projectile-project-buffers) + (mapcan + (lambda (b) (and (buffer-file-name b) (list b))) + (projectile-project-buffers)))))) + (display-buffer-in-direction buffer '((direction . up))) + (select-window (get-buffer-window buffer)) + (with-current-buffer buffer + (setq-local eb--list-buffers t)))) + +(define-advice Buffer-menu-mouse-select (:around (f event) eb-list-buffers) + (if eb--list-buffers + (progn + (select-window (posn-window (event-end event))) + (let ((buffer (tabulated-list-get-id (posn-point (event-end event))))) + (display-buffer buffer t) + (quit-window))) + (funcall f event))) + +;;;###autoload +(defun eb-dired () + "Open the root of the current project with `dired'." + (interactive) + (dired (project-root (project-current)))) + +(defvar-local eb-tool-bar-mode--old-map nil) +(defvar-local eb-tool-bar-mode--old-back-button-mode nil) +(defvar-local eb-tool-bar-mode--old-back-button-show-toolbar-buttons nil) + +;;;###autoload +(define-minor-mode eb-tool-bar-mode + "Useful tool bar buttons." + nil " EB" nil + (if eb-tool-bar-mode + (progn + (require 'back-button) + (setq eb-tool-bar-mode--old-map tool-bar-map) + (setq eb-tool-bar-mode--old-back-button-mode back-button-mode) + (setq eb-tool-bar-mode--old-back-button-show-toolbar-buttons back-button-show-toolbar-buttons) + (back-button-mode 1) + (setq-local back-button-show-toolbar-buttons nil) + (let ((map (make-sparse-keymap))) + (tool-bar-local-item "close" #'bury-buffer 'bury-buffer map + :label "Bury" :help "Bury buffer") + (tool-bar-local-item "index" #'eb-list-buffers 'list-buffers map + :label "Buffers" :help "Show project buffers") + (tool-bar-local-item "diropen" #'eb-dired 'dired map + :label "Root" :help "Browse project root") + + (define-key-after map [separator-1] menu-bar-separator) + + (tool-bar-local-item "refresh" #'eb-compile 'compile map + :label "Compile" :help "Compile project") + (tool-bar-local-item "search-replace" #'projectile-grep 'grep map + :label "Grep" :help "Grep project") + (tool-bar-local-item "connect" #'projectile-vc 'vc map + :label "Version Control" :help "Open project version control") + + (define-key-after map [separator-2] menu-bar-separator) + + ;; back-button + (tool-bar-local-item "left-arrow" + 'back-button-global-backward + 'back-button + map + :label "Back By Mark" + :visible '(and back-button-mode)) + (tool-bar-local-item "mpc/add" + 'back-button-push-mark-local-and-global + 'back-button-push + map + :label "push Mark" + :visible '(and back-button-mode)) + (tool-bar-local-item "right-arrow" + 'back-button-global-forward + 'forward-button + map + :label "Forward By Mark" + :visible '(and back-button-mode)) + (setq-local tool-bar-map map))) + (setq-local tool-bar-map eb-tool-bar-mode--old-map) + (if (not eb-tool-bar-mode--old-back-button-mode) + (back-button-mode 0)) + (setq-local back-button-show-toolbar-buttons eb-tool-bar-mode--old-back-button-show-toolbar-buttons))) + +(define-global-minor-mode global-eb-tool-bar-mode eb-tool-bar-mode + (lambda () (eb-tool-bar-mode 1))) + (provide 'eb) ;;; eb.el ends here |