まあ、grep別のプログラムです(これも使用できます)。Emacs では、関数 を使用しますsearch-forward-regexp。これは、どちらかを使用して実行できM-x(Meta通常はAltキーを押しながら を押しますx)、タイプsearch-forward-regexpして を押しReturnます。
次に、正規表現を入力して検索する必要があります。|< 簡単に言えば、何か を無視したいようです>.Emacsのさまざまな正規表現は次のとおりです。
|<[a-z]+>
たとえば、次のように検索できます。
a|<[a-z]+> comedy|<[a-z]+> show|<[a-z]+>
この方法で文字列を変換する Lisp 関数を作成するには、文字列をスペースで分割し、正規表現シーケンスを追加します。
(defun find-string-in-funny-file (s) ; Define a function
"Find a string in the file with the |<foo> things in it." ; Document its purpose
(interactive "sString to find: ") ; Accept input if invoked interactively with M-x
(push-mark) ; Save the current location, so `pop-global-mark' can return here
; (usually C-u C-SPC)
(goto-char 0) ; Start at the top of the file
(let ((re (apply #'concat ; join into one string…
(cl-loop
for word in (split-string s " ") ; for each word in `s'
collect (regexp-quote word) ; collect that word, plus
collect "|<[a-z]+> ")))) ; also the regex bits to skip
(search-forward-regexp ; search for the next occurrence
(substring re 0 (- (length re) 2))))) ; after removing the final space from `re'
(オンラインの) Emacs Lisp マニュアルで、これらの関数がそれぞれ何をするかを調べることができます。たとえば、メニューから「ヘルプ→説明→関数」を選択するか、 C-h f(Control+ h、次にf) を押して (RET) とタイプinteractiveすると、その特別な形式のマニュアルのドキュメントが表示されます。
上記(defun)を*scratch*バッファに貼り付け、最後にカーソルを最後)に置くと、 を押しC-jて評価することができ、関数はEmacsを閉じるまで残ります。
something という名前のファイルに保存すると、後で再度読み込むこと.elができます。M-x load-file
次に、「面白い」ファイルをロードして と入力M-x find-string-in-funny-fileすると、ファイル内で文字列が検索され、カーソルが文字列に置かれます。見つからない場合は、その旨のメッセージが表示されます。
バグ: 機能は壮観なスタイルよりも劣ります