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: Tue, 11 Dec 2012 02:07:58 +0530 Message-ID: <87lid57ie1.fsf@gmail.com> References: <81d37z271c.fsf@gmail.com> <87626i2i4r.fsf@gmail.com> <87zk1r3h3b.fsf@gmail.com> <87lidaan4g.fsf@gmail.com> <87a9tq6cs5.fsf@gmail.com> <87sj7iii4f.fsf@gmail.com> <87pq2k6744.fsf@gmail.com> <87ip8a352w.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1355171734 4935 80.91.229.3 (10 Dec 2012 20:35:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Dec 2012 20:35:34 +0000 (UTC) Cc: 11095-done@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 10 21:35:47 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 1TiA4m-0006mX-3j for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Dec 2012 21:35:44 +0100 Original-Received: from localhost ([::1]:39794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiA4Z-0002E1-Fq for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Dec 2012 15:35:31 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiA4V-0002Ds-CW for bug-gnu-emacs@gnu.org; Mon, 10 Dec 2012 15:35:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiA4T-0007su-Ii for bug-gnu-emacs@gnu.org; Mon, 10 Dec 2012 15:35:27 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiA4T-0007si-Dh for bug-gnu-emacs@gnu.org; Mon, 10 Dec 2012 15:35:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TiA54-00056S-1Z for bug-gnu-emacs@gnu.org; Mon, 10 Dec 2012 15:36:02 -0500 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: Mon, 10 Dec 2012 20:36:02 +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: patch Original-Received: via spool by 11095-done@debbugs.gnu.org id=D11095.135517173719582 (code D ref 11095); Mon, 10 Dec 2012 20:36:02 +0000 Original-Received: (at 11095-done) by debbugs.gnu.org; 10 Dec 2012 20:35:37 +0000 Original-Received: from localhost ([127.0.0.1]:35921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiA4e-00055m-9L for submit@debbugs.gnu.org; Mon, 10 Dec 2012 15:35:36 -0500 Original-Received: from mail-pa0-f44.google.com ([209.85.220.44]:40590) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiA4a-00055d-Nk for 11095-done@debbugs.gnu.org; Mon, 10 Dec 2012 15:35:34 -0500 Original-Received: by mail-pa0-f44.google.com with SMTP id hz11so2260347pad.3 for <11095-done@debbugs.gnu.org>; Mon, 10 Dec 2012 12:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=X9fc5sLof62gKpXoxKNpf9syQWo8eBHBrhclWS+3f2w=; b=jXIz/L0nyhILEx0PgyRmoGDAqVjoTVK4BHiusxSYz7nnv7PZM8/xZSFFTLO18AT6DR X4q0f8YmCjDwGMJUSbHmQeR8M9KqFqPBCmAwSPWeydvdu/GS57H/ReKerHWmVOitWRyw NZ2Qey3+xPYlAffhnlfgc+P7WSlCBpdMvwKox5jmOLfGbYQwsUwlz4ZLXh4MV3f0cF/V UArJoNibrKKZsaTlX2NHv1LpVZ+hKNLa7VuLliLIlER52Pbzt96vyRkfmom4LYYm8VXQ SuTmOUw2l7ZOPhK277PXzR4jxMPQz8K3xy6WJgcOhjPwRirPhyJOHBG6w+IVORia5CGv OjVw== Original-Received: by 10.68.204.103 with SMTP id kx7mr42555094pbc.33.1355171694910; Mon, 10 Dec 2012 12:34:54 -0800 (PST) Original-Received: from debian-6.05 ([101.62.41.16]) by mx.google.com with ESMTPS id ir4sm5951426pbc.41.2012.12.10.12.34.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 10 Dec 2012 12:34:54 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Mon, 10 Dec 2012 13:34:25 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.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.x 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:68291 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> This patch makes sure that faces used for highlighting are always >> distinct and recycles them only when it is inevitable. > > Installed with 2 changes: > - replace "delete" with "remove" because it was applied to a list which > is reachable from other places (basically, from other buffer's > hi-lock--unused-faces). Attaching a patch with following changes. (This is the last lap) 1. Fix following bug when `font-lock-mode' is disabled. ,---- | Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) | buffer-substring-no-properties(nil nil) | (let* ((hi-text (buffer-substring-no-properties (previous-single-property-change (point) (quote face)) (next-single-property-change (point) (quote face))))) (progn (let ((--dolist-tail-- hi-lock-interactive-patterns)) (while --dolist-tail-- (let ((hi-lock-pattern (car --dolist-tail--))) (let ((regexp ...)) (if (string-match regexp hi-text) (setq regexps ...))) (setq --dolist-tail-- (cdr --dolist-tail--))))))) | (and (memq (face-at-point) (mapcar (function hi-lock-keyword->face) hi-lock-interactive-patterns)) (let* ((hi-text (buffer-substring-no-properties (previous-single-property-change (point) (quote face)) (next-single-property-change (point) (quote face))))) (progn (let ((--dolist-tail-- hi-lock-interactive-patterns)) (while --dolist-tail-- (let ((hi-lock-pattern ...)) (let (...) (if ... ...)) (setq --dolist-tail-- (cdr --dolist-tail--)))))))) | (let ((regexps (quote nil))) (let ((regexp (get-char-property (point) (quote hi-lock-overlay-regexp)))) (if regexp (progn (setq regexps (cons regexp regexps))))) (and (memq (face-at-point) (mapcar (function hi-lock-keyword->face) hi-lock-interactive-patterns)) (let* ((hi-text (buffer-substring-no-properties (previous-single-property-change (point) (quote face)) (next-single-property-change (point) (quote face))))) (progn (let ((--dolist-tail-- hi-lock-interactive-patterns)) (while --dolist-tail-- (let (...) (let ... ...) (setq --dolist-tail-- ...))))))) regexps) | hi-lock--regexps-at-point() | (or (hi-lock--regexps-at-point) (mapcar (function car) hi-lock-interactive-patterns)) | (let* ((defaults (or (hi-lock--regexps-at-point) (mapcar (function car) hi-lock-interactive-patterns)))) (list (completing-read (if (null defaults) "Regexp to unhighlight: " (format "Regexp to unhighlight (default %s): " (car defaults))) hi-lock-interactive-patterns nil t nil nil defaults))) | (cond (current-prefix-arg (list t)) ((and (display-popup-menus-p) (listp last-nonmenu-event) use-dialog-box) (catch (quote snafu) (or (x-popup-menu t (cons (quote keymap) (cons "Select Pattern to Unhighlight" (mapcar ... hi-lock-interactive-patterns)))) (throw (quote snafu) (quote ("")))))) (t (if hi-lock-interactive-patterns nil (error "No highlighting to remove")) (let* ((defaults (or (hi-lock--regexps-at-point) (mapcar (function car) hi-lock-interactive-patterns)))) (list (completing-read (if (null defaults) "Regexp to unhighlight: " (format "Regexp to unhighlight (default %s): " (car defaults))) hi-lock-interactive-patterns nil t nil nil defaults))))) | call-interactively(unhighlight-regexp nil nil) `---- 2. Add a NEWS entry. 3. Re-works how hi-lock--unused-faces is allocated. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=bug11095-rev111175.patch === modified file 'etc/NEWS' --- etc/NEWS 2012-12-10 12:38:49 +0000 +++ etc/NEWS 2012-12-10 20:08:35 +0000 @@ -92,6 +92,12 @@ when its arg ADJACENT is non-nil (when c it works like the utility `uniq'. Otherwise by default it deletes duplicate lines everywhere in the region without regard to adjacency. +** Interactive highlighting +*** New user variable `hi-lock-auto-select-face'. +*** Unhighlighting command (`hi-lock-unface-buffer') now un-highlights +text at point. When called interactively with a non-nil prefix, +removes all highlighting in current buffer. + ** Tramp +++ *** New connection method "adb", which allows to access Android === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-10 18:33:59 +0000 +++ lisp/ChangeLog 2012-12-10 20:19:36 +0000 @@ -1,5 +1,14 @@ 2012-12-10 Jambunathan K + * hi-lock.el (hi-lock--regexps-at-point): When `font-lock-mode' is + disabled, highlighting will use overlays. So use + `*-single-char-property-change' instead of + ``*-single-property-change'. + (hi-lock-read-face-name): Initialize `hi-lock--unused-faces' only + once. + +2012-12-10 Jambunathan K + * hi-lock.el: Refine the choice of default face. (hi-lock-keyword->face): New function. Use it wherever we used cadadadr instead. === modified file 'lisp/hi-lock.el' --- lisp/hi-lock.el 2012-12-10 18:33:59 +0000 +++ lisp/hi-lock.el 2012-12-10 19:42:51 +0000 @@ -478,8 +478,8 @@ updated as you type." (mapcar #'hi-lock-keyword->face hi-lock-interactive-patterns)) (let* ((hi-text (buffer-substring-no-properties - (previous-single-property-change (point) 'face) - (next-single-property-change (point) 'face)))) + (previous-single-char-property-change (point) 'face) + (next-single-char-property-change (point) 'face)))) ;; Compute hi-lock patterns that match the ;; highlighted text at point. Use this later in ;; during completing-read. @@ -611,8 +611,10 @@ not suitable." "Return face for interactive highlighting. When `hi-lock-auto-select-face' is non-nil, just return the next face. Otherwise, read face name from minibuffer with completion and history." - (unless hi-lock-interactive-patterns - (setq hi-lock--unused-faces hi-lock-face-defaults)) + (unless (or hi-lock-interactive-patterns hi-lock--unused-faces) + ;; This is the very first request for interactive highlighting. + ;; Initialize unused faces list. + (setq hi-lock--unused-faces (copy-sequence hi-lock-face-defaults))) (let* ((last-used-face (when hi-lock-interactive-patterns (face-name (hi-lock-keyword->face @@ -628,7 +630,7 @@ Otherwise, read face name from minibuffe (car defaults)) obarray 'facep t nil 'face-name-history defaults)) ;; Update list of un-used faces. - (setq hi-lock--unused-faces (remove face hi-lock--unused-faces)) + (setq hi-lock--unused-faces (delete face hi-lock--unused-faces)) ;; Grow the list of defaults. (add-to-list 'hi-lock-face-defaults face t)) (intern face))) --=-=-= Content-Type: text/plain > - introduced a helper hi-lock-keyword->face to get rid of those cadadadr > (some of which needed `cl' even it was not `require'd). > > > Stefan --=-=-=--