From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: Reducing mouse-dependency In Emacs. Date: Mon, 11 Aug 2003 20:29:58 -0500 (CDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200308120129.h7C1Tw621439@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1060652035 29295 80.91.224.253 (12 Aug 2003 01:33:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Aug 2003 01:33:55 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Aug 12 03:33:53 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mO2r-0001XY-00 for ; Tue, 12 Aug 2003 03:33:53 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19mOAM-0005lZ-00 for ; Tue, 12 Aug 2003 03:41:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mO1P-0006bA-VH for emacs-devel@quimby.gnus.org; Mon, 11 Aug 2003 21:32:23 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mO1J-0006ZB-F0 for emacs-devel@gnu.org; Mon, 11 Aug 2003 21:32:17 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mO0n-0006Em-RS for emacs-devel@gnu.org; Mon, 11 Aug 2003 21:32:16 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mO0m-0006ET-Mi for emacs-devel@gnu.org; Mon, 11 Aug 2003 21:31:44 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.9/8.12.9) with ESMTP id h7C1VheQ009848 for ; Mon, 11 Aug 2003 20:31:43 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id h7C1Tw621439; Mon, 11 Aug 2003 20:29:58 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:15890 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15890 Here are my highlighting functions for text-properties. You can do C-h C-k to highlight help-echo regions and C-u C-h C-k to remove the highlight. To make things more interesting, you should have adjacent regions with different non-nil help-echo properties. More generally, M-x highlight-text-property-regions will prompt for a property and two faces. Specifying nil for the first face will remove any highlight associated with the property. These functions are more meant to get an idea of "what is in the buffer" than for permanent highlighting. They do _not_ automatically set a timer to update. ===File ~/highlightprops.el================================= (defun highlight-text-property-regions (prop &optional face1 face2) "Highlight regions with non-nil text or overlay property PROP. Regions get highlighted using face1, except that adjacent regions with non-nil but different PROP properties get highlighted alternatively with face1 and face2. If face1 is nil, remove all highlighting. If face2 is nil, highlight all regions with face1." (interactive "SProperty to highlight: \nSMain face: \nSBackup face: ") (unless prop (error "PROP must be non-nil")) (let ((overlay-list (overlays-in (point-min) (point-max)))) (dolist (overlay overlay-list) (when (eq (overlay-get overlay 'highlight-text-property-regions) prop) (delete-overlay overlay)))) (if face1 (let ((pos (point-min)) (oldpos) (current-face face1) (change-face nil) (current-overlay)) (overlay-recenter (point-max)) (unless face2 (setq face2 face1)) (while (/= pos (point-max)) (if (get-char-property pos prop) (progn (setq oldpos pos) (setq pos (next-single-char-property-change pos prop)) (if change-face (setq current-face (if (eq current-face face1) face2 face1))) (setq current-overlay (make-overlay oldpos pos (current-buffer) t)) (overlay-put current-overlay 'face current-face) (overlay-put current-overlay 'highlight-text-property-regions prop) (setq change-face t)) (setq pos (next-single-char-property-change pos prop)) (setq change-face nil)))))) (defface help-echo-primary-face '((t (:background "yellow"))) "Used by `highlight-help-echo-regions' as its main face." :group 'faces) (defface help-echo-secondary-face '((t (:background "orange"))) "Used by `highlight-help-echo-regions' as its secondary face." :group 'faces) (defun highlight-help-echo-regions (&optional arg) "Highlight regions with non-nil help-echo-property. With a numeric argumenr, remove all such highlighting. Regions are normally highlighted with `help-echo-primary-face'. However, regions are highlighted with'help-echo-secondary-face', if necessary to distinguish them from adjacent regions. This is mainly useful for temporary highlighting, as it might override other highlighting. No automatic updating takes place." (interactive "P") (if arg (highlight-text-property-regions 'help-echo) (highlight-text-property-regions 'help-echo 'help-echo-primary-face 'help-echo-secondary-face))) (global-set-key "\C-h\C-k" 'highlight-help-echo-regions) ============================================================