[Top][All Lists]

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

Re: [el-search] How to search string excluding docstring?

From: Chunyang Xu
Subject: Re: [el-search] How to search string excluding docstring?
Date: Mon, 25 Dec 2017 21:57:19 +0800
User-agent: mu4e 0.9.18; emacs 27.0.50

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.

reply via email to

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