emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r99710: Fix message of multi-line occ


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99710: Fix message of multi-line occur regexps and multi-buffer header lines.
Date: Sun, 21 Mar 2010 12:52:51 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99710
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Sun 2010-03-21 12:52:51 +0200
message:
  Fix message of multi-line occur regexps and multi-buffer header lines.
  http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00457.html
  
  * replace.el (occur-1): Don't display regexp if it is longer
  than window-width.  Use `query-replace-descr' to display regexp.
  (occur-engine): Don't display regexp in the buffer header for
  multi-buffer occur.  Display a separate header line with total
  match count and regexp for multi-buffer occur.
  Use `query-replace-descr' to display regexp.
modified:
  lisp/ChangeLog
  lisp/replace.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-03-20 21:46:31 +0000
+++ b/lisp/ChangeLog    2010-03-21 10:52:51 +0000
@@ -1,3 +1,15 @@
+2010-03-21  Juri Linkov  <address@hidden>
+
+       Fix message of multi-line occur regexps and multi-buffer header lines.
+       http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00457.html
+
+       * replace.el (occur-1): Don't display regexp if it is longer
+       than window-width.  Use `query-replace-descr' to display regexp.
+       (occur-engine): Don't display regexp in the buffer header for
+       multi-buffer occur.  Display a separate header line with total
+       match count and regexp for multi-buffer occur.
+       Use `query-replace-descr' to display regexp.
+
 2010-03-20  Teodor Zlatanov  <address@hidden>
 
        * net/secrets.el: Fix parenthesis.

=== modified file 'lisp/replace.el'
--- a/lisp/replace.el   2010-03-18 06:44:36 +0000
+++ b/lisp/replace.el   2010-03-21 10:52:51 +0000
@@ -1166,12 +1166,15 @@
                      (not (eq occur-excluded-properties t)))))
          (let* ((bufcount (length active-bufs))
                 (diff (- (length bufs) bufcount)))
-           (message "Searched %d buffer%s%s; %s match%s for `%s'"
+           (message "Searched %d buffer%s%s; %s match%s%s"
                     bufcount (if (= bufcount 1) "" "s")
                     (if (zerop diff) "" (format " (%d killed)" diff))
                     (if (zerop count) "no" (format "%d" count))
                     (if (= count 1) "" "es")
-                    regexp))
+                    ;; Don't display regexp if with remaining text
+                    ;; it is longer than window-width.
+                    (if (> (+ (length regexp) 42) (window-width))
+                        "" (format " for `%s'" (query-replace-descr regexp)))))
          (setq occur-revert-arguments (list regexp nlines bufs))
           (if (= count 0)
               (kill-buffer occur-buf)
@@ -1298,9 +1301,13 @@
                (goto-char headerpt)
                (let ((beg (point))
                      end)
-                 (insert (format "%d match%s for \"%s\" in buffer: %s\n"
+                 (insert (format "%d match%s%s in buffer: %s\n"
                                  matches (if (= matches 1) "" "es")
-                                 regexp (buffer-name buf)))
+                                 ;; Don't display regexp for multi-buffer.
+                                 (if (> (length buffers) 1)
+                                     "" (format " for \"%s\""
+                                                (query-replace-descr regexp)))
+                                 (buffer-name buf)))
                  (setq end (point))
                  (add-text-properties beg end
                                       (append
@@ -1308,6 +1315,18 @@
                                          `(font-lock-face ,title-face))
                                        `(occur-title ,buf))))
                (goto-char (point-min)))))))
+      ;; Display total match count and regexp for multi-buffer.
+      (when (and (not (zerop globalcount)) (> (length buffers) 1))
+       (goto-char (point-min))
+       (let ((beg (point))
+             end)
+         (insert (format "%d match%s total for \"%s\":\n"
+                         globalcount (if (= globalcount 1) "" "es")
+                         (query-replace-descr regexp)))
+         (setq end (point))
+         (add-text-properties beg end (when title-face
+                                        `(font-lock-face ,title-face))))
+       (goto-char (point-min)))
       (if coding
          ;; CODING is buffer-file-coding-system of the first buffer
          ;; that locally binds it.  Let's use it also for the output


reply via email to

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