Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search 如何在emacs中搜索其他缓冲区中的字符串?_Search_Emacs_Buffer - Fatal编程技术网

Search 如何在emacs中搜索其他缓冲区中的字符串?

Search 如何在emacs中搜索其他缓冲区中的字符串?,search,emacs,buffer,Search,Emacs,Buffer,我在一个缓冲区中有一组单词,在另一个缓冲区中有一组文本行。我在寻找像一个缓冲区中选定的字必须在另一个缓冲区中突出显示的东西。emacs支持吗?试试组织模式。 您可以将链接[[file:yourFile::yourSearchExpression]]放入组织缓冲区。 如果单击链接,则会在访问您的文件的缓冲区中搜索您的搜索表达式(正则表达式) 我使用下面的分机。使用此扩展,您还可以编写[[buffer:yourBuffer::yourSearchExpression]]。这里,yourBuffer必

我在一个缓冲区中有一组单词,在另一个缓冲区中有一组文本行。我在寻找像一个缓冲区中选定的字必须在另一个缓冲区中突出显示的东西。emacs支持吗?

试试组织模式。 您可以将链接
[[file:yourFile::yourSearchExpression]]
放入组织缓冲区。 如果单击链接,则会在访问
您的文件
的缓冲区中搜索
您的搜索表达式
(正则表达式)

我使用下面的分机。使用此扩展,您还可以编写
[[buffer:yourBuffer::yourSearchExpression]]
。这里,
yourBuffer
必须是缓冲区(而不是文件)。 但是,您可以提前打开感兴趣的文件。
yourSearchExpression
的第一个字符可以是运算符。 如果是
+
,则从当前点位置开始向前搜索
yourBuffer
。 如果是
-
,则从当前点位置开始向后搜索
yourBuffer
。如果未给出运算符,则从缓冲区的开头开始向前搜索缓冲区。其他操作符可以很容易地实现

好的是,您可以轻松地在org文件中预先定义搜索。您有一个文件,用于组织对一个主题的搜索。您搜索的内容可以分布在多个缓冲区中

如果您以后需要再次搜索此类型,这将非常方便

我最近增加了高亮度照明。因此,如果你遇到问题。给我一张纸条

