From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#18241: 24.4.50; [PATCH] I can now highlight-lines-matching-regexp from isearch Date: Sun, 10 Aug 2014 15:04:11 -0700 Message-ID: <87sil4uhlw.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1407708328 17033 80.91.229.3 (10 Aug 2014 22:05:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Aug 2014 22:05:28 +0000 (UTC) To: 18241@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 11 00:05:22 2014 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 1XGbEt-0007sH-KJ for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Aug 2014 00:05:19 +0200 Original-Received: from localhost ([::1]:32862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbEt-0008Ns-6P for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Aug 2014 18:05:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbEj-0008I6-5g for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:05:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGbEc-0001JN-Is for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:05:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbEc-0001Hd-DI for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XGbEb-0008LE-Ud for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Aug 2014 22:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.140770828332032 (code B ref -1); Sun, 10 Aug 2014 22:05:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Aug 2014 22:04:43 +0000 Original-Received: from localhost ([127.0.0.1]:38080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XGbEI-0008KZ-LD for submit@debbugs.gnu.org; Sun, 10 Aug 2014 18:04:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38494) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XGbEG-0008KL-IV for submit@debbugs.gnu.org; Sun, 10 Aug 2014 18:04:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGbE4-00019h-E0 for submit@debbugs.gnu.org; Sun, 10 Aug 2014 18:04:35 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:45795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbE4-00019c-Az for submit@debbugs.gnu.org; Sun, 10 Aug 2014 18:04:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbDy-00083H-9n for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:04:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGbDs-00018r-Dq for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:04:22 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:37249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGbDs-00018k-8D for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 18:04:16 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by gateway1.nyi.internal (Postfix) with ESMTP id 7F7102258C for ; Sun, 10 Aug 2014 18:04:13 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Sun, 10 Aug 2014 18:04:13 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=sygkUx8r03Frdep/q9Cl/sOz2rk=; b=XhHYLuS2d49mpsmyJQXNQ 9RGPCmE/wC2Bndw5lyQ/JC44NAnl6zgf0qeQX/4Vo2Pm6cqoHnqYGO0m/GmwivXY cimdr/Ij0vHIaTKaq/ZiVXVshZyb/OVX3DUTXq2Iq9VUPNpAmPHTsuQUwHtqhdnv NnLmf4hRjov3Bv61u2Vl3Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=sygkUx8r03Frdep/q9Cl/s Oz2rk=; b=sNxdyCdItM3c747hAzHWoL8YPdwC6kRdaOViKA235u690iOlRzCLDo h6zsZH+syX+ubRFBI9Mz3OPhr/ItEoDx1AqEI04euZ4lQDPSDEWoWuo2DDm6cNnR BmMd4foCpc/fKiVxWjKxHqvVl9oztp4aa+yOqFkQuyybER0VlFb4o= X-Sasl-enc: gG9FQKezS/UnAVF/lJBBPJo5MGvn/yzZ6yG5NsA2zWBP 1407708253 Original-Received: from shorty.local (unknown [23.243.199.75]) by mail.messagingengine.com (Postfix) with ESMTPA id 3903AC007B0 for ; Sun, 10 Aug 2014 18:04:13 -0400 (EDT) Original-Received: from ip6-localhost ([::1] helo=shorty.local) by shorty.local with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1XGbDn-0008Ey-Qs for bug-gnu-emacs@gnu.org; Sun, 10 Aug 2014 15:04:11 -0700 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:92395 Archived-At: --=-=-= Content-Type: text/plain Hi. Before this patch it was possible to 'M-s h r' during an isearch to highlight the regexp being sought. This patch adds similar functionality for matching lines with 'M-s h l'. This patch moves the previous 'M-s h r' isearch functionality into a macro, and then calls this macro separately for the regex and line cases. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-I-can-now-highlight-lines-matching-regexp-from-isear.patch >From ca3b5261d034b21467f781d7aa2620d0050fea37 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 10 Aug 2014 14:57:56 -0700 Subject: [PATCH] I can now highlight-lines-matching-regexp from isearch Before this patch it was possible to 'M-s h r' during an isearch to highlight the regexp being sought. This patch adds similar functionality for matching lines --- lisp/isearch.el | 79 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 20dabdc..710890c 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -524,6 +524,7 @@ This is like `describe-bindings', but displays only Isearch keys." (define-key map [?\C-\M-%] 'isearch-query-replace-regexp) (define-key map "\M-so" 'isearch-occur) (define-key map "\M-shr" 'isearch-highlight-regexp) + (define-key map "\M-shl" 'isearch-highlight-lines-matching-regexp) ;; The key translations defined in the C-x 8 prefix should add ;; characters to the search string. See iso-transl.el. @@ -732,6 +733,8 @@ Type \\[isearch-occur] to run `occur' that shows\ the last search string. Type \\[isearch-highlight-regexp] to run `highlight-regexp'\ that highlights the last search string. +Type \\[isearch-highlight-lines-matching-regexp] to run `highlight-lines-matching-regexp'\ + that highlights lines matching the last search string. Type \\[isearch-describe-bindings] to display all Isearch key bindings. Type \\[isearch-describe-key] to display documentation of Isearch key. @@ -1804,42 +1807,60 @@ characters in that string." (declare-function hi-lock-read-face-name "hi-lock" ()) + +(defmacro isearch--hi-lock (hi-lock-form) + "Backend for isearch-highlight-*. Does all the setup work, and +evaluates the given `hi-lock-form' to actually invoke the +highlighting function" + `(progn + (let ( + ;; Set `isearch-recursive-edit' to nil to prevent calling + ;; `exit-recursive-edit' in `isearch-done' that terminates + ;; the execution of this command when it is non-nil. + ;; We call `exit-recursive-edit' explicitly at the end below. + (isearch-recursive-edit nil)) + (isearch-done nil t) + (isearch-clean-overlays)) + (let ((regexp (cond ((functionp isearch-word) + (funcall isearch-word isearch-string)) + (isearch-word (word-search-regexp isearch-string)) + (isearch-regexp isearch-string) + ((if (and (eq isearch-case-fold-search t) + search-upper-case) + (isearch-no-upper-case-p + isearch-string isearch-regexp) + isearch-case-fold-search) + ;; Turn isearch-string into a case-insensitive + ;; regexp. + (mapconcat + (lambda (c) + (let ((s (string c))) + (if (string-match "[[:alpha:]]" s) + (format "[%s%s]" (upcase s) (downcase s)) + (regexp-quote s)))) + isearch-string "")) + (t (regexp-quote isearch-string))))) + (eval ,hi-lock-form)) + (and isearch-recursive-edit (exit-recursive-edit)))) + (defun isearch-highlight-regexp () "Run `highlight-regexp' with regexp from the current search string. It exits Isearch mode and calls `hi-lock-face-buffer' with its regexp argument from the last search regexp or a quoted search string, and reads its face argument using `hi-lock-read-face-name'." (interactive) - (let ( - ;; Set `isearch-recursive-edit' to nil to prevent calling - ;; `exit-recursive-edit' in `isearch-done' that terminates - ;; the execution of this command when it is non-nil. - ;; We call `exit-recursive-edit' explicitly at the end below. - (isearch-recursive-edit nil)) - (isearch-done nil t) - (isearch-clean-overlays)) (require 'hi-lock nil t) - (let ((regexp (cond ((functionp isearch-word) - (funcall isearch-word isearch-string)) - (isearch-word (word-search-regexp isearch-string)) - (isearch-regexp isearch-string) - ((if (and (eq isearch-case-fold-search t) - search-upper-case) - (isearch-no-upper-case-p - isearch-string isearch-regexp) - isearch-case-fold-search) - ;; Turn isearch-string into a case-insensitive - ;; regexp. - (mapconcat - (lambda (c) - (let ((s (string c))) - (if (string-match "[[:alpha:]]" s) - (format "[%s%s]" (upcase s) (downcase s)) - (regexp-quote s)))) - isearch-string "")) - (t (regexp-quote isearch-string))))) - (hi-lock-face-buffer regexp (hi-lock-read-face-name))) - (and isearch-recursive-edit (exit-recursive-edit))) + (isearch--hi-lock (hi-lock-face-buffer regexp (hi-lock-read-face-name)))) + +(defun isearch-highlight-lines-matching-regexp () + "Run `highlight-lines-matching-regexp' with regexp from the +current search string. It exits Isearch mode and calls +`hi-lock-face-buffer' with its regexp argument from the last +search regexp or a quoted search string, and reads its face +argument using `hi-lock-read-face-name'." + (interactive) + (require 'hi-lock nil t) + (isearch--hi-lock (hi-lock-line-face-buffer regexp (hi-lock-read-face-name)))) (defun isearch-delete-char () -- 2.0.0 --=-=-=--