From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: ruler support in hexl mode Date: Tue, 09 Mar 2004 21:11:19 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040309.211119.169570100.jet@gyve.org> References: <20040305.142915.63122255.jet@gyve.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1079221704 13915 80.91.224.253 (13 Mar 2004 23:48:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 13 Mar 2004 23:48:24 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Mar 14 00:48:16 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B2IrY-0001KX-00 for ; Sun, 14 Mar 2004 00:48:16 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B2IrY-0002g5-00 for ; Sun, 14 Mar 2004 00:48:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B1TuG-00040R-MS for emacs-devel@quimby.gnus.org; Thu, 11 Mar 2004 12:23:40 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B0g6D-0003AE-Ml for emacs-devel@gnu.org; Tue, 09 Mar 2004 07:12:41 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B0g5f-00035Q-4v for emacs-devel@gnu.org; Tue, 09 Mar 2004 07:12:38 -0500 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B0g55-0002zR-PM for emacs-devel@gnu.org; Tue, 09 Mar 2004 07:11:31 -0500 Original-Received: from localhost (nat-pool.jp.redhat.com [219.120.63.249]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id i29CBJV14819; Tue, 9 Mar 2004 21:11:20 +0900 (JST) Original-To: monnier@iro.umontreal.ca In-Reply-To: X-Mailer: Mew version 4.0.62 on Emacs 21.3.50 / Mule 5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20413 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20413 > > +(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