From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#14017: Highlight prefix line numbers in occur Date: Fri, 22 Mar 2013 00:38:17 +0200 Organization: JURTA Message-ID: <871ub8idk6.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363905618 28497 80.91.229.3 (21 Mar 2013 22:40:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 22:40:18 +0000 (UTC) To: 14017@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 21 23:40:43 2013 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 1UIoA7-0002iI-Cp for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Mar 2013 23:40:43 +0100 Original-Received: from localhost ([::1]:36192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo9j-0007dK-Fs for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Mar 2013 18:40:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo9e-0007d6-Qx for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:40:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIo9Z-0004NB-GG for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:40:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo9Z-0004Mp-Cm for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:40:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UIoBO-0000hV-1L for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Mar 2013 22:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14017 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13639056892649 (code B ref -1); Thu, 21 Mar 2013 22:42:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Mar 2013 22:41:29 +0000 Original-Received: from localhost ([127.0.0.1]:39474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIoAr-0000gg-8o for submit@debbugs.gnu.org; Thu, 21 Mar 2013 18:41:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56691) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIoAn-0000gX-Cs for submit@debbugs.gnu.org; Thu, 21 Mar 2013 18:41:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIo8x-0003ic-1N for submit@debbugs.gnu.org; Thu, 21 Mar 2013 18:39:32 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:45757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo8w-0003iY-UL for submit@debbugs.gnu.org; Thu, 21 Mar 2013 18:39:30 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo8v-0007Wd-OW for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:39:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIo8u-0003iH-EK for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:39:29 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:50806 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIo8u-0003iD-4S for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2013 18:39:28 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id C76C9258B92960 for ; Thu, 21 Mar 2013 15:39:26 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:72769 Archived-At: Currently the `prefix-face' arg of `occur-engine' is unused. Its caller `occur-1' just sends nil to `occur-engine'. This is the reason why a bug in its usage in `occur-engine' remained undiscovered for a long time. The bug is that this code: (when prefix-face `(font-lock-face prefix-face)) should be fixed to: (when prefix-face `(font-lock-face ,prefix-face)) To take it into use I propose to add a new face option `list-matching-lines-prefix-face' to accompany the existing `list-matching-lines-buffer-name-face' and `list-matching-lines-face'. Its default value could be `shadow' - the same face as is used to highlight line numbers in `linum-mode' (their output will look similar). === modified file 'lisp/replace.el' --- lisp/replace.el 2013-03-10 08:44:07 +0000 +++ lisp/replace.el 2013-03-21 22:36:56 +0000 @@ -1125,6 +1125,14 @@ (defcustom list-matching-lines-buffer-name-face :type 'face :group 'matching) +(defcustom list-matching-lines-prefix-face 'shadow + "Face used by \\[list-matching-lines] to show the prefix column. +If the face doesn't differ from the default face, +don't highlight the prefix with line numbers specially." + :type 'face + :group 'matching + :version "24.4") + (defcustom occur-excluded-properties '(read-only invisible intangible field mouse-face help-echo local-map keymap yank-handler follow-link) @@ -1334,7 +1342,9 @@ (defun occur-1 (regexp nlines bufs &opti (isearch-no-upper-case-p regexp t) case-fold-search) list-matching-lines-buffer-name-face - nil list-matching-lines-face + (if (face-differs-from-default-p list-matching-lines-prefix-face) + list-matching-lines-prefix-face) + list-matching-lines-face (not (eq occur-excluded-properties t)))))) (let* ((bufcount (length active-bufs)) (diff (- (length bufs) bufcount))) @@ -1423,7 +1433,7 @@ (defun occur-engine (regexp buffers out- (apply #'propertize (format "%7d:" lines) (append (when prefix-face - `(font-lock-face prefix-face)) + `(font-lock-face ,prefix-face)) `(occur-prefix t mouse-face (highlight) ;; Allow insertion of text at ;; the end of the prefix (for @@ -1447,7 +1457,9 @@ (defun occur-engine (regexp buffers out- ;; of multi-line matches. (replace-regexp-in-string "\n" - "\n :" + (if prefix-face + (propertize "\n :" 'font-lock-face prefix-face) + "\n :") match-str) ;; Add marker at eol, but no mouse props. (propertize "\n" 'occur-target marker))) @@ -1458,7 +1470,8 @@ (defun occur-engine (regexp buffers out- ;; The complex multi-line display style. (setq ret (occur-context-lines out-line nlines keep-props begpt endpt - lines prev-lines prev-after-lines)) + lines prev-lines prev-after-lines + prefix-face)) ;; Set first elem of the returned list to `data', ;; and the second elem to `prev-after-lines'. (setq prev-after-lines (nth 1 ret)) @@ -1482,7 +1495,7 @@ (defun occur-engine (regexp buffers out- (when prev-after-lines (with-current-buffer out-buf (insert (apply #'concat (occur-engine-add-prefix - prev-after-lines))))))) + prev-after-lines prefix-face))))))) (when (not (zerop matches)) ;; is the count zero? (setq globalcount (+ globalcount matches)) (with-current-buffer out-buf @@ -1537,10 +1550,13 @@ (defun occur-engine-line (beg end &optio str) (buffer-substring-no-properties beg end))) -(defun occur-engine-add-prefix (lines) +(defun occur-engine-add-prefix (lines &optional prefix-face) (mapcar #'(lambda (line) - (concat " :" line "\n")) + (concat (if prefix-face + (propertize " :" 'font-lock-face prefix-face) + " :") + line "\n")) lines)) (defun occur-accumulate-lines (count &optional keep-props pt) @@ -1569,7 +1585,8 @@ (defun occur-accumulate-lines (count &op ;; Generate a list of lines, add prefixes to all but OUT-LINE, ;; then concatenate them all together. (defun occur-context-lines (out-line nlines keep-props begpt endpt - lines prev-lines prev-after-lines) + lines prev-lines prev-after-lines + &optional prefix-face) ;; Find after- and before-context lines of the current match. (let ((before-lines (nreverse (cdr (occur-accumulate-lines @@ -1609,10 +1626,13 @@ (defun occur-context-lines (out-line nli ;; Return a list where the first element is the output line. (apply #'concat (append - (and prev-after-lines - (occur-engine-add-prefix prev-after-lines)) - (and separator (list separator)) - (occur-engine-add-prefix before-lines) + (if prev-after-lines + (occur-engine-add-prefix prev-after-lines prefix-face)) + (if separator + (list (if prefix-face + (propertize separator 'font-lock-face prefix-face) + separator))) + (occur-engine-add-prefix before-lines prefix-face) (list out-line))) ;; And the second element is the list of context after-lines. (if (> nlines 0) after-lines))))