From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Chunyang Xu Newsgroups: gmane.emacs.help Subject: Re: [el-search] How to search string excluding docstring? Date: Mon, 25 Dec 2017 21:57:19 +0800 Message-ID: References: <86373znhk6.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1514210176 14739 195.159.176.226 (25 Dec 2017 13:56:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 25 Dec 2017 13:56:16 +0000 (UTC) User-Agent: mu4e 0.9.18; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 25 14:56:12 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTTEh-0003Iu-QP for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Dec 2017 14:56:12 +0100 Original-Received: from localhost ([::1]:48786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTTGe-0008Nh-Gc for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Dec 2017 08:58:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTTG3-0008ND-Ng for help-gnu-emacs@gnu.org; Mon, 25 Dec 2017 08:57:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTTFy-0006Qx-Ps for help-gnu-emacs@gnu.org; Mon, 25 Dec 2017 08:57:35 -0500 Original-Received: from forward105p.mail.yandex.net ([77.88.28.108]:41788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eTTFy-0006QS-Hm for help-gnu-emacs@gnu.org; Mon, 25 Dec 2017 08:57:30 -0500 Original-Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 3D6084080EEA; Mon, 25 Dec 2017 16:57:27 +0300 (MSK) Original-Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id v3ZBTISUVY-vQfielh0; Mon, 25 Dec 2017 16:57:27 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xuchunyang.me; s=mail; t=1514210247; bh=SuXzVg7L9V+2tP7eyP3jVIANYJdpRZT0NEjyXPlubgs=; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID; b=LlEbF5xZSuqBxBBq+MGD43RNn7I1n0ufVSGy/oXTqTuFxEvPG4A4xj1X6e7FpBnSC 8WcTw3BYYiHAVUmIYrbu8nWlxOmFPODTYzgDuqS/BvNUASnPl2lmEBBPzIeLizEYOP 9u4ce+uCw/WXXtxDH+UXQVm9jCfapJEQmf+0DPXA= Original-Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id H6o3BF2yfT-vMiWlBuv; Mon, 25 Dec 2017 16:57:25 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xuchunyang.me; s=mail; t=1514210245; bh=SuXzVg7L9V+2tP7eyP3jVIANYJdpRZT0NEjyXPlubgs=; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID; b=y3rlV9MCGcvW4xFEwqhUAmiTDi+KASH+zjI8CU530kNHy2Sq5GjObdFCwp3CneXRC EVLjkvTdTN+M7JYKXqv51d8TWizKJf2+243l1QEM0ZUnpdbWj3/Q8q2kwX0fIPpnSb Bcieb685AsApS10RqN8oJXAGrWMNzGNrtwpx5m+w= Authentication-Results: smtp4j.mail.yandex.net; dkim=pass header.i=@xuchunyang.me In-reply-to: <86373znhk6.fsf@zoho.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 77.88.28.108 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115447 Archived-At: Emanuel Berg writes: > Chunyang Xu wrote: > >> but I have no idea how to define >> 'docstring-p'. > > Docstrings are in `font-lock-doc-face' so Emacs > already knows how to determine that. Find out > how that is done, and then invoke or reuse that > code from your function. It almost solves my problem via: (and (pred stringp) (guard (not (eq 'font-lock-doc-face (get-char-property (point) 'face)))) (string "foo")) but it doesn't work for files which is not already opened, I guess it is because font-lock-mode is only active when I open the file. For example, M-x el-search-directory RET (and (pred stringp) (guard (not (eq 'font-lock-doc-face (get-char-property (point) 'face)))) (string "^GNU Emacs")) RET M-x el-search-occur RET also matches process-event-p's docstring (from levents.el.gz): (defun process-event-p (obj) "True if the argument is a process-output event object. GNU Emacs 19 does not currently generate process-output events." (eq (car-safe obj) 'process)) and after I open levents.el.gz and try the 'M-x el-search-directory' with the exact same argument again, the match disappears. Besides I am still interested in using "pattern match" to solve the issue. I think it is possible though I don't know how yet.