From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: texinfo-show-structure and occur Date: Mon, 15 Mar 2010 23:51:45 +0200 Organization: JURTA Message-ID: <87vdcxtgoz.fsf@mail.jurta.org> References: <871vfni1ln.fsf@ambire.localdomain> <873a02wok1.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1268690571 12171 80.91.229.12 (15 Mar 2010 22:02:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 15 Mar 2010 22:02:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 15 23:02:47 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NrIN4-0000Wx-DZ for ged-emacs-devel@m.gmane.org; Mon, 15 Mar 2010 23:02:46 +0100 Original-Received: from localhost ([127.0.0.1]:52677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrIN4-0000y4-0x for ged-emacs-devel@m.gmane.org; Mon, 15 Mar 2010 18:02:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrILE-0000Iq-Qb for emacs-devel@gnu.org; Mon, 15 Mar 2010 18:00:52 -0400 Original-Received: from [140.186.70.92] (port=43033 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrILC-0000I7-8X for emacs-devel@gnu.org; Mon, 15 Mar 2010 18:00:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NrIL9-0002fY-03 for emacs-devel@gnu.org; Mon, 15 Mar 2010 18:00:50 -0400 Original-Received: from smtp-out2.starman.ee ([85.253.0.4]:53464 helo=mx2.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NrIL8-0002ew-Mn for emacs-devel@gnu.org; Mon, 15 Mar 2010 18:00:46 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (62.65.209.182.cable.starman.ee [62.65.209.182]) by mx2.starman.ee (Postfix) with ESMTP id 289573F40D7; Tue, 16 Mar 2010 00:00:39 +0200 (EET) In-Reply-To: <873a02wok1.fsf@mail.jurta.org> (Juri Linkov's message of "Sun, 14 Mar 2010 23:57:05 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:122028 Archived-At: > `occur' already displays this information in the first line of the output > buffer. I think we don't need to duplicate this information in the echo area > that should be as concise as possible, like: > > Searched 1 buffer; found 573 matches This patch ensures that the length of the message in the echo area never gets more than the width of the window: === modified file 'lisp/replace.el' --- lisp/replace.el 2010-01-13 08:35:10 +0000 +++ lisp/replace.el 2010-03-15 21:49:59 +0000 @@ -1162,12 +1162,13 @@ (defun occur-1 (regexp nlines bufs &opti (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)) + (if (> (length regexp) (- (window-width) 42)) + "" (format " for `%s'" regexp)))) (setq occur-revert-arguments (list regexp nlines bufs)) (if (= count 0) (kill-buffer occur-buf) There is also a related problem with multi-occur. In the output it duplicates the regexp for every found buffer. For instance, see how the string `for "chapter"' is repeated: 2 matches for "chapter" in buffer: commands.texi 6:@chapter Characters, Keys and Commands 8: This chapter explains the character sets used by Emacs for input 1 match for "chapter" in buffer: cmdargs.texi 31:in batch mode. The sections of this chapter describe the available and there is no information about the total number of the found matches. The following patch adds a line with total number of matches and the regexp, and removes duplicate regexp output for multi-occur, so the above example becomes: 3 matches for "chapter": 2 matches in buffer: commands.texi 6:@chapter Characters, Keys and Commands 8: This chapter explains the character sets used by Emacs for input 1 match in buffer: cmdargs.texi 31:in batch mode. The sections of this chapter describe the available === modified file 'lisp/replace.el' --- lisp/replace.el 2010-01-13 08:35:10 +0000 +++ lisp/replace.el 2010-03-15 21:47:14 +0000 @@ -1294,9 +1295,11 @@ (defun occur-engine (regexp buffers out- (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))) + (if (> (length buffers) 1) + "" (format " for \"%s\"" regexp)) + (buffer-name buf))) (setq end (point)) (add-text-properties beg end (append @@ -1304,6 +1307,17 @@ (defun occur-engine (regexp buffers out- `(font-lock-face ,title-face)) `(occur-title ,buf)))) (goto-char (point-min))))))) + (when (and (not (zerop globalcount)) (> (length buffers) 1)) + (goto-char (point-min)) + (let ((beg (point)) + end) + (insert (format "%d match%s for \"%s\":\n" + globalcount (if (= globalcount 1) "" "es") + 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 -- Juri Linkov http://www.jurta.org/emacs/