From 27c3c63768ded10135cafe63677d9c241338d1f2 Mon Sep 17 00:00:00 2001 From: Bar Magal Date: Fri, 13 Feb 2015 21:33:06 +0200 Subject: [PATCH] important fix and a cool extension --- extensions/pu-ext-dired-ibuffer.el | 37 ++++++++++++++++++++++++++++++ purpose-switch.el | 9 +++++--- purpose.el | 4 ++-- 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 extensions/pu-ext-dired-ibuffer.el diff --git a/extensions/pu-ext-dired-ibuffer.el b/extensions/pu-ext-dired-ibuffer.el new file mode 100644 index 0000000..427d57a --- /dev/null +++ b/extensions/pu-ext-dired-ibuffer.el @@ -0,0 +1,37 @@ +(require 'purpose) + +(defvar pu-ext--window-layout + '(nil (0 0 152 35) + (:purpose edit :purpose-dedicated t :width 0.7466666666666667 :height 0.9722222222222222 :edges (0.0 0.0 0.7733333333333333 0.9722222222222222)) + (t (116 0 152 35) (:purpose dired :purpose-dedicated t :width 0.21333333333333335 :height 0.5 :edges (0.7733333333333333 0.0 1.0133333333333334 0.5)) (:purpose ibuffer :purpose-dedicated t :width 0.22 :height 0.4722222222222222 :edges (0.7733333333333333 0.5 1.0133333333333334 0.9722222222222222))))) + +(defun pu-ext--setup-ibuffer () + (purpose-set-mode-purpose 'ibuffer-mode 'ibuffer) + (add-hook 'ibuffer-mode-hook + #'(lambda () + (ibuffer-filter-by-filename "."))) + (add-hook 'ibuffer-mode-hook #'ibuffer-auto-mode) + (setq ibuffer-formats '((mark " " name))) + (setq ibuffer-display-summary nil) + (setq ibuffer-use-header-line nil) + ;; not sure if we want this... + ;; (setq ibuffer-default-shrink-to-minimum-size t) + (ibuffer-list-buffers)) + +(defun pu-ext-update-dired () + (when (and (buffer-file-name) + (cl-delete-if #'window-dedicated-p (purpose-windows-with-purpose 'dired))) + (save-selected-window + (dired (file-name-directory (buffer-file-name)))))) + +(defun pu-ext--setup-dired () + (add-hook 'dired-mode-hook #'dired-hide-details-mode) + (add-hook 'purpose-select-buffer-hook #'pu-ext-update-dired)) + +(defun pu-ext-setup () + (interactive) + (pu-ext--setup-ibuffer) + (pu-ext--setup-dired) + (purpose-set-window-layout pu-ext--window-layout)) + +(provide 'pu-ext-dired-ibuffer) diff --git a/purpose-switch.el b/purpose-switch.el index 52e7c22..b1870fc 100644 --- a/purpose-switch.el +++ b/purpose-switch.el @@ -79,14 +79,16 @@ it yourself.") (defun purpose-alist-set (key value alist) "Set VALUE to be the value associated to KEY in ALIST. This doesn't change the original alist, but returns a modified copy." - (setf (alist-get key alist) value)) + (setf (alist-get key alist) value) + alist) (defun purpose-alist-del (key alist) "Delete KEY from ALIST. This doesn't change the original alist, but returns a modified copy." ;; we could use any value instead of 0, as long as we used it instead ;; of 0 in both places - (setf (alist-get key alist 0 t) 0)) + (setf (alist-get key alist 0 t) 0) + alist) (defun purpose-alist-combine (&rest alists) ;; (purpose-flatten alists) @@ -443,7 +445,7 @@ This function runs hook `purpose-select-buffer-hook' when its done." (unless (eq new-frame old-frame) (select-frame-set-input-focus new-frame norecord)) (select-window new-window norecord)) - (run-hooks purpose-select-buffer-hook) + (run-hooks 'purpose-select-buffer-hook) buffer)) @@ -457,6 +459,7 @@ currently selected window is not available." ;; `display-buffer' should call `purpose--action-function', and ;; `purpose--action-function' should try to switch buffer in current window, ;; and if that's impossible - display buffer in another window. + (message "xxxx") (purpose-select-buffer buffer-or-name (if force-same-window 'force-same-window diff --git a/purpose.el b/purpose.el index ddd1cb2..5f6444d 100644 --- a/purpose.el +++ b/purpose.el @@ -2,7 +2,7 @@ ;; Author: Bar Magal (2015) ;; Package: purpose -;; Version: 1.1 +;; Version: 1.1.1 ;; Keywords: frames ;; Homepage: https://github.com/bmag/emacs-purpose ;; Package-Requires: ((emacs "24.4") (let-alist "1.0.3")) @@ -87,7 +87,7 @@ (require 'purpose-switch) (require 'purpose-prefix-overload) -(defconst purpose-version "1.1" +(defconst purpose-version "1.1.1" "Purpose's version.")