aboutsummaryrefslogtreecommitdiff
path: root/eb.el
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-31 01:45:07 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-31 01:45:07 +0200
commit41b565c2d39411e25b46ec8f8eb09205eb830a0c (patch)
treea5c7fc0f404969bcb6edf5288be79db23f5b8e9b /eb.el
parent3deeb40e4a3c8cbbc6778749845ee37e608ba3d9 (diff)
downloadEpisodeBrowser-41b565c2d39411e25b46ec8f8eb09205eb830a0c.tar.gz
eb.el: Improve eb-dired.
Diffstat (limited to 'eb.el')
-rw-r--r--eb.el62
1 files changed, 52 insertions, 10 deletions
diff --git a/eb.el b/eb.el
index c79c369..20699b7 100644
--- a/eb.el
+++ b/eb.el
@@ -6,6 +6,7 @@
(require 'cl-lib)
+;;;###autoload
(defgroup eb nil
"Episode Browser development package."
:prefix "eb-")
@@ -19,22 +20,45 @@
;; (char-from-name name t))
;; fallback)))
+;; Truncate dired headers minor mode.
+
+(defvar eb--truncate-dired-headers--keywords
+ (list
+ '("^. \\(.*/\\)\\(.+\\)\\(:\\)\n"
+ (1 (list 'face dired-header-face 'invisible 'eb--truncate-dired-headers--invisible))
+ (2 (list 'face dired-header-face)))))
+
+(font-lock-add-keywords 'dired-mode eb--truncate-dired-headers--keywords)
+;; (font-lock-remove-keywords 'dired-mode eb--truncate-dired-headers--keywords)
+
+;;;###autoload
+(define-minor-mode eb--dired-truncate-headers-mode
+ "Show only last path component in `dired' header lines."
+ :lighter ""
+ (if eb--dired-truncate-headers-mode
+ (add-to-invisibility-spec 'eb--truncate-dired-headers--invisible)
+ (remove-from-invisibility-spec 'eb--truncate-dired-headers--invisible)))
+
+;; Fleeting minor mode.
+
;;;###autoload
(define-minor-mode eb--fleeting-minor-mode
"Minor mode for transient buffer selection pop-up windows."
:lighter "")
-(defmacro eb--fleeting-window (dir buffer &rest body)
- (declare (indent defun))
+(defmacro eb--fleeting-window (dir buffer &optional open close)
+ (declare (indent 2))
`(progn
(let ((buffer ,buffer)
(cwd default-directory))
(if (equal buffer (window-buffer))
(progn
+ ,close
(eb--fleeting-minor-mode -1)
(quit-window)
nil)
(when eb--fleeting-minor-mode
+ ,close
(eb--fleeting-minor-mode -1)
(quit-window))
(display-buffer-in-direction buffer '((direction . ,dir)))
@@ -42,7 +66,7 @@
(select-window window)
(with-current-buffer buffer
(setq default-directory cwd)
- ,@body
+ ,open
(eb--fleeting-minor-mode)
(setq eb--fleeting--direction ',dir))
(run-with-idle-timer 0 nil (lambda (window) (fit-window-to-buffer window)) window)
@@ -97,6 +121,8 @@
(add-hook 'window-configuration-change-hook #'eb--fleeting--window-hook)
(add-hook 'window-selection-change-functions #'eb--fleeting--window-hook)
+;; Development tool bar functions.
+
;;;###autoload
(defun eb-quit-or-bury ()
"Quit window or bury buffer."
@@ -141,11 +167,13 @@
(require 'bookmark)
(bookmark-maybe-load-default-file)
(eb--fleeting-window up (get-buffer-create bookmark-bmenu-buffer)
- (bookmark-bmenu-mode)
- (bookmark-bmenu--revert)
- (bookmark-bmenu-list)))
+ (progn (bookmark-bmenu-mode)
+ (bookmark-bmenu--revert)
+ (bookmark-bmenu-list))))
-(defvar eb--dired-width nil)
+(defvar eb--dired-truncate-lines--orig nil)
+(defvar eb--dired-hide-details-mode--orig nil)
+(defvar eb--dired-truncate-headers-mode--orig nil)
;;;###autoload
(defun eb-dired (&optional arg dir)
@@ -158,9 +186,20 @@
(if arg
(switch-to-buffer buffer)
(eb--fleeting-window right buffer
- (toggle-truncate-lines 1)
- (message "")
- (revert-buffer)))))
+ (progn
+ (setq eb--dired-truncate-lines--orig truncate-lines)
+ (setq eb--dired-hide-details-mode--orig dired-hide-details-mode)
+ (setq eb--dired-truncate-headers-mode--orig eb--dired-truncate-headers-mode)
+ (toggle-truncate-lines 1)
+ (dired-hide-details-mode 1)
+ (eb--dired-truncate-headers-mode 1)
+ (message "")
+ (revert-buffer))
+ (progn
+ (when (not eb--dired-truncate-lines--orig) (toggle-truncate-lines -1))
+ (when (not eb--dired-hide-details-mode--orig) (dired-hide-details-mode -1))
+ (when (not eb--dired-truncate-headers-mode--orig) (eb--dired-truncate-headers-mode -1))
+ (message "close"))))))
;;;###autoload
(defun eb-dired-here (&optional arg)
@@ -177,16 +216,19 @@
(call-interactively #'projectile-grep)
(call-interactively #'grep)))
+;;;###autoload
(defcustom eb-system "vs2019"
"Build system."
:group 'eb
:type '(radio (const "mingw") (const "vs2019")))
+;;;###autoload
(defcustom eb-config "Debug"
"Build configuration type."
:group 'eb
:type '(radio (const "Debug") (const "Release")))
+;;;###autoload
(defcustom eb-cwd "b"
"Working directory for executable."
:group 'eb