Changeset - 3c87a9bd166e
[Not reviewed]
0 7 0
Sergey Pashinin - 11 years ago 2014-08-23 15:59:44
sergey@pashinin.com
Removed unused stuff
7 files changed with 11 insertions and 225 deletions:
0 comments (0 inline, 0 general)
src/workgroups-buf.el
Show inline comments
 
@@ -286,8 +286,6 @@ BUFFER nil defaults to `current-buffer'."
 
  (mapc 'wg-update-buffer-in-buf-list (or buffer-list (wg-buffer-list-emacs))))
 

	
 

	
 

	
 

	
 
(defun wg-buffer-list-display (buffer-list)
 
  "Return the BUFFER-LIST display string."
 
  (wg-display-internal
 
@@ -295,119 +293,12 @@ BUFFER nil defaults to `current-buffer'."
 
   (if wg-center-rotate-buffer-list-display
 
       (wg-center-rotate-list buffer-list) buffer-list)))
 

	
 
(defun wg-buffer-list-filter-display (&optional workgroup blf-id)
 
  "Return a buffer-list-filter display string from WORKGROUP and BLF-ID."
 
  (wg-fontify
 
    "("
 
    (wg-workgroup-name (wg-get-workgroup workgroup))
 
    ":"
 
    (wg-get-buffer-list-filter-val blf-id 'indicator)
 
    ")"))
 

	
 
(defun wg-buffer-list-filter-prompt (prompt &optional workgroup blf-id)
 
  "Return a prompt string from PROMPT indicating WORKGROUP and BLF-ID."
 
  (wg-fontify
 
    prompt " "
 
    (wg-buffer-list-filter-display workgroup blf-id)
 
    ": "))
 

	
 
(defun wg-buffer-command-display (&optional buffer-list)
 
  "Return the buffer command display string."
 
  (concat
 
   (wg-buffer-list-filter-display) ": "
 
   (wg-buffer-list-display (or buffer-list (wg-filtered-buffer-list)))))
 

	
 

	
 
(defun wg-read-buffer (prompt &optional default require-match)
 
  "Workgroups' version of `read-buffer'.
 
Read with PROMT DEFAULT REQUIRE-MATCH."
 
  (if (not (wg-filter-buffer-list-p))
 
      (funcall (wg-read-buffer-function) prompt default require-match)
 
    (wg-with-buffer-list-filters 'read-buffer
 
      (funcall (wg-read-buffer-function)
 
               (wg-buffer-list-filter-prompt
 
                (aif (string-match ": *$" prompt)
 
                    (substring prompt 0 it) prompt))
 
               default require-match))))
 

	
 

	
 

	
 
;;; filtered buffer-list construction
 

	
 
(defun wg-get-buffer-list-filter-id-flexibly (blf-id)
 
  "Return a buffer-list-filter-id one way or another."
 
  (or blf-id wg-current-buffer-list-filter-id 'all))
 

	
 
(defun wg-get-buffer-list-filter-val (id key &optional noerror)
 
  "Return ID's KEY's value in `wg-buffer-list-filter-definitions'.
 
Lots of possible errors here because
 
`wg-buffer-list-filter-definitions' can be modified by the user."
 
  (let ((slot-num (cl-case key (symbol 0) (indicator 1) (constructor 2))))
 
    (if (not slot-num)
 
        (unless noerror
 
          (error "`%S' is not a valid buffer-list-filter definition slot" key))
 
      (let* ((id (wg-get-buffer-list-filter-id-flexibly id))
 
             (entry (assq id (wg-local-value
 
                              'wg-buffer-list-filter-definitions))))
 
        (if (not entry)
 
            (unless noerror
 
              (error "`%S' is an undefined buffer-list-filter" id))
 
          (or (nth slot-num entry)
 
              (unless noerror
 
                (error "Slot `%S' is undefined in `%S's definition"
 
                       key id))))))))
 

	
 
(defun wg-filtered-buffer-list (&optional names workgroup bfl-id initial)
 
  "Return a filtered buffer-list from NAMES, WORKGROUP, BLF-ID and INITIAL.
 
NAMES non-nil means return a list of buffer-names instead of buffer objects.
 
WORKGROUP non-nil should be any workgroup identifier accepted by
 
`wg-get-workgroup'.
 
BLF-ID non-nil should be the identifier of a defined buffer-list-filter.
 
It defaults to `wg-get-buffer-list-filter-val'.
 
INITIAL non-nil should be an initial buffer-list to filter.  It defaults to
 
`wg-interesting-buffers'."
 
  (let ((buffer-list (funcall (wg-get-buffer-list-filter-val
 
                               (wg-get-buffer-list-filter-id-flexibly bfl-id)
 
                               'constructor)
 
                              (wg-get-workgroup workgroup)
 
                              (or initial (wg-interesting-buffers)))))
 
    (if names (mapcar 'wg-buffer-name buffer-list) buffer-list)))
 

	
 

	
 
;; buffer-list filters
 

	
 
(defun wg-buffer-list-filter-all (workgroup initial)
 
  "Return all buffers in INITIAL."
 
  initial)
 

	
 
(defun wg-filter-buffer-list-by-regexp (regexp buffer-list)
 
  "Return only those buffers in BUFFER-LIST with names matching REGEXP."
 
  (cl-remove-if-not (lambda (bname) (string-match regexp bname))
 
                    buffer-list :key 'buffer-name))
 

	
 
(defun wg-filter-buffer-list-by-root-dir (root-dir buffer-list)
 
  "Return only those buffers in BUFFER-LIST visiting files undo ROOT-DIR."
 
  (cl-remove-if-not (lambda (f) (when f (wg-file-under-root-path-p root-dir f)))
 
                    buffer-list :key 'buffer-file-name))
 

	
 
(defun wg-filter-buffer-list-by-major-mode (major-mode buffer-list)
 
  "Return only those buffers in BUFFER-LIST in major-mode MAJOR-MODE."
 
  (cl-remove-if-not (lambda (mm) (eq mm major-mode))
 
                    buffer-list :key 'wg-buffer-major-mode))
 

	
 

	
 
;; Example custom buffer-list-filters
 

	
 
(defun wg-buffer-list-filter-irc (workgroup buffer-list)
 
  "Return only those buffers in BUFFER-LIST with names starting in \"#\"."
 
  (wg-filter-buffer-list-by-regexp "^#" buffer-list))
 

	
 
(defun wg-buffer-list-filter-home-dir (workgroup buffer-list)
 
  "Return only those buffers in BUFFER-LIST visiting files under ~/."
 
  (wg-filter-buffer-list-by-root-dir "~/" buffer-list))
 

	
 

	
 

	
 
;; buffer-list-filter context
 

	
 
(defun wg-buffer-list-filter-order (command)
 
@@ -423,30 +314,5 @@ INITIAL non-nil should be an initial buffer-list to filter.  It defaults to
 
  "Return the current workgroup when buffer-list-filters are on."
 
  (and workgroups-mode wg-buffer-list-filtration-on (wg-current-workgroup t)))
 

	
 
(defmacro wg-with-buffer-list-filters (command &rest body)
 
  "Create buffer-list filter context for COMMAND, and eval BODY.
 
Binds `wg-current-buffer-list-filter-id' in BODY."
 
  (declare (indent 1))
 
  (wg-with-gensyms (order status)
 
    `(let* ((wg-previous-minibuffer-contents nil)
 
            (,order (wg-buffer-list-filter-order ,command)))
 
       (catch 'wg-result
 
         (while 'your-mom
 
           (let* ((wg-current-buffer-list-filter-id (car ,order))
 
                  (,status (catch 'wg-action (list 'done (progn ,@body)))))
 
             (cl-case (car ,status)
 
               (done (throw 'wg-result (cadr ,status)))
 
               (next (setq ,order (wg-rotate-list ,order 1))
 
                     (setq wg-previous-minibuffer-contents (cadr ,status)))
 
               (prev (setq ,order (wg-rotate-list ,order -1))
 
                     (setq wg-previous-minibuffer-contents
 
                           (cadr ,status))))))))))
 

	
 
(defun wg-toggle-buffer-list-filtration ()
 
  "Toggle `wg-buffer-list-filtration-on'."
 
  (interactive)
 
  (wg-toggle-and-message 'wg-buffer-list-filtration-on))
 

	
 

	
 
(provide 'workgroups-buf)
 
;;; workgroups-buf.el ends here
src/workgroups-keys.el
Show inline comments
 
@@ -109,7 +109,6 @@ off and then on again to take effect."
 

	
 
   ;; toggling
 
   (kbd "C-t C-m")    'wg-toggle-mode-line-display
 
   (kbd "C-t C-b")    'wg-toggle-buffer-list-filtration
 
   (kbd "C-t C-d")    'wg-toggle-window-dedicated-p
 

	
 

	
src/workgroups-utils-basic.el
Show inline comments
 
@@ -359,12 +359,6 @@ BUFFER-LIST should contain buffer objects and/or buffer names."
 
      (insert (format "%S" sexp)))
 
    (write-file file)))
 

	
 
(defun wg-file-under-root-path-p (root-path file-path)
 
  "Return t when FILE-PATH is under ROOT-PATH, nil otherwise."
 
  (string-match (concat "^" (regexp-quote (expand-file-name root-path)))
 
                (expand-file-name file-path)))
 

	
 

	
 

	
 
;;; frames
 

	
 
@@ -511,33 +505,6 @@ Saves some variables to restore a BUFFER later."
 
      (unless noerror
 
        (error "No session is defined"))))
 

	
 

	
 
(defun wg-read-buffer-mode ()
 
  "Return the buffer switching package (ido or iswitchb) to use, or nil."
 
  (if (eq wg-current-buffer-list-filter-id 'fallback) 'fallback
 
    (cl-case (let (workgroups-mode) (command-remapping 'switch-to-buffer))
 
      (ido-switch-buffer 'ido)
 
      (otherwise 'fallback))))
 

	
 
(defun wg-read-buffer-function (&optional mode)
 
  "Return MODE's or `wg-read-buffer-mode's `read-buffer' function."
 
  (cl-case (or mode (wg-read-buffer-mode))
 
    (ido 'ido-read-buffer)
 
    (fallback (lambda (prompt &optional default require-match)
 
                (let (read-buffer-function)
 
                  (read-buffer prompt default require-match))))))
 

	
 
(defun wg-completing-read
 
    (prompt choices &optional pred require-match initial-input history default)
 
  "Do a completing read.  The function called depends on what's on."
 
  (cl-ecase (wg-read-buffer-mode)
 
    (ido
 
     (ido-completing-read prompt choices pred require-match
 
                          initial-input history default))
 
    (fallback
 
     (completing-read prompt choices pred require-match
 
                      initial-input history default))))
 

	
 
;; locate-dominating-file
 
(defun wg-get-first-existing-dir (&optional dir)
 
  "Test if DIR exists and return it.
src/workgroups-variables.el
Show inline comments
 
@@ -334,37 +334,7 @@ temporarily disable flagging `modified'.")
 
  "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.")
 

	
 
(defvar wg-current-workgroup nil "Bound to the current workgroup.")
 

	
 
;; wconfig restoration
 

	
 
@@ -386,8 +356,7 @@ use by buffer list filtration hooks.")
 
(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-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.")
src/workgroups-wconfig.el
Show inline comments
 
@@ -244,10 +244,9 @@ If you want, restore them manually and try again."
 
    (wg-restore-wconfig-undoably
 
     (wg-workgroup-get-saved-wconfig
 
      workgroup
 
      (wg-completing-read
 
       "Saved wconfig: "
 
       (mapcar 'wg-wconfig-name (wg-workgroup-saved-wconfigs workgroup))
 
       nil t)))))
 
      (ido-completing-read "Saved wconfig: "
 
                           (mapcar 'wg-wconfig-name (wg-workgroup-saved-wconfigs workgroup))
 
                           nil t)))))
 

	
 
(defun wg-kill-saved-wconfig ()
 
  "Kill one of the current workgroup's saved wconfigs.
src/workgroups-workgroup.el
Show inline comments
 
@@ -227,9 +227,9 @@ Or scream unless NOERROR."
 

	
 

	
 
(defun wg-read-workgroup-name (&optional require-match)
 
  "Read a workgroup with `wg-completing-read'."
 
  (wg-completing-read
 
   "Workgroup: " (wg-workgroup-names) nil require-match nil nil
 
  "Read a workgroup name from `wg-workgroup-names'.
 
REQUIRE-MATCH to match."
 
  (ido-completing-read "Workgroup: " (wg-workgroup-names) nil require-match nil nil
 
   (awhen (wg-current-workgroup t) (wg-workgroup-name it))))
 

	
 
(defun wg-new-default-workgroup-name ()
 
@@ -249,10 +249,9 @@ Or scream unless NOERROR."
 
(defun wg-read-saved-wconfig-name (workgroup &optional prompt require-match)
 
  "Read the name of a saved wconfig, completing on the names of
 
WORKGROUP's saved wconfigs."
 
  (wg-completing-read
 
   (or prompt "Saved wconfig name: ")
 
   (wg-workgroup-saved-wconfig-names workgroup)
 
   nil require-match))
 
  (ido-completing-read (or prompt "Saved wconfig name: ")
 
                       (wg-workgroup-saved-wconfig-names workgroup)
 
                       nil require-match))
 

	
 
(defun wg-read-saved-wconfig (workgroup)
 
  "Read the name of and return one of WORKGROUP's saved wconfigs."
src/workgroups2.el
Show inline comments
 
@@ -96,19 +96,6 @@
 
(require 'workgroups-association)
 

	
 

	
 
(define-minor-mode workgroups-everywhere
 
  "Use Workgroups' buffer list filters everywhere `read-buffer' is used."
 
  :global t
 
  :group 'workgroups
 
  (awhen (get 'workgroups-everywhere 'read-buffer-fn)
 
    (when (eq read-buffer-function 'wg-read-buffer)
 
      (setq read-buffer-function it))
 
    (put 'workgroups-everywhere 'read-buffer-fn nil))
 
  (when workgroups-everywhere
 
    (put 'workgroups-everywhere 'read-buffer-fn read-buffer-function)
 
    (setq read-buffer-function 'wg-read-buffer)))
 

	
 

	
 
(defun wg-add-or-remove-workgroups-hooks (remove)
 
  "Add or remove all of Workgroups' hooks, depending on REMOVE."
 
  (wg-add-or-remove-hooks
0 comments (0 inline, 0 general)