From: "Ehud Karni" <ehud@unix.mvs.co.il>
To: jbw@macs.hw.ac.uk
Cc: emacs-devel@gnu.org
Subject: Re: no good way to highlight rectangle while region is highlighted
Date: Thu, 26 Jul 2007 19:59:04 +0300 [thread overview]
Message-ID: <200707261659.l6QGx4id013794@beta.mvs.co.il> (raw)
In-Reply-To: <86bqe5fmf1.fsf@macs.hw.ac.uk> (message from Joe Wells on Sat, 21 Jul 2007 22:59:30 +0100)
On Sat, 21 Jul 2007 22:59:30, Joe Wells wrote:
>
> 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.
[snip]
> 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.
Below is my code to mark rectangles (blocks):
> 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.
I think a strong background color (I use red) is much better because
it can not be missed. A frame only (box) can be overlooked, especially
when the rectangle is greater than the screen size.
Ehud.
-------------------------- mark block code --------------------------
(defvar mark-1st nil "1st mark (ek) position,
a cons cell: (marker column-number) for all marks,
nil if not set")
(defvar mark-2nd nil "2nd mark (ek) position,
a cons cell: (marker column-number) for all marks,
nil if not set")
(defvar mark-overlay-list nil "list of mark overlays (unmark deletes them).")
(defvar mark-block-max-lines 500 "Maximum lines in block mark to face (color).
If the number of lines in the block mark is greater than this value don't make it visible.")
(defun visible-unmark () "Make marked area normal"
(mapc 'delete-overlay mark-overlay-list)
(setq mark-overlay-list nil))
(defun mark-set-face (FACE) "Set face of marked area to FACE (to mark only)"
(visible-unmark) ;; clear overlay if exist
(mark-block-check-swap) ;; ensure upper-left, bottom-right
(let* ((buf (set-buffer (marker-buffer (car mark-1st))))
(pos (point-marker)) ;; current position in buf
(m1 (marker-position (car mark-1st)))
(m2 (marker-position (car mark-2nd)))
)
(if (> (count-lines m1 m2) mark-block-max-lines)
(message "Block mark to large - not shown")
(let ((c1 (cdr mark-1st))
(c2 (1+ (cdr mark-2nd))))
(goto-char m1)
(setq m2 (min m2 (1- (point-max))))
(while (not (< m2 (point)))
(setq m1 (+ (point) c1))
(end-of-line)
(setq m1 (min m1 (point)))
(goto-col c2 t)
(mark-set-face-overlay m1 (point) buf FACE)
(forward-line)))))
(goto-char pos)) ;; restore position
(defun mark-set-face-overlay (BEG END BUF FACE)
"make-overlay BEG END in BUF, set its `face' to FACE and its priority to 99.
really FACE is always `MARK'. Add to mark-overlay-list (for unmarking)."
(let ((ov (make-overlay BEG END BUF nil t)))
(overlay-put ov 'face FACE)
(overlay-put ov 'priority 99)
(setq mark-overlay-list (append (list ov) mark-overlay-list))))
(defun mark-block-check-swap ()
"Block mark check (& swap) so mark-1st is set to upper left corner,
mark-2nd to right bottom corner."
(let ((tmp 0)
(p1 (car mark-1st))
(p2 (car mark-2nd))
(c1 (cdr mark-1st))
(c2 (cdr mark-2nd)))
(if (> (marker-position p1) (marker-position p2))
(progn
(setq tmp p1)
(setq p1 p2)
(setq p2 tmp)))
(if (> c1 c2)
(progn
(setq tmp c1)
(setq c1 c2)
(setq c2 tmp)))
(setq mark-1st (cons p1 c1))
(setq mark-2nd (cons p2 c2))))
(defun goto-col (arg &optional nospc)
"goto ARG (column number) on current line, add spaces if needed
optional NOSPC means don't add spaces at end of line"
(interactive "NGoto Column: ")
(end-of-line)
(let ((col-goto (- arg (column-no))))
(if nospc ()
(while (> col-goto 0)
(insert-char ?\040 1)
(setq col-goto (- col-goto 1))))
(if (< col-goto 0)
(goto-char (+ (point) col-goto)))))
(defun column-no (&optional arg)
"returns column number of point or arg (char number if given)"
(interactive "p")
(save-excursion
(if arg
(goto-char arg))
(let ((inhibit-field-text-motion))
(1+ (- (point) (line-beginning-position))))))
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
next prev parent reply other threads:[~2007-07-26 16:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707261659.l6QGx4id013794@beta.mvs.co.il \
--to=ehud@unix.mvs.co.il \
--cc=emacs-devel@gnu.org \
--cc=jbw@macs.hw.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.