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

[Idea] I think `highlight-symbol-colors' can be set foreground face colors matched background face colors. #40

Open
mrlee23 opened this issue Feb 3, 2016 · 0 comments

Comments

@mrlee23
Copy link

mrlee23 commented Feb 3, 2016

I'm using command highlight-symbol with default set of highlight-symbol-colors and set highlight-symbol-foreground-color as "white".

Then, some colors highlighted like yellow, cyan or SpringGreen1, difficult to read the words.

So, My idea is to make highlight-symbol-colors variable can set foreground color and background color as cons or just background color string(before way) matched foreground color as highlight-symbol-foreground-color variable.

Here is sample set of highlight-symbol-colors

(setq highlight-symbol-colors
        '(("black" . "yellow")
          ("black" . "DeepPink")
          ("black" . "cyan")
          ("white" . "MediumPurple1")
          ("black" . "SpringGreen1")
          ("white" . "DarkOrange")
          ("white" . "HotPink1")
          ("black" . "RoyalBlue1")
          ("white" . "OliveDrab")))
;; below is same
(setq highlight-symbol-foreground-color "white")
(setq highlight-symbol-colors
        '("yellow"
          ("black" . "DeepPink")
          ("black" . "cyan")
          "MediumPurple1"
          ("black" . "SpringGreen1")
          "DarkOrange"
          "HotPink1"
          ("black" . "RoyalBlue1")
          "OliveDrab"))

And I override highlight-symbol-add-symbol function.

(defun highlight-symbol-add-symbol (symbol &optional color)
  "Override this function for support convenience set foreground and background"
  (unless (highlight-symbol-symbol-highlighted-p symbol)
    (when (equal symbol highlight-symbol)
      (highlight-symbol-mode-remove-temp))
    (let ((color (or color (highlight-symbol-next-color)))
          f-color b-color)
      (unless (facep color)
        (if (consp color)
            (setq f-color (car color)
                  b-color (cdr color))
          (setq f-color highlight-symbol-foreground-color
                b-color color))
        (setq color `((background-color . ,b-color)
                      (foreground-color . ,f-color))))
      ;; highlight
      (highlight-symbol-add-symbol-with-face symbol color)
      (push symbol highlight-symbol-list))))

Above override function works find.

May be I can use faces but it has to many sequence(define face, face naming) and inconvenient customize.

But foreground and background cons way is very easy to customize and it also support before way (just list of background colors).

Thank you:)

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

No branches or pull requests

1 participant