.emacs-my
changeset 1541 dca10cecc9e2
parent 1540 e3000459f683
child 1542 29783921b4f7
equal deleted inserted replaced
1540:e3000459f683 1541:dca10cecc9e2
   433   )
   433   )
   434 
   434 
   435 ;; See what I am typing immediately (for keystroke in minibuffer).
   435 ;; See what I am typing immediately (for keystroke in minibuffer).
   436 (setq echo-keystrokes 0.2)
   436 (setq echo-keystrokes 0.2)
   437 
   437 
       
   438 (defun my-dpi ()
       
   439   (let* ((attrs (car (display-monitor-attributes-list)))
       
   440          (size (assoc 'mm-size attrs))
       
   441          (sizex (cadr size))
       
   442          (res (cdr (assoc 'geometry attrs)))
       
   443          (resx (- (caddr res) (car res)))
       
   444          dpi)
       
   445     (catch 'exit
       
   446       ;; in terminal
       
   447       (unless sizex
       
   448         (throw 'exit 10))
       
   449       ;; on big screen
       
   450       (when (> sizex 1000)
       
   451         (throw 'exit 10))
       
   452       ;; DPI
       
   453       (* (/ (float resx) sizex) 25.4))))
       
   454 
       
   455 (defun my-preferred-font-size ()
       
   456   (let ( (dpi (my-dpi)) )
       
   457   (cond
       
   458     ((< dpi 110) 10)
       
   459     ((< dpi 130) 11)
       
   460     ((< dpi 160) 12)
       
   461     (t 12))))
       
   462 
       
   463 (defvar my-preferred-font-size (my-preferred-font-size))
       
   464 
       
   465 (defvar my-regular-font
       
   466   (cond
       
   467    ((eq window-system 'x) (format "DejaVu Sans Mono-%d:weight=normal" my-preferred-font-size))
       
   468    ((eq window-system 'w32) (format "Courier New-%d:antialias=none" my-preferred-font-size))))
       
   469 (defvar my-symbol-font
       
   470   (cond
       
   471    ((eq window-system 'x) (format "DejaVu Sans Mono-%d:weight=normal" my-preferred-font-size))
       
   472    ((eq window-system 'w32) (format "DejaVu Sans Mono-%d:antialias=none" my-preferred-font-size))))
       
   473 
   438 (cond
   474 (cond
   439  ((eq window-system 'x)
   475  ((eq window-system 'x)
   440   (if (and (fboundp 'find-font) (find-font (font-spec :name "DejaVu Sans Mono-11:weight=normal")))
   476   (if (and (fboundp 'find-font) (find-font (font-spec :name my-regular-font)))
   441       (set-frame-font "DejaVu Sans Mono-11")
   477       (set-frame-font my-regular-font)
   442     (set-frame-font "7x14")))
   478     (set-frame-font "7x14")))
   443  ((eq window-system 'w32)
   479  ((eq window-system 'w32)
   444   (set-frame-font "Courier New-10:antialias=none")
   480   (set-frame-font my-regular-font)
   445   (set-fontset-font nil 'cyrillic "Courier New-10:antialias=none")
   481   (set-fontset-font nil 'cyrillic my-regular-font)
   446   (set-fontset-font nil 'greek "Courier New-10:antialias=none")
   482   (set-fontset-font nil 'greek my-regular-font)
   447   (set-fontset-font nil 'phonetic "Courier New-10:antialias=none")
   483   (set-fontset-font nil 'phonetic my-regular-font)
   448   (set-fontset-font nil 'symbol "DejaVu Sans Mono-10:antialias=none")))
   484   (set-fontset-font nil 'symbol my-symbol-font)))
   449 
   485 
   450 (fset 'yes-or-no-p 'y-or-n-p)
   486 (fset 'yes-or-no-p 'y-or-n-p)
   451 
   487 
   452 (when (boundp 'confirm-kill-emacs)
   488 (when (boundp 'confirm-kill-emacs)
   453   (setq confirm-kill-emacs 'y-or-n-p))
   489   (setq confirm-kill-emacs 'y-or-n-p))