Changeset - 811d54617711
[Not reviewed]
0 2 0
Sergey Pashinin - 12 years ago 2013-09-25 19:28:45
sergey@pashinin.com
new variable wg-mode-line-disable + powerline fix

wg-mode-line-disable is by default (featurep 'powerline)
2 files changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/workgroups-functions.el
Show inline comments
 
@@ -1527,195 +1527,196 @@ that name and return it. Otherwise error."
 
    (when (eq workgroup1 workgroup2)
 
      (error "Can't swap a workgroup with itself"))
 
    (unless (and (memq workgroup1 workgroup-list)
 
                 (memq workgroup2 workgroup-list))
 
      (error "Both workgroups aren't present in `wg-workgroup-list'."))
 
    (setf (wg-workgroup-list) (wg-util-swap workgroup1 workgroup2 workgroup-list)
 
          (wg-session-modified (wg-current-session)) t)))
 

	
 
(defun wg-cyclic-nth-from-workgroup (workgroup &optional n)
 
  "Return the workgroup N places from WORKGROUP in `wg-workgroup-list'."
 
  (wg-cyclic-nth-from-elt workgroup (wg-workgroup-list-or-error) (or n 1)))
 

	
 

	
 

	
 
;;; buffer association
 

	
 
(defun wg-associate-buffers (workgroup window-or-emacs-window-tree)
 
  "Associate the buffers visible in window elements of
 
WINDOW-OR-EMACS-WINDOW-TREE with the given WORKGROUP.
 
WINDOW-OR-EMACS-WINDOW-TREE must be either a window or a tree of
 
the form produced by `(car (window-tree))'."
 
  (wg-aif (windowp window-or-emacs-window-tree)
 
      (with-current-buffer (window-buffer window-or-emacs-window-tree)
 
        (setq wg-buffer-workgroup workgroup))
 
    (dolist (w (cddr window-or-emacs-window-tree))
 
      (when w (wg-associate-buffers workgroup w)))))
 

	
 
(defun wg-associate-frame-buffers ()
 
  "Associate the buffers visible in the current frame with the
 
current workgroup (unless it is currently being deactivated)."
 
  (wg-awhen (wg-current-workgroup :noerror)
 
    (unless (member it wg-deactivation-list)
 
      (wg-associate-buffers it (car (window-tree))))))
 

	
 
(defun wg-associate-all-frame-buffers ()
 
  "Associate all visible buffers with the current
 
workgroup (unless it is currently being deactivated)."
 
  (mapcar 'wg-associate-frame-buffers (frame-list)))
 

	
 
(defun wg-buffer-predicate (buffer)
 
  "Return t iff the given BUFFER should be considered a candidate
 
for display by `other-buffer' in the current workgroup."
 
  (or (not wg-associate-buffers)
 
      (wg-awhen (wg-current-workgroup :noerror)
 
        (with-current-buffer buffer
 
          (eq wg-buffer-workgroup it)))))
 

	
 
