emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does occur depropertize matching lines?


From: Richard Stallman
Subject: Re: why does occur depropertize matching lines?
Date: Wed, 24 Nov 2004 21:19:47 -0500

    Even now occur partly preserves highlighting for some lines: when
    called with a numeric prefix argument occur displays context lines
    highlighted with their original faces whereas highlighting from matching
    lines is removed.  This is too weird.  I can't find a reason for that.

I discovered that changing occur-1 to pass t for the keep-props
argument to occur-engine inverts this: it preserves the highlighting
for the actual target line, and discards it for the context lines.

That seems like a good idea to me; what do you think?

Here's the patch that does it.

*** replace.el  20 Nov 2004 16:58:11 -0500      1.190
--- replace.el  24 Nov 2004 20:51:24 -0500      
***************
*** 915,921 ****
                    (and case-fold-search
                         (isearch-no-upper-case-p regexp t))
                    list-matching-lines-buffer-name-face
!                   nil list-matching-lines-face nil)))
        (let* ((bufcount (length active-bufs))
               (diff (- (length bufs) bufcount)))
          (message "Searched %d buffer%s%s; %s match%s for `%s'"
--- 915,921 ----
                    (and case-fold-search
                         (isearch-no-upper-case-p regexp t))
                    list-matching-lines-buffer-name-face
!                   nil list-matching-lines-face t)))
        (let* ((bufcount (length active-bufs))
               (diff (- (length bufs) bufcount)))
          (message "Searched %d buffer%s%s; %s match%s for `%s'"


    However, I see another problem: matches are not highlighted anymore
    with `list-matching-lines-face' because when a character has two properties

      font-lock-face [bold]                   ;; from `list-matching-lines-face'
      face           [font-lock-keyword-face] ;; from source buffer

    `face' property takes precedence over `font-lock-face'.

I wonder why occur-engine uses font-lock-face.  It is not font lock
mode, after all.  Changing it to use `face' instead makes it seem
to do the right thing.  Does it cause any problem?

*** replace.el  20 Nov 2004 16:58:11 -0500      1.190
--- replace.el  24 Nov 2004 20:53:47 -0500      
***************
*** 998,1004 ****
                                             (append
                                              `(occur-match t)
                                              (when match-face
!                                               `(font-lock-face ,match-face)))
                                             curstring)
                        (setq start (match-end 0))))
                    ;; Generate the string to insert for this match
--- 998,1004 ----
                                             (append
                                              `(occur-match t)
                                              (when match-face
!                                               `(face ,match-face)))
                                             curstring)
                        (setq start (match-end 0))))
                    ;; Generate the string to insert for this match




reply via email to

[Prev in Thread] Current Thread [Next in Thread]