bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#1779: 23.0.60; proced with variable-pitch header line


From: Stephen Berman
Subject: bug#1779: 23.0.60; proced with variable-pitch header line
Date: Tue, 07 Dec 2010 11:40:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

On Mon, 06 Dec 2010 00:30:17 +0100 Stephen Berman <stephen.berman@gmx.net> 
wrote:

> On Sun, 04 Jan 2009 03:23:53 -0500 Chong Yidong <cyd@stupidchicken.com> wrote:
>
>>> Proced does not align the attribute names in the header line with the
>>> corresponding columns when header-line face has variable pitch.
>>>
>>> I know of two approaches to dealing with this situation in Emacs, namely
>>> that of buff-menu.el and that of ibuffer.el.  The latter imposes a
>>> fixed-pitch face in the header line, overriding the
>>> user customization.  The former uses the display property with an
>>> :align-to specification to get proper alignment.  Maybe one of these
>>> will work with proced.el too.
>>
>> We can't use :align-to because proced justifies some headers to the
>> right hand side of the column.
>
> I (finally) took a look at this again and it appears that :align-to as
> used in buff-menu.el with some additional tweaking pretty much DTRT
> after all.  With my variable-pitch font (Dejavu Sans) I find the spacing
> between "%CPU" and "%Mem" too crowded; using fixed-pitch looks better,
> and that's what the attached patch does.  Alternatively, I think it
> looks fine to let the header line font be variable-pitch as long as the
> let-bound variable whitespace is set to two spaces.  I actually think
> this makes the proced listings also more legible, though it does leave
> less space for the process invocation listing and is also a departure
> from the Dired display that Proced is modelled on.  Anyway, I'd be happy
> with either approach; both are better than the current display when the
> header-line face is variable-pitch.

There was an oversight in my patch; the corrected version is below.
Also, I attach three screenshots: the first shows what the Proced
display generated by the current code looks like when the header line
face is variable-pitch, the second show the display using the below
patch (with the header line stretched and set to fixed-pitch), the third
shows the alternative mentioned above (with stretched variable-pitch
header line and added space).

Steve Berman

Attachment: proced_var.png
Description: Proced with unstretched variable-pitch header line

Attachment: proced_fixed.png
Description: Proced with stretched fixed-pitch header line

Attachment: proced_var2.png
Description: Proced with stretched variable-pitch header line

*** /data/steve/bzr/emacs/trunk/lisp/proced.el  2010-09-08 10:12:09.000000000 
+0200
--- /data/steve/bzr/emacs/quickfixes/lisp/proced.el     2010-12-07 
11:15:38.000000000 +0100
***************
*** 400,406 ****
    :group 'proced-faces)
  
  (defface proced-sort-header
!   '((t (:inherit font-lock-keyword-face)))
    "Face used for header of attribute used for sorting."
    :group 'proced-faces)
  
--- 400,406 ----
    :group 'proced-faces)
  
  (defface proced-sort-header
!   '((t (:family "Monospace" :inherit font-lock-keyword-face)))
    "Face used for header of attribute used for sorting."
    :group 'proced-faces)
  
***************
*** 1427,1433 ****
               (hprops
                (if (nth 4 grammar)
                    (let ((descend (if (eq key sort-key) proced-descend (nth 5 
grammar))))
!                     `(proced-key ,key mouse-face highlight
                                   help-echo ,(format proced-header-help-echo
                                                      (if descend "-" "+")
                                                      (nth 1 grammar)
--- 1427,1433 ----
               (hprops
                (if (nth 4 grammar)
                    (let ((descend (if (eq key sort-key) proced-descend (nth 5 
grammar))))
!                     `(proced-key ,key face fixed-pitch mouse-face highlight
                                   help-echo ,(format proced-header-help-echo
                                                      (if descend "-" "+")
                                                      (nth 1 grammar)
***************
*** 1509,1514 ****
--- 1509,1525 ----
      (if (string-match "[ \t]+$" proced-header-line)
          (setq proced-header-line (substring proced-header-line 0
                                              (match-beginning 0))))
+     (setq proced-header-line (concat "  " proced-header-line))
+     ;; From buff-menu.el: Turn whitespace chars in the header into stretch
+     ;; specs so they work regardless of the header-line face.
+     (let ((pos 0)
+         (header proced-header-line))
+       (while (string-match "[ \t\n]+" header pos)
+         (setq pos (match-end 0))
+         (put-text-property (match-beginning 0) pos 'display
+                            ;; Assume fixed-size chars in the buffer.
+                            (list 'space :align-to pos)
+                            header)))
      ;; (delete-trailing-whitespace)
      (goto-char (point-min))
      (while (re-search-forward "[ \t\r]+$" nil t)
***************
*** 1602,1608 ****
      (while (not (eobp))
        (insert "  ")
        (forward-line))
-     (setq proced-header-line (concat "  " proced-header-line))
      (if revert (set-buffer-modified-p nil))
  
      ;; set `goal-column'
--- 1613,1618 ----

reply via email to

[Prev in Thread] Current Thread [Next in Thread]