如何发现在helm缓冲区中使用哪些面?

时间:2017-01-12 13:40:54

标签: emacs emacs-helm

我想改变*helm ag*缓冲区中某些内容的外观。我发现在某些时候使用哪个面(我最喜欢的是感兴趣区域中的点M-x customize-face)的常用技巧都不起作用,因为没有(明显的)方法来控制光标掌舵缓冲区。

我的问题是:

  • 教我钓鱼,终身喂养我:如何发现缓冲区中使用的面孔,我无法放置光标?

  • 给我一​​条鱼,喂我一天:在*helm ag*缓冲区中使用哪个面来突出显示当前所选行的模式匹配?

更新

对于*helm-ag*命令创建的helm-ag缓冲区,相关的面是helm-match。但是,在*helm ag*命令创建的helm-do-grep-ag缓冲区(无破折号!)中,helm-match面似乎没有效果,如下面的进一步信息所述。

更多信息

以下是emacs会话的图片,其中未启用任何自定义主题。

illustration of the problem

在左下方有一个*helm ag*缓冲区搜索defun。选择缓冲区中的第三行。匹配(defun)在所有其他行中突出显示,但不在所选行中突出显示。

右边是可能候选人的面部定制缓冲区。 helm-match已设置为红色前景,但这不会反映在*helm-ag*缓冲区中。这似乎表明helm-match不是我正在寻找的鱼。

3 个答案:

答案 0 :(得分:2)

首先,这是你的" fish":我认为你指的是helm-match

如果我需要找到一张特定的面孔并且不能用那张脸指向文字,我会亲自尝试几种不同的策略:

  1. 使用M-x describe-face,猜测名称的第一部分可能是什么(在这种情况下为helm),并扫描可能的候选人。
  2. 转到可能已定义该面孔的代码(在这种情况下helm-ag.el可以找到M-x describe-function RET helm-ag),并在该文件中搜索face以查找可能的匹配项
  3. 执行M-x customize-face并输入'all faces',查找helm-*个面孔并尝试找到一个名称和面孔(因为您可以看到此缓冲区中的面部样本)你正在寻找的那个。
  4. 可能这些方法都不像你希望的那样直接,而且可能有更快的解决方案,但这就是我要做的(并且已经完成)。在这种情况下,我用方法#2找到了脸。

    更新

    以下是我设置的屏幕截图:

    enter image description here

    请注意,对我来说,相关的面孔是helm-match,它继承自match中的replace.el。此外,请注意,匹配在突出显示/选定的行中显示的方式与其他行相比的差异不是由于不同的面,而是由线突出显示的背景颜色如何影响颜色引起的,如可以看到的当我在这里突出显示示例文本时:

    enter image description here

    更新2:

    事实证明,OP正在使用helm-ag-do-grep,该helm-grep.el在不同的文件中定义 - ;;; Faces ;; ;; (defgroup helm-grep-faces nil "Customize the appearance of helm-grep." :prefix "helm-" :group 'helm-grep :group 'helm-faces) (defface helm-grep-match '((((background light)) :foreground "#b00000") (((background dark)) :foreground "gold1")) "Face used to highlight grep matches." :group 'helm-grep-faces) (defface helm-grep-file '((t (:foreground "BlueViolet" :underline t))) "Face used to highlight grep results filenames." :group 'helm-grep-faces) (defface helm-grep-lineno '((t (:foreground "Darkorange1"))) "Face used to highlight grep number lines." :group 'helm-grep-faces) (defface helm-grep-finish '((t (:foreground "Green"))) "Face used in mode line when grep is finish." :group 'helm-grep-faces) (defface helm-grep-cmd-line '((t (:inherit diff-added))) "Face used to highlight grep command line when no results." :group 'helm-grep-faces) 。以下是该代码的面部设置部分:

    helm-grep-match

    我认为customize-face正是您所寻找的。如果没有,相关的面孔可能会出现在上面的代码段中,并且所有这些面都应该使用{{1}}进行自定义。此代码也使用上述方法#2进行跟踪。

答案 1 :(得分:2)

@ elethan#3的类似方法:

  • 致电list-faces-display,会显示所有面孔的列表 按字母顺序排列。

  • 搜索“helm”。

答案 2 :(得分:0)

ag本身使用颜色来突出显示匹配。 Helm使用这些颜色并忽略helm-grep-match,除非helm-grep-ag-command包含--nocolors选项。

因此有两种方法:

  1. 使用--color-match选项将所需的颜色设置为ag中的helm-grep-ag-command

  2. 使用ag中的--nocolor选项禁用helm-grep-ag-command的匹配突出显示,并设置Emacs' helm-matchhelm-grep-match(不完全确定哪一个是正确的)指定匹配颜色。由于第二个选项使用elisp来处理着色,因此它可能比第一个更慢。

  3. 在这两种情况下,匹配突出显示都会被helm-selection覆盖,因此在所选行上突出显示匹配的唯一方法是让helm-selection 指定背景或前景,从而为匹配突出显示留下机会。

    参考:https://github.com/emacs-helm/helm/issues/1660#