From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Newsgroups: gmane.emacs.bugs Subject: bug#10916: Using occur to list occurrencies of the symbol at point Date: Thu, 01 Mar 2012 11:10:06 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1330596747 25617 80.91.229.3 (1 Mar 2012 10:12:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 1 Mar 2012 10:12:27 +0000 (UTC) To: 10916@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 01 11:12:27 2012 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 1S32zq-0006RE-Ge for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Mar 2012 11:12:26 +0100 Original-Received: from localhost ([::1]:33333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32zp-0002rG-JY for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Mar 2012 05:12:25 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32zh-0002q0-BQ for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:12:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S32zY-0006wA-UC for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:12:16 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32zY-0006w5-Qt for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:12:08 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S32zS-0003nv-6T for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: nisse@lysator.liu.se (Niels =?UTF-8?Q?M=C3=B6ller?=) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Mar 2012 10:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10916 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.133059666514559 (code B ref -1); Thu, 01 Mar 2012 10:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Mar 2012 10:11:05 +0000 Original-Received: from localhost ([127.0.0.1]:56778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S32yW-0003mL-Tf for submit@debbugs.gnu.org; Thu, 01 Mar 2012 05:11:05 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57892) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S32yL-0003lu-2x for submit@debbugs.gnu.org; Thu, 01 Mar 2012 05:10:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S32xr-0006dF-3A for submit@debbugs.gnu.org; Thu, 01 Mar 2012 05:10:28 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:55648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32xq-0006dB-WB for submit@debbugs.gnu.org; Thu, 01 Mar 2012 05:10:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32xk-0001sj-PG for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:10:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S32xe-0006Wy-73 for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:10:16 -0500 Original-Received: from mail.lysator.liu.se ([130.236.254.3]:38341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S32xe-0006V3-07 for bug-gnu-emacs@gnu.org; Thu, 01 Mar 2012 05:10:10 -0500 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 0B54B4000A for ; Thu, 1 Mar 2012 11:10:07 +0100 (CET) Original-Received: from stalhein.lysator.liu.se (stalhein.lysator.liu.se [IPv6:2001:6b0:17:f0a0::cc]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPS id EFA9D40004 for ; Thu, 1 Mar 2012 11:10:06 +0100 (CET) Original-Received: from stalhein.lysator.liu.se (localhost [127.0.0.1]) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4) with ESMTP id q21AA6tc014449 for ; Thu, 1 Mar 2012 11:10:06 +0100 (MET) Original-Received: (from nisse@localhost) by stalhein.lysator.liu.se (8.14.4+Sun/8.14.4/Submit) id q21AA6uL014448; Thu, 1 Mar 2012 11:10:06 +0100 (MET) X-Authentication-Warning: stalhein.lysator.liu.se: nisse set sender to nisse@lysator.liu.se using -f User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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 (newer, 2) 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:57413 Archived-At: Hi, I'm using both M-x grep and M-x occur quite a lot. I have been a bit annoyed that they interpret a prefix argument very differently. With C-u M-x grep, it searches for the symbol (or word or tag; I'm not sure exactly how it's delimited) under point, which is a feature I find very useful. I first expected C-u M-x occur to behave the same way, but instead it interprets the prefix argument as the amount of additional context to include in the output buffer. This is a feature I don't need very often. I'm not sure it's a good idea to change the behaviour of M-x occur, so instead I wrote the following function to do what I want: (defun occur-tag (regexp nlines) (interactive (let ((tag (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) 'find-tag-default)))) (if tag (list (concat "\\_<" (regexp-quote tag) "\\_>") (when current-prefix-arg (prefix-numeric-value current-prefix-arg))) (occur-read-primary-args)))) (occur regexp nlines)) It gets the symbol under point in the same way as M-x grep, and constructs a regexp to use with occur. I this it mainly for searching in source files, which is why I use \_< and \_> rather than \< and \> when constructing the regexp. Maybe it would make sense to add something like this to emacs, either as a separate function like above, or in response to an "empty" prefix argument to M-x occur. Or maybe there's already some emacs function which does this and does it better, which I'm not aware of... BTW, I think it would also make some sense with a helper function for the logic involving find-tag-default-function, since this seems to be duplicated in find-tag-tag, complete-tag, grep-tag-default, and possibly other places. Or movee it inside find-tag-default, if those variables always should be consulted. Best regards, /Niels M=F6ller --=20 Niels M=F6ller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance.