]> code.delx.au - gnu-emacs/commitdiff
* ibuf-macs.el (define-ibuffer-column): Add a new key:
authorDan Nicolaescu <dann@ics.uci.edu>
Sun, 2 Apr 2006 19:17:34 +0000 (19:17 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Sun, 2 Apr 2006 19:17:34 +0000 (19:17 +0000)
header-mouse-map.

* ibuffer.el (ibuffer-name-header-map, ibuffer-size-header-map)
(ibuffer-mode-header-map): New keymaps.
(ibuffer-update-title-and-summary): Enable mouse face highlighting
and keybindings for column headers.
(name,size,mode) <define-ibuffer-column>: Add a header-mouse-map
property.

lisp/ChangeLog
lisp/ibuf-macs.el
lisp/ibuffer.el

index 98ddbf601d3e2df2b13afc435c250d2a0ac6dbf6..a265db673691e2cb8627513d2a0f07bbfed0a13b 100644 (file)
@@ -1,3 +1,15 @@
+2006-04-02  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * ibuf-macs.el (define-ibuffer-column): Add a new key:
+       header-mouse-map. 
+
+       * ibuffer.el (ibuffer-name-header-map, ibuffer-size-header-map)
+       (ibuffer-mode-header-map): New keymaps.
+       (ibuffer-update-title-and-summary): Enable mouse face highlighting
+       and keybindings for column headers.
+       (name,size,mode) <define-ibuffer-column>: Add a header-mouse-map
+       property.
+
 2006-04-02  Drew Adams  <drew.adams@oracle.com>  (tiny change)
 
        * speedbar.el (speedbar-after-create-hook): Doc fix.
index 38fee1b56c1a6ba37e9b08b9a0ddbed7eb54050e..603ffc45c9396a6ee022f7face440f07266808f8 100644 (file)
@@ -75,8 +75,8 @@ During evaluation of body, bind `it' to the value returned by TEST."
 ;; (put 'ibuffer-save-marks 'lisp-indent-function 0)
 
 ;;;###autoload
-(defmacro* define-ibuffer-column (symbol (&key name inline props
-                                              summarizer) &rest body)
+(defmacro* define-ibuffer-column (symbol (&key name inline props summarizer 
+                                              header-mouse-map) &rest body)
   "Define a column SYMBOL for use with `ibuffer-formats'.
 
 BODY will be called with `buffer' bound to the buffer object, and
@@ -115,6 +115,7 @@ change its definition, you should explicitly call
            ,(if (stringp name)
                 name
               (capitalize (symbol-name symbol))))
+       ,(if header-mouse-map `(put (quote ,sym) 'header-mouse-map ,header-mouse-map))
        ,(if summarizer
            ;; Store the name of the summarizing function.
            `(put (quote ,sym) 'ibuffer-column-summarizer
index 179c7b334bd2cf391a2fadafc04030dae532f769..0a84f9b0c822d5562a1c07848a9e129283c35fde 100644 (file)
@@ -829,6 +829,21 @@ directory, like `default-directory'."
     (define-key map (kbd "RET") 'ibuffer-interactive-filter-by-mode)
     map))
 
+(defvar ibuffer-name-header-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(mouse-1)] 'ibuffer-do-sort-by-alphabetic)
+    map))
+
+(defvar ibuffer-size-header-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(mouse-1)] 'ibuffer-do-sort-by-size)
+    map))
+
+(defvar ibuffer-mode-header-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(mouse-1)] 'ibuffer-do-sort-by-major-mode)
+    map))
+
 (defvar ibuffer-mode-filter-group-map
   (let ((map (make-sparse-keymap)))
     (define-key map [(mouse-1)] 'ibuffer-mouse-toggle-mark)
@@ -1666,6 +1681,7 @@ If point is on a group name, this function operates on that group."
 
 (define-ibuffer-column name
   (:inline t
+   :header-mouse-map ibuffer-name-header-map
    :props
    ('mouse-face 'highlight 'keymap ibuffer-name-map
                'ibuffer-name-column t
@@ -1682,6 +1698,7 @@ If point is on a group name, this function operates on that group."
 
 (define-ibuffer-column size
   (:inline t
+   :header-mouse-map ibuffer-size-header-map
    :summarizer
    (lambda (column-strings)
      (let ((total 0))
@@ -1695,6 +1712,7 @@ If point is on a group name, this function operates on that group."
 
 (define-ibuffer-column mode
   (:inline t
+   :header-mouse-map ibuffer-mode-header-map
    :props
    ('mouse-face 'highlight
                'keymap ibuffer-mode-name-map
@@ -2009,12 +2027,18 @@ the value of point at the beginning of the line for that buffer."
                  (setq min (- min)))
                (let* ((name (or (get sym 'ibuffer-column-name)
                                 (error "Unknown column %s in ibuffer-formats" sym)))
-                      (len (length name)))
-                 (if (< len min)
-                     (ibuffer-format-column name
-                                            (- min len)
-                                            align)
-                   name))))))
+                      (len (length name))
+                      (hmap (get sym 'header-mouse-map))
+                      (strname (if (< len min)
+                                   (ibuffer-format-column name
+                                                          (- min len)
+                                                          align)
+                                 name)))
+                 (when hmap
+                   (setq
+                    strname 
+                    (propertize strname 'mouse-face 'highlight 'keymap hmap)))
+                 strname)))))
         (add-text-properties opos (point) `(ibuffer-title-header t))
         (insert "\n")
         ;; Add the underlines