all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* no good way to highlight rectangle while region is highlighted
@ 2007-07-21 21:59 Joe Wells
  2007-07-23  4:28 ` Richard Stallman
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Joe Wells @ 2007-07-21 21:59 UTC (permalink / raw)
  To: emacs-devel

Summary of this message: This is a feature request for (1) the
possibility that some overlays can have priority over the use of the
region face, and/or (2) a variant of the “box” face feature where the
vertical lines of the box take no extra space.

It started when I saw the “sense-region” package.  It contains some
code to make Emacs operations that normally operate on the region
switch between operating on the region and the rectangle.  When
operating on the region (in transient mark mode), the region is
highlighted.  When operating on the rectangle, the rectangle is
highlighted.

I didn't really want all of the features of sense-region, but I liked
the rectangle highlighting.  So I thought, wouldn't it be nice to be
able to have _both_ the region and the rectangle highlighted
simultaneously?  I've wanted something like this for a while for
multiple reasons.  One reason is that it makes it easier for me to
explain the rectangle commands to other users.  Another is that
something like this would be a big help with SES (Simple Emacs
Spreadsheet).

So I wrote some code to just use the rectangle highlighting code of
sense-region.el.  I ran into these problems in trying to highlight the
region and rectangle simultaneously:

1. The use of the “region” face for the region takes precedence over
   all overlays and text properties.  So it is not possible to change
   the background color of the rectangle because the region face sets
   the background for the portion of the rectangle inside the region.
   Using slightly different colors for the portion of the rectangle
   within the region and the portion outside the region would have
   been the nicest way of highlighting the rectangle.  However, there
   will be no way of doing this unless some overlays can be given
   priority over the region.

2. Using the “box” face feature (i.e., (set-face-attribute FACE nil
   :box '(:line-width -1 :color COLOR))) for the rectangle is
   problematic because there is no way to make the vertical lines not
   take space.  Using a negative dimension makes the horizontal lines
   (on top and bottom) not take space, but the vertical lines (on the
   left and right) do take space.  So every time the rectangle changes
   lots of text on the screen gets shifted around.  It would be nice
   if there was a way to make the vertical lines appear _within_ the
   space allocated for the text with the face.

3. Changing the foreground color of the rectangle just is not visually
   satisfactory, and overrides any colors provided by font-lock.

4. Using inverse video (i.e., (set-face-inverse-video-p FACE t)) for
   the rectangle is not visually satisfactory, and is anyway confusing
   at the boundaries of the rectangle due to the blinking box cursor
   which looks just like inverse video when it is on.

The most satisfactory alternative I have found is to use the stipple
feature.  I'm currently using this code:

  (set-face-stipple FACE '(12 12 "\000\010\000\004\000\002\000\001\200\000\100\000\040\000\020\000\010\000\004\000\002\000\001\000"))

This draws diagonal lines in the foreground color over the rectangle
from upper right to lower left that are 1 pixel wide and separated by
12 pixels.

But even using stipple is not really satisfactory as it is visually
difficult to locate the exact boundaries of the rectangle.

Any suggestions?  I'd like to use either background colors, or the box
face feature, but either of these would require changes to Emacs to
work acceptably.

By the way, *all* of the methods I have tried can't show a rectangle
of width 0.  But rectangles of width 0 are extremely useful with some
rectangle commands, and it would help to be able to show such
rectangles.

-- 
Joe

======================================================================

P.S.  Here is the code I am using with version 1.8 of sense-region.el,
so you can see how highlighting the rectangle works for yourself with
“M-x sense-region-on RET”:

;; I'm building on sense-region.el version 1.8 of 2002-05-23, because
;; I don't understand what version 1.9 is doing and all the
;; documentation is in Japanese and Google's translation doesn't make
;; much sense.  You can get version 1.8 in the recent Ubuntu versions
;; of the “sense-region” package:
;;
;;   http://archive.ubuntu.com/ubuntu/pool/universe/s/sense-region/sense-region_0.0.20020523.orig.tar.gz
;;
;; The file sense-region_2002-05-23.el on the author's web site is
;; actually a significantly later version from 2002-08-25, so don't get
;; that file.

(defun require-sense-region-if-found ()
  (or (require 'sense-region nil t)
      (require 'sense-region
               "/mnt/gentoo-portage/jbw/sense-region-0.0.20020523/sense-region.el"
               t)))

(require-sense-region-if-found)

(progn
  (make-face 'sense-region-face t)
  ;;(set-face-attribute 'sense-region-face nil :box '(:line-width -1 :color "red"))
  (set-face-attribute 'sense-region-face nil :box nil)
  ;;;; XOXOXOXO
  ;;;; OXOXOXOX
  ;;;; #o125 == #x55, #o252 == #xAA
  ;;(set-face-stipple 'sense-region-face '(8 2 "\125\252"))
  ;;;; XXO == 1 + 2 == 3
  ;;;; XOX == 1 + 4 == 5
  ;;;; OXX == 2 + 4 == 6
  ;;(set-face-stipple 'sense-region-face '(3 3 "\003\005\006"))
  ;;;; XOO == 1
  ;;;; OOX == 4
  ;;;; OXO == 2
  ;;(set-face-stipple 'sense-region-face '(3 3 "\001\004\002"))
  ;;;; XOOO == 1
  ;;;; OOOX == 8
  ;;;; OOXO == 4
  ;;;; OXOO == 2
  ;;(set-face-stipple 'sense-region-face '(4 4 "\001\010\004\002"))
  ;;;; XOOOO ==  1 == 001
  ;;;; OOOOX == 16 == 020
  ;;;; OOOXO ==  8 == 010
  ;;;; OOXOO ==  4 == 004
  ;;;; OXOOO ==  2 == 002
  ;;(set-face-stipple 'sense-region-face '(5 5 "\001\020\010\004\002"))
  ;;(set-face-stipple 'sense-region-face '(7 7 "\100\040\020\010\004\002\001"))
  (set-face-stipple 'sense-region-face '(8 8 "\200\100\040\020\010\004\002\001"))
  (set-face-stipple 'sense-region-face '(9 9 "\000\001\200\000\100\000\040\000\020\000\010\000\004\000\002\000\001\000"))
  (set-face-stipple 'sense-region-face '(11 11 "\000\004\000\002\000\001\200\000\100\000\040\000\020\000\010\000\004\000\002\000\001\000"))
  (set-face-stipple 'sense-region-face '(12 12 "\000\010\000\004\000\002\000\001\200\000\100\000\040\000\020\000\010\000\004\000\002\000\001\000"))
  ;;(set-face-stipple 'sense-region-face '(14 14 "\000\040\000\020\000\010\000\004\000\002\000\001\200\000\100\000\040\000\020\000\010\000\004\000\002\000\001\000"))
  (set-face-inverse-video-p 'sense-region-face nil)
  ;;(set-face-foreground 'sense-region-face "red")
  (set-face-background 'sense-region-face nil)
  (set-face-foreground 'sense-region-face nil)
  (setq sense-region-status 'rectangle))

(defadvice sense-region-on (around jbw-override-completely activate)
  (interactive)
  (if (featurep 'sense-region)
      (add-hook 'post-command-hook 'sense-region-redisplay)))

(defadvice sense-region-off (around jbw-override-completely activate)
  (interactive)
  (if (featurep 'sense-region)
      (sense-region-to-region))
  (remove-hook 'post-command-hook 'sense-region-redisplay))

(defadvice sense-region-to-region (around jbw-override-completely activate)
  (interactive)
  (mell-sign-rectangle-highlight-off sense-region-overlay-list)
  (setq sense-region-overlay-list nil))

======================================================================

P.P.S.  My Emacs version information:

In GNU Emacs 22.1.1 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
 of 2007-06-27 on artemis
Windowing system distributor `The X.Org Foundation', version 11.0.70000000
configured using `configure  '--prefix=/home/jbw/local2' '--enable-debug' '--disable-nls' '--with-x-toolkit=gtk' 'CFLAGS=-O0 -g3 -ggdb''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: jbw
  value of $LANG: nil
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  outline-minor-mode: t
  desktop-save-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  size-indication-mode: t
  line-number-mode: t
  transient-mark-mode: t

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-01-23 21:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-21 21:59 no good way to highlight rectangle while region is highlighted Joe Wells
2007-07-23  4:28 ` Richard Stallman
2007-07-23  7:46   ` Joe Wells
2007-07-23 22:30     ` Richard Stallman
2007-07-23 22:52       ` Joe Wells
2007-07-30 16:44         ` Richard Stallman
2007-07-30 17:04           ` Joe Wells
2008-01-23 21:25   ` overlays with higher priority than region [was: no good way to highlight rectangle while region is highlighted] Drew Adams
2007-07-23 17:55 ` no good way to highlight rectangle while region is highlighted Johan Bockgård
2007-07-26 16:59 ` Ehud Karni
2007-07-27  7:52   ` Joe Wells
2007-07-27  8:10     ` Ehud Karni
2007-07-27 13:27       ` Joe Wells
2007-07-27 19:43         ` Ehud Karni
2007-07-28  0:10           ` Joe Wells
2007-07-28 10:33             ` Ehud Karni
2007-07-27 13:36   ` Dan Nicolaescu

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.