Skip to content

Commit

Permalink
important fix and a cool extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Bar Magal committed Feb 13, 2015
1 parent 1cad1cc commit 27c3c63
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
37 changes: 37 additions & 0 deletions extensions/pu-ext-dired-ibuffer.el
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 6 additions & 3 deletions purpose-switch.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))


Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions purpose.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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.")


Expand Down

0 comments on commit 27c3c63

Please sign in to comment.