From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.bugs Subject: bug#11095: [PATCH] Re: bug#11095: 24.0.94; hi-lock-face-buffer/unhighlight-regexp': Augment? Date: Thu, 11 Oct 2012 01:51:08 +0530 Message-ID: <87626i2i4r.fsf@gmail.com> References: <81d37z271c.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1349900438 18412 80.91.229.3 (10 Oct 2012 20:20:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2012 20:20:38 +0000 (UTC) To: 11095@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 10 22:20:44 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TM2ll-00048p-2a for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 22:20:41 +0200 Original-Received: from localhost ([::1]:54803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM2le-0008K4-PS for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 16:20:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM2lX-0008Jt-Jq for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2012 16:20:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TM2lR-0002sg-Pj for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2012 16:20:27 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM2lR-0002s2-Kt for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2012 16:20:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TM2m5-0003xL-NJ for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2012 16:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jambunathan K Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Oct 2012 20:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11095 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11095-submit@debbugs.gnu.org id=B11095.134990043115170 (code B ref 11095); Wed, 10 Oct 2012 20:21:01 +0000 Original-Received: (at 11095) by debbugs.gnu.org; 10 Oct 2012 20:20:31 +0000 Original-Received: from localhost ([127.0.0.1]:38100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TM2la-0003wd-Bg for submit@debbugs.gnu.org; Wed, 10 Oct 2012 16:20:31 -0400 Original-Received: from mail-pb0-f44.google.com ([209.85.160.44]:44071) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TM2lW-0003wL-FF for 11095@debbugs.gnu.org; Wed, 10 Oct 2012 16:20:28 -0400 Original-Received: by mail-pb0-f44.google.com with SMTP id ro8so1099687pbb.3 for <11095@debbugs.gnu.org>; Wed, 10 Oct 2012 13:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=7u4ttcuiBe1ES4PpVThyoMBBXcXpAoegFYAM7FxQcps=; b=mTEAn+vOj0znt8e4aqCRCEMCMK9g3HifGTOh+H/fmJsRySiJD833cVporpLbPFtpJD oXjguhtL1mZCFSZ8gSItFPpbDWFqnEN/vIY5CXLWIHXkdvLkFq7pOYrbxx4xO+FL7JCY qCvMcf9nsHICsyWGkeGr45j6p9xZoE2bvoB40m0UAHqMml2d5NJtFeP0MhLBgx79Y8v4 JROhirXXMvY60Jjgh/E8mjMeBcrBlsFolkqX+hTWsRAgyLefywqPrGAXMR6An+gJRuOf cSivyVItOTd3uMfLJtMaOw6+oQ+wHUvhVSQLq6TQd1tpic1auRFYd0CAXHY8QY3ebVY7 HWIg== Original-Received: by 10.66.85.4 with SMTP id d4mr65275727paz.11.1349900379938; Wed, 10 Oct 2012 13:19:39 -0700 (PDT) Original-Received: from debian-6.05 ([101.62.83.198]) by mx.google.com with ESMTPS id sj5sm1491979pbc.30.2012.10.10.13.19.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 13:19:39 -0700 (PDT) In-Reply-To: <81d37z271c.fsf@gmail.com> (Jambunathan K.'s message of "Mon, 26 Mar 2012 12:16:55 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:65472 Archived-At: --=-=-= Content-Type: text/plain I am attaching a patch that addresses Part-I/Item-1 below. The patch adds no functionality. It merely removes "color" from appearing verbatim in the face variables. I am using `hi-lock-' as prefix. Let me know if `highlight-' will be more appropriate (considering that there is a standard highlight face). --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug11095-part1.patch Content-Description: bug11095-part1.diff === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-10-10 14:45:26 +0000 +++ lisp/ChangeLog 2012-10-10 20:05:04 +0000 @@ -1,3 +1,14 @@ +2012-10-10 Jambunathan K + + * hi-lock.el (hi-yellow, hi-pink, hi-green, hi-blue, hi-black-b) + (hi-blue-b, hi-green-b, hi-red-b, hi-black-hb): Mark these faces + as obsolete. + (hi-lock-1, hi-lock-2, hi-lock-3, hi-lock-4, hi-lock-5, hi-lock-6) + (hi-lock-7, hi-lock-8, hi-lock-9): New faces. + (hi-lock-face-defaults, hi-lock-line-face-buffer) + (hi-lock-face-buffer, hi-lock-face-phrase-buffer): Propagate above + changes. + 2012-10-10 Kenichi Handa * select.el (xselect--encode-string): If a coding is specified for === modified file 'lisp/hi-lock.el' --- lisp/hi-lock.el 2012-10-07 00:27:31 +0000 +++ lisp/hi-lock.el 2012-10-10 20:01:23 +0000 @@ -140,7 +140,7 @@ patterns." :group 'hi-lock :group 'faces) -(defface hi-yellow +(defface hi-lock-1 '((((min-colors 88) (background dark)) (:background "yellow1" :foreground "black")) (((background dark)) (:background "yellow" :foreground "black")) @@ -149,13 +149,13 @@ patterns." "Default face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-pink +(defface hi-lock-2 '((((background dark)) (:background "pink" :foreground "black")) (t (:background "pink"))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-green +(defface hi-lock-3 '((((min-colors 88) (background dark)) (:background "green1" :foreground "black")) (((background dark)) (:background "green" :foreground "black")) @@ -164,40 +164,50 @@ patterns." "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-blue +(defface hi-lock-4 '((((background dark)) (:background "light blue" :foreground "black")) (t (:background "light blue"))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-black-b +(defface hi-lock-5 '((t (:weight bold))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-blue-b +(defface hi-lock-6 '((((min-colors 88)) (:weight bold :foreground "blue1")) (t (:weight bold :foreground "blue"))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-green-b +(defface hi-lock-7 '((((min-colors 88)) (:weight bold :foreground "green1")) (t (:weight bold :foreground "green"))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-red-b +(defface hi-lock-8 '((((min-colors 88)) (:weight bold :foreground "red1")) (t (:weight bold :foreground "red"))) "Face for hi-lock mode." :group 'hi-lock-faces) -(defface hi-black-hb +(defface hi-lock-9 '((t (:weight bold :height 1.67 :inherit variable-pitch))) "Face for hi-lock mode." :group 'hi-lock-faces) +(define-obsolete-face-alias 'hi-yellow 'hi-lock-1 "24.3") +(define-obsolete-face-alias 'hi-pink 'hi-lock-2 "24.3") +(define-obsolete-face-alias 'hi-green 'hi-lock-3 "24.3") +(define-obsolete-face-alias 'hi-blue 'hi-lock-4 "24.3") +(define-obsolete-face-alias 'hi-black-b 'hi-lock-5 "24.3") +(define-obsolete-face-alias 'hi-blue-b 'hi-lock-6 "24.3") +(define-obsolete-face-alias 'hi-green-b 'hi-lock-7 "24.3") +(define-obsolete-face-alias 'hi-red-b 'hi-lock-8 "24.3") +(define-obsolete-face-alias 'hi-black-hb 'hi-lock-9 "24.3") + (defvar hi-lock-file-patterns nil "Patterns found in file for hi-lock. Should not be changed.") @@ -207,8 +217,8 @@ patterns." (define-obsolete-variable-alias 'hi-lock-face-history 'hi-lock-face-defaults "23.1") (defvar hi-lock-face-defaults - '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b" - "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") + '("hi-lock-1" "hi-lock-2" "hi-lock-3" "hi-lock-4" "hi-lock-5" + "hi-lock-6" "hi-lock-7" "hi-lock-8" "hi-lock-9") "Default faces for hi-lock interactive functions.") ;;(dolist (f hi-lock-face-defaults) @@ -410,7 +420,7 @@ updated as you type." (hi-lock-regexp-okay (read-regexp "Regexp to highlight line" (car regexp-history))) (hi-lock-read-face-name))) - (or (facep face) (setq face 'hi-yellow)) + (or (facep face) (setq face 'hi-lock-1)) (unless hi-lock-mode (hi-lock-mode 1)) (hi-lock-set-pattern ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ? @@ -435,7 +445,7 @@ updated as you type." (hi-lock-regexp-okay (read-regexp "Regexp to highlight" (car regexp-history))) (hi-lock-read-face-name))) - (or (facep face) (setq face 'hi-yellow)) + (or (facep face) (setq face 'hi-lock-1)) (unless hi-lock-mode (hi-lock-mode 1)) (hi-lock-set-pattern regexp face)) @@ -457,7 +467,7 @@ updated as you type." (hi-lock-process-phrase (read-regexp "Phrase to highlight" (car regexp-history)))) (hi-lock-read-face-name))) - (or (facep face) (setq face 'hi-yellow)) + (or (facep face) (setq face 'hi-lock-1)) (unless hi-lock-mode (hi-lock-mode 1)) (hi-lock-set-pattern regexp face)) --=-=-= Content-Type: text/plain > Proposal is in two parts. Part-I deals with `hi-lock-face-buffer'. > Part-II deals with `unhighlight-regexp'. Part-III has a dump of the > current customization I have in my .emacs. > > I believe that my proposal is useful in general. So I request that it > be folded in to Emacs-24.1. > > Part-I: `hi-lock-face-buffer' & Co. > ---------------------------------- > > 1) Review the face names used in `hi-lock-face-defaults' and make the > faces customizable. The defaults may not look good on a user's his > own font-lock configuration. > > 2) Make `hi-lock-face-buffer' use a different face on each invocation. > > Here is a real-world usecase for the above request. > > As a programmer, I use highlighting to trace variable dependencies > within a function. For example, in the example below, after > highlighting the variables in __different__ faces, I will come to the > conclusion that "a" depends on "d" and "tmp". > > c = d; > b = c + tmp; > a = b; > > And I use this very often to track variables and how they get their > values from. > > If I were to use the default Emacs provided behaviour then I would > have to press M-n multiple times as I highlight more and more > symbols. (Typically I have 3-5 symbols highlighted before I turn off > highlighting.) > > See elisp snippet at the end of the mail. > > > Part-II: `unhighlight-regexp' > ------------------------------ > > See usecase in Part-I/Item-2 > > 1) I want to selectively turn-off highlighting for certain regexps > (arguably) that _specific_ highlighted regexp cursor is stationed on. > This would happen when I decide that I don't want to factor a > particular variable for my current refactoring exercise. > > I find the current behaviour of `unhighlight-regexp' slightly > tedious. > > 1. There is no completion for which regexp I want to unhighlight and > I have to circle through `hi-lock-interactive-patterns'. > > 2. Browsing the `hi-lock-interactive-patterns' is tedious for the > following reasons: > > - The order in which unhighlighting happens could totally be > unrelated to the order in which highlighting happens. When I am > analyzing the variable flow, I don't want to do a "context > switch" trying to find out what item to choose from the > `unhighlight-regexp' menu. > > 2) I want to unhighlight all regexps. This happens when I am done with > variable analysis. > > > ps: I am not questioning the current defaults. I am only saying that it > the current behaviour is too generic to be immediately useful (atleast > for my usecase) and so needs some sort of extra augmentation. > > Part-III: Elisp snippet > ----------------------- > > ;; Why should the color of the faces be encoded in the variable name? > ;; Seems counter-intutitive to me. I cannot relate to a hi-yellow > ;; face customized to render in red. > > ;; (defvar hi-lock-face-defaults > ;; '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b" > ;; "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") > ;; "Default faces for hi-lock interactive functions.") > > ;; So roll out my own face for highlighting. Make them > ;; __customizable__. Note that the name of the face doesn't say what > ;; the color of the highlight will be. Works for the color theme that > ;; I have. > (custom-set-faces > '(highlight1 ((t (:background "yellow" :foreground "black")))) > '(highlight2 ((t (:background "OrangeRed" :foreground "black")))) > '(highlight3 ((((class color) (background dark)) (:background "AntiqueWhite" :foreground "black")))) > '(highlight4 ((t (:background "SystemHotTrackingColor")))) > '(highlight5 ((t (:background "VioletRed" :foreground "black"))))) > > ;; override the Emacs default > (setq hi-lock-face-defaults > '("highlight1" "highlight2" "highlight3" "highlight4" "highlight5")) > > (defvar hi-lock-faces > (let ((l (copy-list hi-lock-face-defaults))) > (setcdr (last l) l)) > "Circular list of faces in `hi-lock-face-defaults'.") > > ;; make `hi-lock-faces' buffer local > (make-variable-buffer-local 'hi-lock-faces) > > (defun highlight-symbol () > "Highlight symbol at point. > For illustartion only. Note the use of `hi-lock-face-buffer'. > Choose a new face from `hi-lock-faces' on each invocation. > Overrides the default behaviour in vanilla Emacs which is to use > the face at the head of the list." > (interactive) > (hi-lock-face-buffer > (concat "\\_<" (regexp-quote (thing-at-point 'symbol)) "\\_>") > ;; rotate the face list > (prog1 (car hi-lock-faces) > (setq hi-lock-faces (cdr hi-lock-faces))))) > > (defun my-unhighlight-regexp (arg) > "Wrapper around `unhighlight-regexp'. > With a prefix argument, turn off all highlighting. > > TODO: Check if the symbol is right now on a highlighted regexp. > If yes, unhighlight only that regexp." > (interactive "P") > (if arg > (mapc (lambda (p) > (unhighlight-regexp (car p))) > hi-lock-interactive-patterns) > (call-interactively 'unhighlight-regexp))) --=-=-=--