bongo-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bongo-patches] Additions to bongo-dired-library-mode


From: Daniel Jensen
Subject: [bongo-patches] Additions to bongo-dired-library-mode
Date: Fri, 22 Jun 2007 15:21:19 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

Not all of these are strictly necessary, so you could remove a few of
them if you like. I find `^' the most useful.

I moved the hook code to a macro and simplified it a bit.

diff -Naur bongo-old/bongo.el bongo-new/bongo.el
--- bongo-old/bongo.el  2007-06-19 18:46:49.000000000 +0200
+++ bongo-new/bongo.el  2007-06-22 15:08:32.000000000 +0200
@@ -9820,20 +9820,52 @@
     (with-bongo-playlist-buffer
       (bongo-play-line point))))
 
+(defmacro with-bongo-dired-mode-hook (&rest body)
+  "Execute BODY with an extended `dired-mode-hook'.
+This adds a function to turn on `bongo-dired-library-mode'."
+  (declare (indent 0) (debug t))
+  `(let ((dired-mode-hook (and (boundp 'dired-mode-hook) dired-mode-hook)))
+     (add-hook 'dired-mode-hook
+               (lambda ()
+                 (bongo-dired-library-mode 1)))
+     ,@body))
+
+(defun bongo-dired-find-file ()
+  (interactive)
+  (with-bongo-dired-mode-hook
+    (dired-find-file)))
+
+(defun bongo-dired-find-file-other-window ()
+  (interactive)
+  (with-bongo-dired-mode-hook
+    (dired-find-file-other-window)))
+
+(defun bongo-dired-find-alternate-file ()
+  (interactive)
+  (with-bongo-dired-mode-hook
+    (dired-find-alternate-file)))
+
+(defun bongo-dired-view-file ()
+  (interactive)
+  (with-bongo-dired-mode-hook
+    (dired-view-file)))
+
+(defun bongo-dired-display-file ()
+  (interactive)
+  (with-bongo-dired-mode-hook
+    (dired-display-file)))
+
+(defun bongo-dired-up-directory (&optional other-window)
+  (interactive "P")
+  (with-bongo-dired-mode-hook
+    (dired-up-directory other-window)))
+
 (defun bongo-dired-dwim ()
   (interactive)
   (if (ignore-errors
         (bongo-backend-for-file (dired-get-file-for-visit)))
       (bongo-dired-play-line)
-    (let ((dired-mode-hook
-           (cons (lambda ()
-                   (bongo-dired-library-mode 1))
-                 (and (boundp 'dired-mode-hook)
-                      (if (and (listp dired-mode-hook)
-                               (not (eq (car dired-mode-hook) 'lambda)))
-                          dired-mode-hook
-                        (list dired-mode-hook))))))
-      (dired-find-file))))
+    (bongo-dired-find-file)))
 
 (defvar bongo-dired-library-mode-map
   (let ((map (make-sparse-keymap)))
@@ -9842,6 +9874,12 @@
       (define-key map "E" 'bongo-dired-insert-enqueue-lines)
       (define-key map "h" 'bongo-switch-buffers)
       (define-key map "q" 'bongo-quit)
+      (define-key map "f" 'bongo-dired-find-file)
+      (define-key map "o" 'bongo-dired-find-file-other-window)
+      (define-key map "a" 'bongo-dired-find-alternate-file)
+      (define-key map "v" 'bongo-dired-view-file)
+      (define-key map "\C-o" 'bongo-dired-display-file)
+      (define-key map "^" 'bongo-dired-up-directory)
       (define-key map "\C-m" 'bongo-dired-dwim)
       (define-key map " " 'bongo-pause/resume)
       (define-key map "\C-c\C-a" 'bongo-replay-current)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]