Changeset - 8f6ee05ce83a
[Not reviewed]
0 1 0
Sergey Pashinin - 11 years ago 2014-08-23 07:18:03
sergey@pashinin.com
Check buf-uids, not buffers
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/workgroups-variables.el
Show inline comments
 
@@ -326,125 +326,128 @@ temporarily disable flagging `modified'.")
 

	
 
(defvar wg-window-configuration-changed nil
 
  "Flag set by `window-configuration-change-hook'.")
 

	
 
(defvar wg-already-updated-working-wconfig nil
 
  "Flag set by `wg-update-working-wconfig-hook'.")
 

	
 
(defvar wg-undoify-window-configuration-change t
 
  "Flag unset when changes to the window config shouldn't cause
 
workgroups' undo info to be updated.")
 

	
 

	
 

	
 

	
 
;; buffer-list-filter vars
 

	
 
(defvar wg-current-workgroup nil
 
  "Bound to the current workgroup in `wg-with-buffer-list-filters'.")
 

	
 
;; (defvar wg-current-buffer-command nil
 
;;   "Bound to the current buffer command in `wg-with-buffer-list-filters'.")
 

	
 
(defvar wg-current-buffer-list-filter-id nil
 
  "Bound to the current buffer-list-filter symbol in `wg-with-buffer-list-filters'.")
 

	
 
(defvar wg-previous-minibuffer-contents nil
 
  "Holds the previous minibuffer contents for re-insertion when
 
the buffer-list-filter is cycled.")
 

	
 
(defvar wg-ido-method-translations
 
  `((switch-to-buffer              . selected-window)
 
    (switch-to-buffer-other-window . other-window)
 
    (switch-to-buffer-other-frame  . other-frame)
 
    (kill-buffer                   . kill)
 
    (insert-buffer                 . insert)
 
    (display-buffer                . display))
 
  "Alist mapping buffer commands to ido buffer methods.")
 

	
 
(defvar wg-buffer-internal-default-buffer nil
 
  "Bound to `wg-buffer-internal's optional DEFAULT argument for
 
use by buffer list filtration hooks.")
 

	
 

	
 
;; wconfig restoration
 

	
 
(defvar wg-window-min-width 2
 
  "Bound to `window-min-width' when restoring wtrees. ")
 

	
 
(defvar wg-window-min-height 1
 
  "Bound to `window-min-height' when restoring wtrees.")
 

	
 
(defvar wg-window-min-pad 2
 
  "Added to `wg-window-min-foo' to produce the actual minimum window size.")
 

	
 
(defvar wg-actual-min-width (+ wg-window-min-width wg-window-min-pad)
 
  "Actual minimum window width when creating windows.")
 

	
 
(defvar wg-actual-min-height (+ wg-window-min-height wg-window-min-pad)
 
  "Actual minimum window height when creating windows.")
 

	
 
(defvar wg-min-edges `(0 0 ,wg-actual-min-width ,wg-actual-min-height)
 
  "Smallest allowable edge list of windows created by Workgroups.")
 

	
 
(defvar wg-null-edges '(0 0 0 0)
 
  "Null edge list.")
 

	
 
(defvar wg-window-tree-selected-window nil
 
  "Used during wconfig restoration to hold the selected window.")
 

	
 
(defvar wg-update-current-workgroup-working-wconfig-on-select-frame t
 
  "Non-nil means update `selected-frame's current workgroup's
 
working wconfig before `select-frame' selects a new frame.
 
let-bind this to nil around forms in which you don't want this to
 
happen.")
 

	
 
;; Remove after some time
 
(defalias 'wg-switch-to-buffer 'switch-to-buffer)
 

	
 

	
 
;;
 
;; Crazy stuff...
 
;;
 
(defcustom wg-associate-blacklist (list "*helm mini*" "*Messages*" "*scratch*"
 
                                        "*helm action*")
 
  "Do not autoassociate these buffers."
 
  :type 'list
 
  :group 'workgroups)
 

	
 
(defconst wg-buffer-list-original (symbol-function 'buffer-list))
 

	
 
(defun buffer-list (&optional frame)
 
  "Redefinition of `buffer-list'.
 
Pass FRAME to it.
 
Remove file and dired buffers that are not associated with workgroup."
 
  (let ((lst (list))
 
        (res (wg-buffer-list-emacs frame))
 
        (wg-buffers (wg-workgroup-associated-buffers (wg-current-workgroup))))
 
        ;;(wg-buffers (wg-workgroup-associated-buffers (wg-current-workgroup)))
 
        (wg-buf-uids (wg-workgroup-associated-buf-uids (wg-current-workgroup))))
 

	
 
    (dolist (b res res)
 
      (when (and (or (buffer-file-name b)
 
                     (eq (buffer-local-value 'major-mode b) 'dired-mode))
 
                 (not (member b wg-buffers)))
 
                 ;;(not (member b wg-buffers))
 
                 (not (member (wg-buffer-uid-or-add b) wg-buf-uids)))
 
        (delq b res)))))
 

	
 
(defconst wg-buffer-list-function (symbol-function 'buffer-list))
 
(fset 'buffer-list wg-buffer-list-original)
 
(fset 'wg-buffer-list-emacs wg-buffer-list-original)
 

	
 

	
 
;; locate-dominating-file
 
(defcustom wg-mess-with-buffer-list nil
 
  "Redefine `buffer-list' to show buffers for each workgroup.
 

	
 
Crazy stuff that allows to reduce amount of code, gives new
 
features but is fucking unstable, so disabled by default"
 
  :type 'boolean
 
  :group 'workgroups
 
  :set (lambda (sym val)
 
         (custom-set-default sym val)
 
         (if (and workgroups-mode val)
 
             (fset 'buffer-list wg-buffer-list-function)
 
           (fset 'buffer-list wg-buffer-list-original))))
 
(fset 'buffer-list wg-buffer-list-original)
 

	
 
(provide 'workgroups-variables)
 
;;; workgroups-variables.el ends here
0 comments (0 inline, 0 general)