(defun wg-after-make-frame (frame)
 
  (set-frame-parameter frame 'buffer-predicate
 
                       'wg-buffer-predicate))
 

	
 
;;; mode-line
 

	
 
(defun wg-mode-line-buffer-association-indicator (workgroup)
 
  "Return a string indicating `current-buffer's association-type in WORKGROUP."
 
  (case (wg-workgroup-bufobj-association-type workgroup (current-buffer))
 
    (strong wg-mode-line-decor-strongly-associated)
 
    (weak wg-mode-line-decor-weakly-associated)
 
    (otherwise wg-mode-line-decor-unassociated)))
 

	
 
(defun wg-mode-line-string ()
 
  "Return the string to be displayed in the mode-line."
 
  (let ((wg (wg-current-workgroup t))
 
        (wg-use-faces wg-mode-line-use-faces))
 
    (cond (wg (wg-fontify " "
 
                ;;(consp (cons :div wg-mode-line-decor-left-brace))
 
                ;;(keywordp (car (cons :div wg-mode-line-decor-left-brace)))
 
                ;;(:div wg-mode-line-decor-left-brace)
 
                wg-mode-line-decor-left-brace
 
                (wg-workgroup-name wg)
 
                (if (not wg-mode-line-only-name)
 
                    (progn
 
                      wg-mode-line-decor-divider
 
                      (wg-mode-line-buffer-association-indicator wg)
 
                      wg-mode-line-decor-divider
 
                      (if (window-dedicated-p)
 
                                 wg-mode-line-decor-window-dedicated
 
                               wg-mode-line-decor-window-undedicated)
 
                      wg-mode-line-decor-divider
 
                      (if (wg-session-modified (wg-current-session))
 
                                 wg-mode-line-decor-session-modified
 
                               wg-mode-line-decor-session-unmodified)
 
                      (if (wg-workgroup-modified wg)
 
                          wg-mode-line-decor-workgroup-modified
 
                        wg-mode-line-decor-workgroup-unmodified)))
 
                wg-mode-line-decor-right-brace))
 
          (t (if wg-display-nowg
 
                 (progn
 
                   (wg-fontify " "
 
                     wg-mode-line-decor-left-brace
 
                     wg-nowg-string
 
                     wg-mode-line-decor-right-brace))
 
               "")))))
 

	
 
(defun wg-add-mode-line-display ()
 
  "Add Workgroups' mode-line format to `mode-line-format'."
 
  (unless (assq 'wg-mode-line-display-on mode-line-format)
 
  (unless (or (assq 'wg-mode-line-display-on mode-line-format)
 
              wg-mode-line-disable)
 
    (let ((format '(wg-mode-line-display-on (:eval (wg-mode-line-string))))
 
          (pos (wg-position 'mode-line-position mode-line-format)))
 
          (pos (or (wg-position 'mode-line-position mode-line-format) 10)))
 
      (set-default 'mode-line-format
 
                   (wg-insert-after format mode-line-format pos))
 
      (force-mode-line-update))))
 

	
 
(defun wg-remove-mode-line-display ()
 
  "Remove Workgroups' mode-line format from `mode-line-format'."
 
  (wg-awhen (assq 'wg-mode-line-display-on mode-line-format)
 
    (set-default 'mode-line-format (remove it mode-line-format))
 
    (force-mode-line-update)))
 

	
 

	
 

	
 
;;; messaging
 

	
 
(defun wg-message (format-string &rest args)
 
  "Call `message' with FORMAT-STRING and ARGS.
 
Also save the msg to `wg-last-message'."
 
  (setq wg-last-message (apply #'message format-string args)))
 

	
 
(defmacro wg-fontified-message (&rest format)
 
  "`wg-fontify' FORMAT and call `wg-message' on it."
 
  (declare (indent defun))
 
  `(wg-message (wg-fontify ,@format)))
 

	
 

	
 

	
 
;;; fancy displays
 

	
 
;; FIXME: add `wg-display-max-lines' to chop long display strings at max-line
 
;; and element-name boundaries
 

	
 
(defun wg-element-display (elt elt-string &optional current-elt-p previous-elt-p)
 
  "Return display string for ELT."
 
  (cond ((and current-elt-p (funcall current-elt-p elt))
 
         (wg-fontify (:cur (concat wg-list-display-decor-current-left
 
                                   elt-string
 
                                   wg-list-display-decor-current-right))))
 
        ((and previous-elt-p (funcall previous-elt-p elt))
 
         (wg-fontify (:prev (concat wg-list-display-decor-previous-left
 
                                    elt-string
 
                                    wg-list-display-decor-previous-right))))
 
        (t (wg-fontify (:other elt-string)))))
 

	
 
(defun wg-workgroup-display (workgroup index)
 
  "Return display string for WORKGROUP at INDEX."
 
  (if (not workgroup) wg-nowg-string
 
    (wg-element-display
 
     workgroup
 
     (format "%d: %s" index (wg-workgroup-name workgroup))
 
     'wg-current-workgroup-p
 
     'wg-previous-workgroup-p)))
 

	
 
(defun wg-buffer-display (buffer index)
 
  "Return display string for BUFFER. INDEX is ignored."
 
  (if (not buffer) "No buffers"
 
    (wg-element-display
 
     (wg-get-buffer buffer)
 
     (format "%s" (wg-buffer-name buffer))
 
     'wg-current-buffer-p)))
 

	
 

	
 
;; (defun wg-display-internal (elt-fn list)
 
;;   "Return display string built by calling ELT-FN on each element of LIST."
 
;;   (let ((div (wg-add-face :div wg-list-display-decor-divider))
 
;;         (i -1))
 
;;     (wg-fontify
 
;;       (:brace wg-list-display-decor-left-brace)
 
;;       (if (not list) (funcall elt-fn nil nil)
 
;;         (wg-doconcat (elt list div) (funcall elt-fn elt (incf i))))
 
;;       (:brace wg-list-display-decor-right-brace))))
 

	
 
(defcustom wg-display-max-lines 1
 
  "FIXME: docstring this"
 
  :type 'integer
 
  :group 'workgroups)
 

	
 

	
 

	
 
(defun wg-display-internal (elt-fn list)
 
  "Return display string built by calling ELT-FN on each element of LIST."
 
  (let ((div (wg-add-face :div wg-list-display-decor-divider))
 
        (wwidth (window-width (minibuffer-window)))
 
        (i -1)
 
        (str))
 
    (setq str
 
          (wg-fontify
 
            (:brace wg-list-display-decor-left-brace)
 
            (if (not list) (funcall elt-fn nil nil)
 
              (wg-doconcat (elt list div) (funcall elt-fn elt (incf i))))
 
            (:brace wg-list-display-decor-right-brace)))
 
    ;; (subseq str 0 wwidth)
 
    ))
 

	
 
(defun wg-workgroup-list-display (&optional workgroup-list)
 
  "Return the Workgroups list display string.
 
The string contains the names of all workgroups in `wg-workgroup-list',
src/workgroups-variables.el
Show inline comments
 
@@ -506,192 +506,197 @@ Otherwise, don't remap."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-remap-insert-buffer nil
 
  "Non-nil means remap `insert-buffer' to `wg-insert-buffer'.
 
Otherwise, don't remap."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-remap-next-buffer nil
 
  "Non-nil means remap `next-buffer' to `wg-next-buffer'.
 
Otherwise, don't remap."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-remap-previous-buffer nil
 
  "Non-nil means remap `previous-buffer' to `wg-previous-buffer'.
 
Otherwise, don't remap."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-remap-bury-buffer 'bury
 
  "Non-nil means remap `bury-buffer'.
 
`banish' means remap `bury-buffer' to `wg-banish-buffer'.
 
`bury' or other non-nil means remap `bury-buffer' to
 
`wg-bury-buffer'.  Otherwise, don't remap."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-ido-entry-buffer-replacement-regexp "^ .*Minibuf.*$"
 
  "Regexp matching the name of a buffer to replace `ido-entry-buffer'.
 
The regexp should match the name of a live buffer that will never
 
be a completion candidate under normal circumstances.  You
 
probably don't want to change this.  See
 
`wg-get-sneaky-ido-entry-buffer-replacement'."
 
  :type 'regexp
 
  :group 'workgroups)
 

	
 

	
 
;; morph customization
 

	
 
(defcustom wg-morph-on nil
 
  "Non-nil means use `wg-morph' when restoring wconfigs."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-morph-hsteps 9
 
  "Columns/iteration to step window edges during `wg-morph'.
 
Values lower than 1 are invalid."
 
  :type 'integer
 
  :group 'workgroups)
 

	
 
(defcustom wg-morph-vsteps 3
 
  "Rows/iteration to step window edges during `wg-morph'.
 
Values lower than 1 are invalid."
 
  :type 'integer
 
  :group 'workgroups)
 

	
 
(defcustom wg-morph-terminal-hsteps 3
 
  "Used instead of `wg-morph-hsteps' in terminal frames.
 
If nil, `wg-morph-hsteps' is used."
 
  :type 'integer
 
  :group 'workgroups)
 

	
 
(defcustom wg-morph-terminal-vsteps 1
 
  "Used instead of `wg-morph-vsteps' in terminal frames.
 
If nil, `wg-morph-vsteps' is used."
 
  :type 'integer
 
  :group 'workgroups)
 

	
 
(defcustom wg-morph-truncate-partial-width-windows t
 
  "Bound to `truncate-partial-width-windows' during `wg-morph'.
 
Non-nil, this prevents weird-looking continuation line behavior,
 
and can speed up morphing a little.  Lines jump back to their
 
wrapped status when `wg-morph' is complete."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 

	
 
;; mode-line customization
 

	
 
(defcustom wg-mode-line-display-on t
 
  "Toggles Workgroups' mode-line display."
 
  :type 'boolean
 
  :group 'workgroups
 
  :set (lambda (sym val)
 
         (custom-set-default sym val)
 
         (force-mode-line-update)))
 

	
 
(defcustom wg-mode-line-use-faces nil
 
  "Non-nil means use faces in the mode-line display.
 
It can be tricky to choose faces that are visible in both active
 
and inactive mode-lines, so this feature defaults to off."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-disable (featurep 'powerline)
 
  "Do not do any modeline modifications."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-only-name t
 
  "Display only workgroup name in modeline without any flags."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-left-brace "("
 
  "String displayed at the left of the mode-line display."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-right-brace ")"
 
  "String displayed at the right of the mode-line display."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-divider ":"
 
  "String displayed between elements of the mode-line display."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-strongly-associated
 
  #("@" 0 1 (help-echo "This buffer is strongly associated with the \
 
current workgroup"))
 
  "Indicates that a buffer is strongly associated with the current workgroup."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-weakly-associated
 
  #("~" 0 1 (help-echo "This buffer is weakly associated with the \
 
current workgroup"))
 
  "Indicates that a buffer is weakly associated with the current workgroup."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-unassociated
 
  #("-" 0 1 (help-echo "This buffer is unassociated with the \
 
current workgroup"))
 
  "Indicates that a buffer is unassociated with the current workgroup."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-window-dedicated
 
  #("#" 0 1 (help-echo "This window is dedicated to its buffer."))
 
  "Indicates that the window is dedicated to its buffer."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-window-undedicated
 
  #("-" 0 1 (help-echo "This window is not dedicated to its buffer."))
 
  "Indicates that the window is not dedicated to its buffer."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-session-modified
 
  #("*" 0 1 (help-echo "The session is modified"))
 
  "Indicates that the session is modified."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-session-unmodified
 
  #("-" 0 1 (help-echo "The session is unmodified"))
 
  "Indicates that the session is unmodified."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-workgroup-modified
 
  #("*" 0 1 (help-echo "The current workgroup is modified"))
 
  "Indicates that the current workgroup is modified."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-mode-line-decor-workgroup-unmodified
 
  #("-" 0 1 (help-echo "The current workgroup is unmodified"))
 
  "Indicates that the current workgroup is unmodified."
 
  :type 'string
 
  :group 'workgroups)
 

	
 

	
 
;; display customization
 

	
 
(defcustom wg-use-faces t
 
  "Non-nil means use faces in various displays."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-time-format "%H:%M:%S %A, %B %d %Y"
 
  "Format string for time display.  Passed to `format-time-string'."
 
  :type 'string
 
  :group 'workgroups)
 

	
 
(defcustom wg-display-battery t
 
  "Non-nil means include `battery', when available, in the time display."
 
  :type 'boolean
 
  :group 'workgroups)
 

	
 
(defcustom wg-list-display-decor-left-brace "( "
0 comments (0 inline, 0 general)