2012-04-20 13 views
5

मैं सामान्य रूप से एचएल-लाइन को वर्तमान पृष्ठभूमि की थोड़ा गहरा छाया लेता हूं। यह संपादन बफर में अच्छा काम करता है। हालांकि, कुछ बफर में, जैसे ऑर्ग एजेंडा और ग्नस समूह बफर, मैं एक और अधिक स्पिफी रंग (कर्सर के स्थान पर) का उपयोग करना चाहता हूं।Emacs hl-line: स्थानीय रूप से रंग बदलें

विशिष्ट होने के लिए मैं अन्य बफर में एचएल-लाइन के रंग को प्रभावित करने वाले के बिना gnus-hl-line में एचएल-लाइन का रंग बदलना चाहता हूं।

(add-hook 'gnus-summary-mode-hook 'gnus-hl-line) 
(add-hook 'gnus-group-mode-hook 'gnus-hl-line) 

(defun gnus-hl-line() 
    (hl-line-mode 1) 
    (set (make-local-variable 'line-move-visual) nil) 
    (setq cursor-type nil)) 

धन्यवाद,

अंतिम समाधान फिल के सुझाव का उपयोग कर। यह ज्यादातर समय एक तटस्थ एचएल लाइन का उपयोग करता है, लेकिन कभी-कभी एक बोल्ड एचएल-लाइन सराहनीय है, उदाहरण के लिए Gnus और संगठन के एजेंडे में

;; From emacs-wiki: 
(defun shade-color (intensity) 
    "print the #rgb color of the background, dimmed according to intensity" 
    (interactive "nIntensity of the shade : ") 
    (apply 'format "#%02x%02x%02x" 
     (mapcar (lambda (x) 
        (if (> (lsh x -8) intensity) 
         (- (lsh x -8) intensity) 
        0)) 
       (color-values (cdr (assoc 'background-color (frame-parameters))))))) 

;; Default hl 
(global-hl-line-mode t) 
(make-variable-buffer-local 'global-hl-line-mode) 
(set-face-background hl-line-face (shade-color 08)) 

(defface hl-line-highlight-face 
    '((t :inherit highlight)) 
    "Face for highlighting the current line with `hl-line-fancy-highlight'." 
    :group 'hl-line) 

(defun hl-line-fancy-highlight() 
    (set (make-local-variable 'hl-line-face) 'hl-line-highlight-face) 
    ;; (set (make-local-variable 'line-move-visual) nil) 
    ;; (set (make-local-variable 'cursor-type) nil) 
    (setq global-hl-line-mode nil) 
    (hl-line-mode)) 

(add-hook 'org-agenda-mode-hook 'hl-line-fancy-highlight) 
(add-hook 'gnus-summary-mode-hook 'hl-line-fancy-highlight) 
(add-hook 'gnus-group-mode-hook 'hl-line-fancy-highlight) 
+0

क्या आप कृपया बता सकते हैं कि कोड में क्रमशः ऑर्ग-एजेंडा, gnus-summary और gnus-group के लिए तीव्रता * और * रंग कहां सेट कर सकता है? धन्यवाद! वास्तव में –

उत्तर

4

hl-line-face चेहरा hl-line-mode के लिए उपयोग करने के लिए युक्त एक चर रहा है, तो हम उस चर इन मोड में बफर-स्थानीय बनाना, और यह एक नए कस्टम चेहरा असाइन कर सकते हैं।

आप इस तरह एक नया चेहरा बना सकते हैं:

(defface gnus-hl-line 
    '((t :inherit hl-line)) 
    "Face for highlighting the current line with `gnus-hl-line'." 
    :group 'hl-line) 

और के साथ अनुकूलित एमएक्सcustomize-faceआरईटीgnus-hl-lineआरईटी

फिर अपने gnus-hl-line समारोह में इस ऐड (hl-line-mode कॉल करने से पहले सबसे समझदार प्रतीत होता है)।

(set (make-local-variable 'hl-line-face) 'gnus-hl-line) 
+0

। धन्यवाद! – Rasmus