在 Emacs 中设置默认字体

在 Emacs 中设置默认字体

我在 Linux 上将 emacs 23.2.1 与 quack 结合使用,并尝试将我的默认字体设置为 Inconsolata Medium 13。它安装在我的系统(debian sid)上,可以在 emacs 中根据缓冲区手动设置。

但是,我希望它始终被默认使用。我怀疑 Quack 的模式存在某种冲突。

我搜索了很多关于 emacs 中字体自定义的信息。虽然有文档和示例,但我发现它们放在一起时相当不连贯,没有具体解决这个问题。

这是我的 .emacs

(set-default-font "Inconsolata-13")

;;; Turn on visible-bell, get rid of beeps
(setq visible-bell t)

;;; Hilight the selected region
(setq transient-mark-mode t)

;;; Get rid of tool-bar
(tool-bar-mode -1)

;;; Show matched parens
(show-paren-mode 1)

;;; Avoid iconizing emacs.
(global-unset-key "\C-z")

;;; Jump to a specific line of the current buffer
(global-set-key "\M-g" 'goto-line)

;;; Tabs are evil?
;;; Use spaces instead of tabs for indentation.
(setq indent-tabs-mode nil) 

;;; Turn on syntax-highlighting.
(global-font-lock-mode t)
(load-library "font-lock")
(setq font-lock-maximum-decoration t)

;;; load xscheme library

(require 'xscheme)

;;; Scheme-specific customization

;;; Load the Quack mode, which is an advanced Scheme mode.
(require 'quack)

;;; Loading/creating a file/buffer whose name ends with '.ss'
;;; automagically switches Emacs to Scheme mode.
(setq auto-mode-alist (cons '("\\.ss" . scheme-mode) auto-mode-alist))

;;; Change the program name string below to point to Petite Chez
;;; Scheme on your machine.  For example, Will uses the string
;;; "/usr/bin/petite" on his laptop running Mac OS X.
(setq scheme-program-name "mit-scheme")

;;; Teach Emacs how to properly indent
;;; certain Scheme special forms
;;; (such as 'pmatch')
(put 'cond 'scheme-indent-function 0)
(put 'for-each 'scheme-indent-function 0)
(put 'pmatch 'scheme-indent-function 1)
(put 'match 'scheme-indent-function 1)
(put 'union-case 'scheme-indent-function 2)
(put 'cases 'scheme-indent-function 1)
(put 'let-values 'scheme-indent-function 1)
(put 'call-with-values 'scheme-indent-function 2)
(put 'syntax-case 'scheme-indent-function 2)
(put 'test 'scheme-indent-function 1)
(put 'test-check 'scheme-indent-function 1)
(put 'test-divergence 'scheme-indent-function 1)
(put 'make-engine 'scheme-indent-function 0)
(put 'with-mutex 'scheme-indent-function 1)
(put 'trace-lambda 'scheme-indent-function 1)
(put 'timed-lambda 'scheme-indent-function 1)
(put 'tlambda 'scheme-indent-function 1)


;;; For folks who like pretty colors on their screens:

(require 'color-theme)
(color-theme-initialize)
(color-theme-dark-blue2)

(if (fboundp 'global-font-lock-mode)
    (global-font-lock-mode 1); Emacs    
    (setq font-lock-auto-fontify t)); XEmacs

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(column-number-mode t)
 '(paren-blinking "t" t)
 '(paren-matching t t)
 '(quack-default-program "mit-scheme")
 '(quack-fontify-style (quote emacs))
 '(quack-pltish-fontify-keywords-p t)
 '(quack-pltish-keywords-to-fontify (quote ("and" "begin" "begin0" "c-declare" "c-lambda" "call-with-current-continuation" "call-with-input-file" "call-with-output-file" "call/cc" "case" "case-lambda" "class" "class*" "class*/names" "class100" "class100*" "compound-unit/sig" "cond" "cond-expand" "define" "define-macro" "define-module" "define-public" "define-signature" "define-struct" "define-syntax" "define-syntax-set" "define-values" "define-values/invoke-unit/sig" "define/contract" "define/override" "define/private" "define/public" "delay" "do" "else" "exit-handler" "field" "if" "import" "inherit" "inherit-field" "init" "init-field" "init-rest" "instantiate" "interface" "lambda" "let" "let*" "let*-values" "let+" "let-syntax" "let-values" "let/ec" "letrec" "letrec-values" "letrec-syntax" "match" "match-lambda" "match-lambda*" "match-let" "match-let*" "match-letrec" "match-define" "mixin" "module" "opt-lambda" "or" "override" "override*" "namespace-variable-bind/invoke-unit/sig" "parameterize" "private" "private*" "protect" "provide" "provide-signature-elements" "provide/contract" "public" "public*" "quote" "receive" "rename" "require" "require-for-syntax" "send" "send*" "set!" "set!-values" "signature->symbols" "super-instantiate" "syntax-case" "syntax-case*" "syntax-error" "syntax-rules" "unit/sig" "unless" "when" "with-handlers" "with-method" "with-syntax")))
 '(quack-pretty-lambda-p nil)
 '(quack-programs (quote ("petite" "bigloo" "csi" "gosh" "gsi" "guile" "kawa" "mit-scheme" "mred -z" "mzscheme" "mzscheme -M errortrace" "rs" "scheme" "scheme48" "scsh" "sisc" "stklos" "sxi")))
 '(quack-remap-find-file-bindings-p nil)
 '(quack-run-scheme-always-prompts-p nil)
 '(quack-switch-to-scheme-method (quote cmuscheme)))

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "#233b5a" :foreground "#fff8dc" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 109 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))
 '(quack-pltish-comment-face ((((class color) (background dark)) (:slant italic))))
 '(quack-pltish-defn-face ((t (:foreground "purple1" :weight bold))))
 '(quack-pltish-keyword-face ((t (:foreground "cyan"))))
 '(quack-pltish-paren-face ((((class color) (background dark)) (:foreground "cyan3"))))
 '(quack-pltish-selfeval-face ((((class color) (background dark)) (:foreground "green"))))
 '(quack-threesemi-semi-face ((((class color) (background dark)) (:background "white" :foreground "white" :box nil))))
 '(quack-threesemi-text-face ((((class color) (background dark)) (:background "cyan4" :foreground "white" :box nil)))))

答案1

我也使用不同的字体,我的 .emacs 中的命令是

(set-face-font 'default "-misc-fixed-medium-r-normal--20-*-*-*-c-100-iso8859-1")

答案2

虽然这可能无法帮助您使特定字体正常工作,但我希望您会发现它总体上很有用。

为了便于移植,我已将其放入我的 .emacs(我在许多系统中使用它)。它从列表中搜索给定的字体,并将找到的任何字体应用到默认字体中。

我对于非 Lisp 风格的循环表示抱歉;这已经是很久以前的事了。

(defun font-existsp (font)
  "Check that a font exists: http://www.emacswiki.org/emacs/SetFonts#toc8"
  (and (window-system)
       (fboundp 'x-list-fonts)
       (x-list-fonts font)))

;;**************************************************
;; font Searching
;;**************************************************
(setq kjfletch-font-list
      '(;; List of fonts to search for in order of priority.
        ;; Each has it's own line for easy transposing.
        "Consolas-10"
        "ProggyOpti-8"
        "ProggyOptiS-8"
        "ProggyClean-10"
        "Consolas-8"
        "DejaVu Sans Mono-8"
        ;; "Lucida Console-8"
        "Courier New-8"
        ))

(let* ((in-loop t)
       (font (car kjfletch-font-list))
       (rest (cdr kjfletch-font-list)))
  (while (and font in-loop)
    (when (font-existsp font)
      (set-face-attribute 'default nil :font font)
      (setq in-loop nil))
    (setq font (car rest)
          rest (cdr rest))))

相关内容