[Top][All Lists]

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

Re: ruler support in hexl mode

From: Stefan Monnier
Subject: Re: ruler support in hexl mode
Date: 12 Mar 2004 16:24:43 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> Based on Stefan and Kim's suggestions, I have revised the patch.
> I've moved the essential functions(`scroll-bar-columns' and `fringe-columns')
> in ruler-mode.el to frame.el and fringe.el and use new functions in
> ruler-mode.el and hexl.el.


> +(defcustom hexl-use-ruler t
> +  "If non-nil then show the ruler for hexl mode."
> +  :type 'boolean
> +  :group 'hexl)

I'd call it hexl-use-header-line, but maybe that's just me.

> +(defface hexl-ascii-overlay
> +  ;; Definition borrowed from vcursor.el.
> +  '((((class color)) (:foreground "blue" :background "cyan" :underline t))
> +    (t (:inverse-video t :underline t)))
> +  "Face for the overlay in ascii area of hexl mode buffer."
> +  :group 'hexl)

I'd call it `hexl-ascii-cursor' since the user might not know it's an
overlay (and it could actually be implemented as a text-property tomorrow).
Also I'd stick to just `:inverse-video' as much as possible or more
specifically I'd try to make it look just like the normal cursor (since
there's conceptually no difference between the two).

> +(defcustom hexl-follow-line t
> +  "If non-nil then turn `hl-line-mode' on."
> +  :type 'boolean
> +  :group 'hexl)
> +    (if hexl-follow-line  (hexl-follow-line 1)))
>    (run-hooks 'hexl-mode-hook))
> +(defun hexl-follow-line (&optional arg)
> +  "Toggle following line address in Hexl buffers.
> +With prefix ARG, turn on following if and only if ARG is positive.
> +When following is enabled, the line address corresponding to the
> +element under the point is highlighted.
> +Customize the variable `hexl-follow-line' to disable this feature."
> +  (interactive "P")
> +  (let ((on-p (if arg
> +               (> (prefix-numeric-value arg) 0)
> +             (not hexl-follow-line))))
> +
> +    (setq hexl-follow-line on-p)
> +    (hl-line-mode (if on-p 1 -1))))

You could define this with `define-minor-mode'.
But I'd recommend to go even further and replace the above with:

(defcustom hexl-mode-hook ()
  :type 'hook
  :options '(hexl-follow-line))

(defun hexl-follow-line ()
  (hl-line-mode 1))

-- Stefan

reply via email to

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