all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <jet@gyve.org>
Cc: emacs-devel@gnu.org
Subject: Re: ruler support in hexl mode
Date: Tue, 09 Mar 2004 21:11:19 +0900 (JST)	[thread overview]
Message-ID: <20040309.211119.169570100.jet@gyve.org> (raw)
In-Reply-To: <jwv65dfxi5i.fsf-monnier+emacs@asado.iro.umontreal.ca>

> > +(defcustom hexl-follow-line t
> > +  "If non-nil then highlight the line address corresponding to point."
> > +  :type 'boolean
> > +  :group 'hexl)
> 
> Any reason why you do not simply use hl-line-mode ?
> Or, better yet, let the user select hl-line-mode if he wants it?

Using hl-line-mode is good idea. However, hl-line-mode hides the
highlighted character associated with the point in ascii area. I will
put other face than highlight on the character associated with the
point.

> > +;; This function is derived from `ruler-mode-ruler' in ruler-mode.el.
> > +(defun hexl-mode-ruler ()
> > +  "Return a string ruler for hexl mode."
> > +  (when hexl-use-ruler
> > +    (let* ((fullw (ruler-mode-full-window-width))
> > +	   (w     (window-width))
> > +	   (m     (window-margins))
> > +	   (lsb   (ruler-mode-left-scroll-bar-cols))
> > +	   (lf    (ruler-mode-left-fringe-cols))
> > +	   (lm    (or (car m) 0))
> > +	   (ruler (make-string fullw ?\ ))
> 
> We really need to move this out of ruler-mode into frame.el or some other
> "global" file.  And to give it a clean interface so its implementation can
> be improved later.

Are You talking about each functions or generic ruler mechanism?

About former, I have inspect ruler-mode.el again.

    (let* ((w     (window-width))
           (m     (window-margins))
           (lsb   (ruler-mode-left-scroll-bar-cols))
           (lf    (ruler-mode-left-fringe-cols t))
           (lm    (or (car m) 0))
           (rsb   (ruler-mode-right-scroll-bar-cols))
           (rf    (ruler-mode-right-fringe-cols t))
           (rm    (or (cdr m) 0))
           (ruler (make-string w ruler-mode-basic-graduation-char))
           (i     0)
           (j     (window-hscroll))
           k c l1 l2 r2 r1 h1 h2 f1 f2)

Next two functions should be in "global" file:
ruler-mode-left-scroll-bar-cols and ruler-mode-left-fringe-cols.
I think these should be renamed to  scroll-bar-columns and 
fringe-columns. How do you think?

> > +	   (o     (+ lsb lf lm))
> > +	   (x o)
> > +	   (highlight (mod (hexl-current-address) 16)))
> > +      ;; "87654321"
> > +      (do ((i 8 (1- i)))
> > +	  ((= i 0))
> > +	(aset ruler x (aref (number-to-string i) 0))
> > +	(setq x (1+ x)))
> > +      ;; "87654321  "
> > +      (setq x (+ x 2))			; ": "
> > +      ;; "87654321  0011 2233 4455 6677 8899 aabb ccdd eeff"
> > +      (do* ((i 0 (1+ i))
> > +	    (c (format "%x" i) (format "%x" i)))
> > +	  ((= i 16))
> > +	(aset ruler x (aref c 0))
> > +	(setq x (1+ x))
> > +	(aset ruler x (aref c 0))
> > +	(setq x (1+ x))
> > +	(if (= highlight i)
> > +	    (put-text-property (- x 2) x 
> > +			       'face 'highlight
> > +			       ruler))
> > +	(when (= (mod i 2) 1) 
> > +	  (aset ruler x ?\ )
> > +	  (setq x (1+ x))))
> > +      ;; "87654321  0011 2233 4455 6677 8899 aabb ccdd eeff "
> > +      (setq x (1+ x))			; " "
> > +      ;; "87654321  0011 2233 4455 6677 8899 aabb ccdd eeff  0123456789abcdef"
> > +      (do* ((i 0 (1+ i))
> > +	    (c (format "%x" i) (format "%x" i)))
> > +	  ((= i 16))
> > +	(aset ruler x (aref c 0))
> > +	(setq x (1+ x))
> > +	(if (= highlight i)
> > +	    (put-text-property (1- x) x 
> > +			       'face 'highlight
> > +			       ruler)))
> > +      ruler)))
> 
> Isn't this always building the exact same string, except for the size
> (which really does not need to depend on the window's width), the leading
> space (to align it), and the highlighting of the current column?
> 
> Couldn't we just do (100% untested code, inspired from buff-menu.el):
...

After modifying a bit, your code works fine.

Masatake YAMATO

  reply	other threads:[~2004-03-09 12:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-05  5:29 ruler support in hexl mode Masatake YAMATO
2004-03-08 20:05 ` Stefan Monnier
2004-03-09 12:11   ` Masatake YAMATO [this message]
2004-03-11  6:59   ` Masatake YAMATO
2004-03-11 16:27   ` Kim F. Storm
2004-03-11 17:43     ` Stefan Monnier
2004-03-11 23:56       ` Kim F. Storm
2004-03-12  6:05         ` Masatake YAMATO
2004-03-12 21:24           ` Stefan Monnier
2004-03-13 18:13             ` Masatake YAMATO
2004-03-15  7:37               ` Masatake YAMATO
2004-03-15  4:55       ` Richard Stallman
2004-03-15 11:00         ` Kim F. Storm
2004-03-16 19:02           ` Richard Stallman
2004-03-17  0:08             ` Kim F. Storm
2004-03-17  0:42               ` Stefan Monnier
2004-03-17  2:23               ` Kim F. Storm
2004-03-19  5:01               ` Richard Stallman
2004-03-19 10:06                 ` Kim F. Storm
2004-03-19 13:33                   ` Kim F. Storm
2004-03-08 21:00 ` Miles Bader
2004-03-11 14:41   ` Juanma Barranquero
2004-03-17  3:59     ` Miles Bader
2004-03-18  0:53       ` Juanma Barranquero
2004-03-20  4:48         ` Richard Stallman
2004-03-22 11:52           ` Juanma Barranquero

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=20040309.211119.169570100.jet@gyve.org \
    --to=jet@gyve.org \
    --cc=emacs-devel@gnu.org \
    /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.