;; stolen from isearch: (defface search-highlight-face '((((class color) (min-colors 88) (background light)) ;; The background must not be too dark, for that means ;; the character is hard to see when the cursor is there. (:background "magenta3" :foreground "lightskyblue1")) (((class color) (min-colors 88) (background dark)) (:background "palevioletred2" :foreground "brown4")) (((class color) (min-colors 16)) (:background "magenta4" :foreground "cyan1")) (((class color) (min-colors 8)) (:background "magenta4" :foreground "cyan1")) (t (:inverse-video t))) "Face for highlighting search matches." :group 'search-highlight) (defface search-highlight-other-face '((((class color) (min-colors 88) (background light)) (:background "paleturquoise")) (((class color) (min-colors 88) (background dark)) (:background "paleturquoise4")) (((class color) (min-colors 16)) (:background "turquoise3")) (((class color) (min-colors 8)) (:background "turquoise3")) (t (:underline t))) "Face for lazy highlighting of matches other than the current one." :group 'search-highlight) (require 'cl) ;; for find (defun search-highlight (se &rest opt) "Like the group of `search-forward' commands with highlighting of the matches. Note, that this function should only be used in commands since it is directly visible. The window of the current buffer must be alive and should be visible. Options: :back non-nil: search backward instead of forward :re non-nil: SE is regular expression :noerror non-nil: issue error when not found :bound bound of search :count search that many times (defaults to 1) :face use this face to highlight :others non-nil: highlight also other matches within visible area of buffer :recenter recenter point in window vertically (before highlighting others) " (interactive "sSearch expression:") (search-highlight-cleanup) ;; If anything went wrong prevously. (let* (ol (regexp? (when (plist-get opt :re) "-regexp")) (cmd (intern-soft (concat "search" (if (plist-get opt :back) "-backward" "-forward") regexp? ))) e) (when (funcall cmd se (plist-get opt :bound) (plist-get opt :noerror) (plist-get opt :count)) (setq ol (make-overlay (match-beginning 0) (match-end 0))) (overlay-put ol 'face 'search-highlight-face)) (when (plist-get opt :recenter) (recenter)) (if (plist-get opt :others) (save-excursion (goto-char (window-start)) (setq e (window-end nil t)) (setq cmd (intern-soft (concat "search-forward" regexp?))) (while (funcall cmd se e t) (unless (and ol (= (match-beginning 0) (overlay-start ol))) (overlay-put (make-overlay (match-beginning 0) (match-end 0)) 'face 'search-highlight-other-face))))) (add-hook 'pre-command-hook 'search-highlight-cleanup t t))) (defun search-highlight-cleanup () "Remove highlights for search-highlight-mode." (interactive) (remove-hook 'pre-command-hook 'search-highlight-cleanup t) (remove-overlays 0 (buffer-size) 'face 'search-highlight-face) (remove-overlays 0 (buffer-size) 'face 'search-highlight-other-face)) (defun org-at-buffer () "Check whether point is at [[buffer:BUFFER::SEARCH]]. BUFFER is just the name of an existing buffer. You can make sure that the buffer exists by [[file:...]]. ::RE is an optional regular expression. The first character of SEARCH may be an operator: + Start at current point and search forward. - Start at current point and search backward. If the operator is missing the buffer is searched for RE starting at the beginning of BUFFER. " (save-excursion (let ((pt (point)) b e name re) (when (search-backward "[[buffer:" (line-beginning-position) 'noErr) (forward-char) (setq b (+ (point) (length "[buffer:"))) (forward-sexp) ;; actual link (setq e (1- (point))) (when (looking-at "\\[") ;; optional description (forward-sexp)) (when (>= (point) pt) (goto-char b) (if (search-forward "::" e 'noErr) (setq name (buffer-substring-no-properties b (match-beginning 0)) re (buffer-substring-no-properties (match-end 0) e) ) (setq name (buffer-substring-no-properties b e))) (switch-to-buffer-other-window name) (when re (if (and (> (length re) 0) (find (aref re 0) "+-")) (let ((op (aref re 0))) (setq re (substring re 1)) (cond ((= op ?+) (when (= (point) (point-max)) (goto-char (point-min))) (search-highlight re :re t :noerror t :others t :recenter t)) ((= op ?-) (when (= (point) (point-min)) (goto-char (point-max))) (search-highlight re :back t :re t :noerror t :others t :recenter t)) (t (error "Unexpected op.")))) (goto-char (point-min)) (search-highlight re :re t :noerror t :others t :recenter t))) t))))) (add-to-list 'org-open-at-point-functions 'org-at-buffer) ;; 从isearch偷来的: (面搜索突出显示面) (((类别颜色)(最小颜色88)(背景光)) 也就是说,背景不能太暗 当光标在那里时,很难看到字符。 (:背景“洋红色3”:前景“lightskyblue1”)) ((类别颜色)(最小颜色88)(背景暗)) (:背景“淡紫色2”:前景“棕色4”)) ((类别颜色)(最小颜色16)) (:背景“洋红4”:前景“青色1”)) ((类别颜色)(最小颜色8)) (:背景“洋红4”:前景“青色1”)) (t(:逆视频t))) “用于突出显示搜索匹配项的面。” :组的搜索突出显示) (取消面搜索突出显示其他面。) (((类别颜色)(最小颜色88)(背景光)) (:背景为“淡绿色”)) ((类别颜色)(最小颜色88)(背景暗)) (:背景“淡绿色4”)) ((类别颜色)(最小颜色16)) (:背景“绿松石色3”)) ((类别颜色)(最小颜色8)) (:背景“绿松石色3”)) (t(:下划线t))) “用于延迟高亮显示当前匹配项以外的匹配项的面。” :组的搜索突出显示) (要求“cl”);;寻找 (取消搜索突出显示(se和rest选项) “与突出显示匹配项的“向前搜索”命令组类似。 请注意,此函数只能在命令中使用,因为它是直接可见的。 当前缓冲区的窗口必须处于活动状态且应可见。 选项: :back非nil:向后搜索而不是向前搜索 :re非nil:SE是正则表达式 :noerror non nil:未找到时发出错误 :搜索范围 :计算搜索次数(默认为1) :面使用此面高亮显示 :others non nil:还高亮显示缓冲区可见区域内的其他匹配项 :在窗口中垂直重新居中重新居中点(高亮显示其他点之前) " (交互式“搜索表达式:”) (搜索突出显示清理);;如果以前出了什么问题。 (让*(ol) (regexp?(当(plist get opt:re)“-regexp”)) (cmd(实习软件)(搜索目录) (如果(plist get opt:back)“-backward”—forward) regexp? ))) (e) (当(funcall cmd se(plist get opt:bound)(plist get opt:noerror)(plist get opt:count)) (setq ol(生成叠加(匹配开始0)(匹配结束0))) (覆盖“面”搜索突出显示面) (何时(plist-get-opt:recenter)(重新居中)) (如果(plist get opt:其他) (省去远足 (转到字符(窗口开始)) (设置为e(窗端为零) (setq cmd(内部软件(concat“search forward”regexp?)) (while(funcall cmd se e t) (除非(和ol((匹配开始0)(叠加开始ol))) (叠加放置(制作叠加(匹配开始0)(匹配结束0)) “面”搜索突出显示其他面()()())) (添加钩子“预命令钩子”搜索突出显示清理t))) (取消搜索高亮显示清除() “删除搜索突出显示模式的突出显示。” (互动) (移除钩子“预命令钩子”搜索高亮显示清除t) (删除覆盖0(缓冲区大小) “面”搜索突出显示面) (删除覆盖0(缓冲区大小) “面”搜索突出显示其他面) (在缓冲区() “检查点是否位于[[buffer:buffer::SEARCH]]。 BUFFER只是现有缓冲区的名称。 您可以通过[[文件:…]确保缓冲区存在。 ::RE是可选的正则表达式。 搜索的第一个字符可以是运算符: +从当前点开始,向前搜索。 -从当前点开始并向后搜索。 如果操作员丢失缓冲区,则在缓冲区开始处搜索重新启动。 " (省去远足 (让((点) b e 名称 (re) (当(向后搜索“[[buffer:”(行起始位置)”noErr时) (向前字符) (设定值b(+(点)(长度“[buffer:”)) (向前sexp);;实际链接 (设定值e(1-(点))) (查看“\\[”)时;可选说明 (前进性别) (当(>=(点)pt) (转到字符b) (如果(向前搜索):“e'noErr) (setq) 名称(缓冲区子字符串无属性b(匹配开始0)) re(缓冲区子字符串无属性(匹配端0)e) ) (setq名称(缓冲区子字符串无属性b e))) (瑞士)