all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: Stefan Monnier <monnier+gnu/emacs@rum.cs.yale.edu>
Subject: Re: Ibuffer as default
Date: Tue, 11 Mar 2003 14:13:58 -0500	[thread overview]
Message-ID: <200303111913.h2BJDwGD012343@rum.cs.yale.edu> (raw)
In-Reply-To: buok7f6qodq.fsf@mcspd15.ucom.lsi.nec.co.jp

> > I recently changed it to work better, especially for relatively
> > default cases like emacs -nw and Emacs under X with a left-sided
> > scrollbar and left-sided fringe (before it just used one space char
> > regardless).  But it seems doomed to lose given unusual settings.  Is
> > there a straight-forward way to cons up pixel-perfect spacing, say as
> > a display property ?
> 
> Yeah, given the popularity of using it for showing aligned stuff, there
> definitively should at least be an option for the header-line to start
> exactly at the text's left edge.  This could even be something as simple
> as a boolean variable I think, or a magic `%' escape in
> header-line-format.

Agreed.
BTW, I suspect that the `spaces' calculation should ideally
be enhanced to take into account window margins rather than only
scrollbars and fringes.... clearly this is a nightmare and should
be solved in a cleaner way.

> Stefan's problem (different font) seems a lot harder though...

How 'bout the patch below ?
Note that it doesn't address the problem of the leading space
being different in different frames and that it wouldn't be
able to use a % magic thingy either.


	Stefan


--- buff-menu.el.~1.60.~	Mon Mar 10 17:59:02 2003
+++ buff-menu.el	Mon Mar 10 18:49:43 2003
@@ -547,6 +547,9 @@
 		       ? )
 	  size))
 
+(defvar Buffer-menu-header-line nil)
+(put 'Buffer-menu-header-line 'risky-local-variable t)
+
 (defun list-buffers-noselect (&optional files-only)
   "Create and return a buffer with a list of names of existing buffers.
 The buffer is named `*Buffer List*'.
@@ -557,9 +560,31 @@
   (let* ((old-buffer (current-buffer))
 	 (standard-output standard-output)
 	 (mode-end (make-string (- Buffer-menu-mode-width 2) ? ))
-	 (header (concat "CRM " (Buffer-menu-buffer+size "Buffer" "Size")
+	 (header (concat (propertize "CRM " 'face 'fixed-pitch)
+			 (Buffer-menu-buffer+size "Buffer" "Size")
 			 "  Mode" mode-end "File\n"))
 	 list desired-point name file mode)
+    (when Buffer-menu-use-header-line
+      (let ((spaces
+	     (/ (+ 0.0 (or (frame-parameter nil 'left-fringe) 0)
+		   (or (if (eq (frame-parameter nil 'vertical-scroll-bars)
+			       'left)
+			   (frame-parameter nil 'scroll-bar-width))
+		       0))
+		(frame-char-width)))
+	    (pos 0))
+	;; Turn spaces in the header into stretch specs so they work
+	;; regardless of the header-line face.
+	(while (string-match "[ \t]+" header pos)
+	  (setq pos (match-end 0))
+	  (put-text-property (match-beginning 0) pos 'display
+			     ;; Assume fixed-size chars
+			     (list 'space :align-to (+ spaces pos))
+			     header))
+	;; Add the leading space
+	(setq header (concat (propertize (make-string (floor spaces) ? )
+					 'display (list 'space :width spaces))
+			     header))))
     (save-excursion
       (set-buffer (get-buffer-create "*Buffer List*"))
       (setq buffer-read-only nil)
@@ -639,15 +664,7 @@
 	(princ "\n"))
       (Buffer-menu-mode)
       (when Buffer-menu-use-header-line
-	(let ((spaces
-	       (/ (+ (or (frame-parameter nil 'left-fringe) 0)
-		     (or (if (eq (frame-parameter nil 'vertical-scroll-bars)
-				 'left)
-			     (frame-parameter nil 'scroll-bar-width))
-			 0))
-		  (frame-char-width))))
-	  (set (make-local-variable 'Buffer-menu-header-line)
-	       (concat (make-string spaces ? ) header)))
+	(set (make-local-variable 'Buffer-menu-header-line) header)
 	(setq header-line-format 'Buffer-menu-header-line))
       ;; DESIRED-POINT doesn't have to be set; it is not when the
       ;; current buffer is not displayed for some reason.

  reply	other threads:[~2003-03-11 19:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-10 23:28 Ibuffer as default Stefan Monnier
2003-03-11  7:47 ` John Paul Wallington
2003-03-11  8:49   ` Miles Bader
2003-03-11 19:13     ` Stefan Monnier [this message]
2003-03-11 18:36 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200303111913.h2BJDwGD012343@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.