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

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

Re: how to highlight the mark


From: Oliver Scholz
Subject: Re: how to highlight the mark
Date: Tue, 11 Nov 2003 11:43:28 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt)

Wim Yedema <yedema@natlab.research.philips.com> writes:

> Subject says it all really.  I want to highlight the mark kind of like 
> the cursor.

Barely tested:

(defvar wy-mark-overlay nil)
(make-variable-buffer-local 'wy-mark-overlay)

(defun wy-move-mark-overlay (pos)
  (move-overlay wy-mark-overlay pos (1+ pos)))

(define-minor-mode wy-highlight-mark-mode
  "Minor mode to highlight the mark."
  nil "wy-mark " nil
  (cond (wy-highlight-mark-mode
         ;; Turn mode on.
         (setq wy-mark-overlay (make-overlay (mark) (1+ (mark))))
         (overlay-put wy-mark-overlay 'face 'highlight))
        (t
         ;; Turn mode off.
         (delete-overlay wy-mark-overlay)
         (setq wy-mark-overlay nil))))

(defadvice set-mark (after wy-highlight-mark activate)
  (when wy-highlight-mark-mode
    (wy-move-mark-overlay (mark))))

It doesn't work well at the end of a line and at `point-max',
though.  I believe that would require hacking the display engine.
You are probably better off using `transient-mark-mode'.

    Oliver
-- 
21 Brumaire an 212 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

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