From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joe Wells Newsgroups: gmane.emacs.devel Subject: Re: no good way to highlight rectangle while region is highlighted Date: Sat, 28 Jul 2007 01:10:26 +0100 Message-ID: <86k5slwfpp.fsf@macs.hw.ac.uk> References: <200707261659.l6QGx4id013794@beta.mvs.co.il> <86sl7awafj.fsf@macs.hw.ac.uk> <200707270810.l6R8AF90032324@beta.mvs.co.il> <86odhyvuwa.fsf@macs.hw.ac.uk> <200707271943.l6RJhf8m010409@beta.mvs.co.il> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1185581421 27447 80.91.229.12 (28 Jul 2007 00:10:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 28 Jul 2007 00:10:21 +0000 (UTC) Cc: emacs-devel@gnu.org To: ehud@unix.mvs.co.il Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 28 02:10:15 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IEZsn-00011p-Jd for ged-emacs-devel@m.gmane.org; Sat, 28 Jul 2007 02:10:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IEZsm-0002c2-Lm for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2007 20:10:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IEZsi-0002Xl-Fl for emacs-devel@gnu.org; Fri, 27 Jul 2007 20:10:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IEZsg-0002T5-VA for emacs-devel@gnu.org; Fri, 27 Jul 2007 20:10:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IEZsg-0002Sp-M0 for emacs-devel@gnu.org; Fri, 27 Jul 2007 20:10:02 -0400 Original-Received: from izanami.macs.hw.ac.uk ([137.195.13.6]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IEZsg-0004L4-12 for emacs-devel@gnu.org; Fri, 27 Jul 2007 20:10:02 -0400 Original-Received: from lxultra1.macs.hw.ac.uk ([137.195.27.173]:35526 helo=127.0.0.1) by izanami.macs.hw.ac.uk with smtp (Exim 4.51) id 1IEZsc-0001wi-CD; Sat, 28 Jul 2007 01:09:58 +0100 Original-Received: (nullmailer pid 15465 invoked by uid 1001); Sat, 28 Jul 2007 00:10:26 -0000 In-Reply-To: <200707271943.l6RJhf8m010409@beta.mvs.co.il> (Ehud Karni's message of "Fri\, 27 Jul 2007 22\:43\:41 +0300") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:75732 Archived-At: "Ehud Karni" writes: > On Fri, 27 Jul 2007 14:27:49, Joe Wells wrote: >> >> "Ehud Karni" writes: >> >> > The overlay is set to priority 99 and I sure see it OVER the region. >> >> How is this possible? From (info "(elisp)Displaying Faces"): >> >> "If these various sources together specify more than one face for a >> particular character, Emacs merges the attributes of the various faces > ^^^^^^ >> specified. For each attribute, Emacs tries first the face of any >> special glyph; then the face for region highlighting, if appropriate; >> then the faces specified by overlays, followed by those specified by >> text properties, then the `mode-line' or `mode-line-inactive' or >> `header-line' face (if in a mode line or a header line), and last the >> `default' face." >> >> So the only faces which can override the "region" face are the faces >> for glyphs set with display tables. Overlays can't do that. Because >> the default "region" face sets a background color, there is no way an >> overlay can override the background color of the region. > > I think the keyword is "merges" that you somehow ignored. Hi, Ehud, My reading of the documentation (supplemented by my perusal of the Emacs C source code) for =E2=80=9Cmerging=E2=80=9D of face F1 and face F2 i= s that it is not a symmetric operation and one of the faces takes priority. In the case of distinct face attributes, both are used; this means if face F1 has value V1 for attribute A1 and face F2 has value V2 for attribute A2, then you get a new face with V1 for A1 and V2 for A2. In the case of assignments for the same face attribute, only one is used; assuming face F1 has priority, if face F1 has value V1 for attribute A0 and face F2 has value V2 for the same attribute A0, then value V1 is used. Note that there is no notion of merging of colors. One of the two colors is always used, unchanged. My reading of the above-quoted documentation is that the =E2=80=9Cregion=E2= =80=9D face always takes priority over all overlays (regardless of the overlay's =E2=80=9Cpriority=E2=80=9D property), text properties, and the default face= . Given that the default value of the =E2=80=9Cregion=E2=80=9D face sets the :backg= round attribute, this means that any :background attribute set by any overlay or text property or the default face is ignored in the area covered by the region when it is being highlighted. I have done testing that agrees with this. Although I had no reason to believe they would make any difference, I just now tried overlay priorities anyway and verified that overlay priorities make no difference whatsoever in this matter. No matter how high the overlay priority, the background color of the overlay's face can not override the background color of the =E2=80=9Cregion=E2=80=9D face (and no attempt a= t color combination occurs). I even tried most-positive-fixnum as the overlay priority (and you can't get any higher than that). So basically, unless you are working with some Emacs C code which differs from Emacs 22.1 in how this is handled, what you are saying about overlay faces overriding the region face is simply not true. My latest testing code is appended below, so you can check for yourself. >> Anyway, I couldn't try your code because it is incomplete. As far as >> I can tell, the entry point in what you supplied is mark-set-face and >> this merely raises an error because there is no code to assign values >> to the variables mark-1st and mark-2nd that it depends on. > > The code is a small part of a much larger (1320 lines) package. > > Here is sample code to set mark-1st to current cursor position. > (setq mark-1st (cons > (save-excursion (beginning-of-line) (point-marker)) > (col (1- (column-no))))) I am only interested in seeing how it might be able to highlight the current rectangle (simultaneously with the current region being highlighted by Emacs's built in mechanism). Do you have code to illustrate that? Right now, you are supplying less than what I already have. --=20 Joe P.S. Here is my testing code (which now tries to set a background color for the overlay faces and sets the priority of these overlays as high as possible): ;; 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 =E2=80=9Csense-region=E2=80=9D package (it is the only file in th= is .tar.gz ;; file): ;; ;; http://archive.ubuntu.com/ubuntu/pool/universe/s/sense-region/sense-re= gion_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. ;; *** TODO: Switch this to using the rectangle highlighting code from ;; cua-rect.el which now comes in Emacs (since 22.1). (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-reg= ion.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 =3D=3D #x55, #o252 =3D=3D #xAA ;;(set-face-stipple 'sense-region-face '(8 2 "\125\252")) ;;;; XXO =3D=3D 1 + 2 =3D=3D 3 ;;;; XOX =3D=3D 1 + 4 =3D=3D 5 ;;;; OXX =3D=3D 2 + 4 =3D=3D 6 ;;(set-face-stipple 'sense-region-face '(3 3 "\003\005\006")) ;;;; XOO =3D=3D 1 ;;;; OOX =3D=3D 4 ;;;; OXO =3D=3D 2 ;;(set-face-stipple 'sense-region-face '(3 3 "\001\004\002")) ;;;; XOOO =3D=3D 1 ;;;; OOOX =3D=3D 8 ;;;; OOXO =3D=3D 4 ;;;; OXOO =3D=3D 2 ;;(set-face-stipple 'sense-region-face '(4 4 "\001\010\004\002")) ;;;; XOOOO =3D=3D 1 =3D=3D 001 ;;;; OOOOX =3D=3D 16 =3D=3D 020 ;;;; OOOXO =3D=3D 8 =3D=3D 010 ;;;; OOXOO =3D=3D 4 =3D=3D 004 ;;;; OXOOO =3D=3D 2 =3D=3D 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\00= 1")) (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\20= 0\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\00= 0\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 t) (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-background 'sense-region-face "red") (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)) (defadvice mell-transient-region-active-p (around jbw-handle-delayed-mark-d= eactivation activate) "Need to make sure (eq deactivate-mark t) taken as a sign the region is not active (this is a bug in sense-region.el)." (if deactivate-mark nil ad-do-it)) ;; This function is copied from version 1.8 of sense-region.el and ;; modified by inserting the commented sexp. (defun mell-sign-rectangle-highlight (start end &optional buffer face) (save-excursion (or buffer (setq buffer (current-buffer))) (mapcar '(lambda (region) (prog1 (setq overlay (make-overlay (car region) (cdr region) buffer nil t)) ;; jbw: inserted next sexp (only difference from version 1.8) (overlay-put overlay 'priority most-positive-fixnum) (overlay-put overlay 'face (or face 'highlight)) (overlay-put overlay 'evaporate t) )) (mell-region-get-visible-rectangle-list start end)) ; (mell-region-get-rectangle-list start end)) ))