मैं किसी कस्टम थीम के भाग कैसे बदलूं?


21

मैं पूर्व-परिभाषित कस्टम थीमों में से एक का उपयोग कर रहा हूं जो स्पेसमैक्स (जेनबर्न) के साथ बंडल में आते हैं।

मैं थीम के विशिष्ट भागों को कैसे संशोधित कर सकता हूं, उदाहरण के लिए टिप्पणियों के लिए उपयोग किए जाने वाले फ़ॉन्ट रंग को बस बदल दें?


2
क्या आप सुनिश्चित हैं कि आपका मतलब रंग थीम है न कि कस्टम थीम? यदि आप 3-पार्टी का उपयोग नहीं कर रहे हैं, color-theme.elतो आप शायद कस्टम थीम का मतलब है। उस स्थिति में, कृपया अपने प्रश्न को तदनुसार संपादित करें। रंग और कस्टम थीम देखें ।
ड्रू

जवाबों:


13

मैं इस बात custom-theme-set-facesको पुन: परिभाषित करने का पक्ष लेता हूं कि थीम किसी विशेष चेहरे को कैसे प्रदर्शित करती है, जैसे,

(custom-theme-set-faces
 'zenburn
 '(font-lock-comment-face ((t (:foreground "#DFAF8F"))))
 '(font-lock-comment-delimiter-face ((t (:foreground "#DFAF8F")))))

के विशिष्ट मामले के लिए zenburn, विषय स्वयं ही विभिन्न रंगों और एक मैक्रो को परिभाषित करता है जिसमें वे परिवर्तनशील नामों से बंधे होते हैं, इसलिए आप ऊपर लिख सकते हैं:

(zenburn-with-color-variables
  (custom-theme-set-faces
   'zenburn
   `(font-lock-comment-face ((t (:foreground ,zenburn-orange))))
   `(font-lock-comment-delimiter-face ((t (:foreground ,zenburn-orange))))))

आप इस कोड के टुकड़े को कहाँ लिखने वाले हैं? में .spacemacs?
चिसेल्डएब्स

1
कोई विचार नहीं, क्षमा करें; मैं Spacemacs का उपयोग नहीं करता। सिद्धांत रूप में, आपको केवल zenburnविषय लोड होने के कुछ समय बाद कोड का मूल्यांकन करने की आवश्यकता होती है ।
एरोन हैरिस

8

स्पेसमैक्स में, परत स्थापित करें theming, https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Bthemes/theming देखें

उदाहरण के लिए, मेरे पास ग्रूवबॉक्स और सोलराइज्ड-लाइट थीम के बैकग्राउंड और लिनेनम्बर रंग को समायोजित करने के लिए dotspacemacs/user-initमेरे .spacemacsस्निप हैं:

  (setq theming-modifications '(
    ;; requires the theming layer
    (gruvbox
       (default :background "#1D2021" :foreground "#fdf4c1")
       (linum :background "#000000" :foreground "#878787")
       (fringe  :background "#000000")
       (linum-relative-current-face :inherit (shadow default) :background "#3C3836" :foreground "#ff0000")
       (font-lock-comment-face :slant italic)
    )
    (solarized-light
     (linum :background "#DBCDA7" :foreground "#40371F")
       (fringe :background "#DBCDA7")
       (font-lock-comment-face :slant italic)
       )
))

4

मैंने कुछ चेहरों को ओवरराइड करने के लिए लोड-थीम फ़ंक्शन को सलाह दी है - इस तरह से आप थीम का चयन करने के लिए सामान्य रूप से लोड-थीम का उपयोग करना जारी रख सकते हैं और यह ओवरराइड्स को स्वचालित रूप से लागू करेगा।

(defadvice load-theme (after theme-set-overrides activate)
  "Set override faces for different custom themes."
  (dolist (theme-settings theme-overrides)
    (let ((theme (car theme-settings))
          (faces (cadr theme-settings)))
      (if (member theme custom-enabled-themes)
          (dolist (face faces)
            (custom-theme-set-faces theme face))))))

(defcustom theme-overrides nil
  "Association list of override faces to set for different custom themes.")

(defun alist-set (alist-symbol key value)
  "Set VALUE of a KEY in ALIST-SYMBOL."
  (set alist-symbol
        (cons (list key value) (assq-delete-all key (eval alist-symbol)))))

; override some settings of the ample-flat theme
(alist-set 'theme-overrides 'ample-flat '(
                                          (default ((t (:background "gray12" :foreground "#bdbdb3"))))
                                          (mode-line ((t (:background "cornsilk4" :foreground "#222" :inherit 'variable-pitch))))
                                          (outline-2 ((t (:inherit font-lock-keyword-face)))) ; blueish
                                          (outline-3 ((t (:inherit font-lock-comment-face)))) ; brownish
                                          (outline-4 ((t (:inherit font-lock-string-face)))) ; orangeish
                                          (org-table ((t (:inherit fixed-pitch :height 0.7 :foreground "#887"))))
                                          (org-formula ((t (:inherit org-table :foreground nil))))
                                          ))

यह काम करता है, और यह इंटरफ़ेस के हिस्से के रूप में अच्छा होगा, लेकिन यह शायद प्रत्येक विषय के लिए एक फ़ंक्शन बनाने के लिए सबसे सरल है जिसे आप इसे लोड करने के बाद कस्टम-थीम-सेट-फेस का उपयोग करते हैं और कॉल करते हैं -

(defun ample-flat ()
  (interactive)
  (mapc #'disable-theme custom-enabled-themes) ; clear any existing themes
  (load-theme 'ample-flat t)
  (custom-theme-set-faces 'ample-flat 
                          '(default ((t (:background "gray12" :foreground "#bdbdb3"))))
                          '(mode-line ((t (:background "cornsilk4" :foreground "#222" :inherit 'variable-pitch))))
                          '(outline-2 ((t (:inherit font-lock-keyword-face)))) ; blueish
                          '(outline-3 ((t (:inherit font-lock-comment-face)))) ; brownish
                          '(outline-4 ((t (:inherit font-lock-string-face)))) ; orangeish
                          '(org-table ((t (:inherit fixed-pitch :height 0.7 :foreground "#887"))))
                          '(org-formula ((t (:inherit org-table :foreground nil))))
                          ))

(ample-flat)

0

मेरे द्वारा संपादित किए गए spacemacs-darkउदाहरणों में से कुछ को हटाकर, मुझे पसंद नहीं है:

  ;; on dotspacemacs/user-config:

  ;; configure spacemacs-dark theme, specifically removing bolds
  (let
      ((func "#d75fd7")
       (keyword "#4f97d7")
       (type "#ce537a"))

    (custom-theme-set-faces
     'spacemacs-dark
     `(font-lock-function-name-face ((t (:foreground ,func :inherit normal))))
     `(font-lock-keyword-face ((t (:foreground ,keyword :inherit normal))))
     `(font-lock-type-face ((t (:foreground ,type :inherit normal))))
     )
    )

0

आपके लिए सिर्फ अपना उपयोग करना SPC SPC custom-theme-visit-theme, ढूंढना gruvbox, अपना संपादन करना और फिर (load-file "~/.emacs.d/gruvbox-theme.el")अपने dotspacemacs/user-configकार्य में जगह बनाना आसान हो सकता है ।

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.