Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable evil-search-highlight-persist-highlight-face #18

Open
mpollmeier opened this issue Dec 13, 2016 · 5 comments · Fixed by naclander/evil-search-highlight-persist#1

Comments

@mpollmeier
Copy link

I just wanted to send you a PR, but since I'm an elisp newbie I ran into a problem, maybe you can help me fix it:

I wanted to change this:

(defface evil-search-highlight-persist-highlight-face
  '((((class color))
     (:background "yellow1")))
  "Face for the highlighted text."
  :group 'evil-search-highlight-persist)

into this, to make the colour configurable:

(defvar evil-search-highlight-background-colour "yellow1" "background colour of highlighted text")
(defface evil-search-highlight-persist-highlight-face
  '((((class color))
     (:background evil-search-highlight-background-colour)))
  "Face for the highlighted text."
  :group 'evil-search-highlight-persist)

Emacs complains that it's the wrong type though (stringp) - I don't get it, you're using a string in the original code as well. Can you help?

@naclander
Copy link

The problem is the ' before '((((class color...
The quote in front basically means that nothing will be evaluated, so you weren't actually using a string.
To fix it use a backquote:
`((((class color ... (:background ,evil-search-highlight-background-colour) ...

@mpollmeier
Copy link
Author

Thank you @naclander , I learned something! However now I have the problem that I can't override the default value - it always takes the default (yellow1). I assume the problem got to do with evaluation time, I tried different versions with backticks, single quotes, defun with no luck :(

From my init.el:

(setq evil-search-highlight-string-min-len 2) ;;works
(setq evil-search-highlight-background-colour "purple1") ;; doesn't work

After making the changes you suggested:

(defvar evil-search-highlight-background-colour "yellow1" "background colour of highlighted text")
(defface evil-search-highlight-persist-highlight-face
  `((((class color))
     (:background ,evil-search-highlight-background-colour)))
  "Face for the highlighted text."
  :group 'evil-search-highlight-persist)

For reference, here's the block that's using the min-length attribute that I can configure fine:

(defvar evil-search-highlight-string-min-len 1 "min legth")
(defun evil-search-highlight-persist-mark ()
  (let ((hlt-use-overlays-flag t)
        (hlt-last-face 'evil-search-highlight-persist-highlight-face)
        tmp)
    (if isearch-regexp
        (progn
          (setq tmp (car-safe regexp-search-ring))
          (setq evil-search-highlight-regex-flag t))
      (progn
        (setq tmp (car-safe search-ring))
        (setq evil-search-highlight-regex-flag nil)))
    (if (>= (length tmp) evil-search-highlight-string-min-len)
          (hlt-highlight-regexp-region-in-buffers tmp (list (current-buffer)))
      ))
  (setq evil-search-highlight-regex-flag t)
  )

@juanjux
Copy link
Owner

juanjux commented Apr 3, 2017

Hi guys,

Please note that currently this project is unmaintained because I went back to Vim and anyway I wasn't very good at elisp. If some of you want to take over it please fork and we can update the elpa links. I'll update the readme.

@naclander
Copy link

@juanjux Sure thing, I forked it.

@mpollmeier You have to put the setq before loading evil-search-highlight-persist. Also, change your defvar to defcustom.

@mpollmeier
Copy link
Author

Thank you, that did the trick. I made evil-search-highlight-string-min-len a defcustom as well for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants