Skip to content

Instantly share code, notes, and snippets.

@rougier
Created May 10, 2020 02:43
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save rougier/e0f13cc4468727d99b693e5f48a09e18 to your computer and use it in GitHub Desktop.
Save rougier/e0f13cc4468727d99b693e5f48a09e18 to your computer and use it in GitHub Desktop.
A very minimal but elegant emacs configuration file
(require 'org)
(setq-default indent-tabs-mode nil)
(setq org-display-inline-images t)
(setq org-redisplay-inline-images t)
(setq org-startup-with-inline-images "inlineimages")
(setq default-frame-alist
(append (list '(width . 72) '(height . 40))))
(setq org-confirm-elisp-link-function nil)
(global-set-key [(control z)] 'undo)
(global-set-key "\C-x\C-x" 'execute-extended-command)
(set-frame-font "Roboto Mono Light 14")
(set-frame-parameter (selected-frame) 'internal-border-width 20)
(setq x-underline-at-descent-line t)
(setq initial-major-mode 'text-mode)
(setq-default line-spacing 0)
(set-default 'cursor-type '(hbar . 2))
(blink-cursor-mode 0)
(fringe-mode '(0 . 0))
(setq frame-background-mode 'light)
(set-background-color "#ffffff")
(set-foreground-color "#666666")
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t) ;; Show/hide startup page
(setq initial-scratch-message nil) ;; Show/hide *scratch* buffer message
;; (menu-bar-mode 0) ;; Show/hide menubar
(tool-bar-mode 0) ;; Show/hide toolbar
(tooltip-mode 0) ;; Show/hide tooltip
(scroll-bar-mode 0) ;; Show/hide scrollbar
(defun mode-line-render (left right)
"Return a string of `window-width' length containing left, and
right aligned respectively."
(let* ((available-width (- (window-total-width) (length left) )))
(format (format "%%s %%%ds" available-width) left right)))
(setq-default header-line-format
'(:eval (mode-line-render
(format-mode-line
(list
(propertize "File " 'face `(:weight regular))
"%b "
'(:eval (if (and buffer-file-name (buffer-modified-p))
(propertize "(modified)"
'face `(:weight light
:foreground "#aaaaaa"))))))
(format-mode-line
(propertize "%3l:%2c "
'face `(:weight light :foreground "#aaaaaa"))))))
(set-face-attribute 'region nil
:background "#f0f0f0")
(set-face-attribute 'highlight nil
:foreground "black"
:background "#f0f0f0")
(set-face-attribute 'org-level-1 nil
:foreground "black"
:weight 'regular)
(set-face-attribute 'org-link nil
:underline nil
:foreground "dark blue")
(set-face-attribute 'org-verbatim nil
:foreground "dark blue")
(set-face-attribute 'bold nil
:foreground "black"
:weight 'regular)
(setq-default mode-line-format "")
(set-face-attribute 'header-line nil
;; :weight 'regular
:height 140
:underline "black"
:foreground "black"
:background "white"
:box `(:line-width 3 :color "white" :style nil))
(set-face-attribute 'mode-line nil
:height 10
:underline "black"
:background "white"
:foreground "white"
:box nil)
(set-face-attribute 'mode-line-inactive nil
:box nil
:inherit 'mode-line)
(set-face-attribute 'mode-line-buffer-id nil
:weight 'light)
(setq org-hide-emphasis-markers t)
@rougier
Copy link
Author

rougier commented May 10, 2020

See reddit post. Start with:

$ emacs -q -l clean.el +25 welcome.org

Where welcome.org is:

*Welcome to Emacs*
 
  Emacs is an  extensible, customizable, free/libre text  editor — and
  more. At its core is an interpreter for Emacs Lisp, a dialect of the
  Lisp programming language with extensions to support text editing.

*Quick help*

  Learn basic Emacs keystroke commands ...................... [[elisp:help-with-tutorial][Tutorial]]
  See an overview of Emacs features at [[https://gnu.org][gnu.org]] ........... [[https://www.gnu.org/software/emacs/tour][Guided Tour]]
  Read the extensive documentation ..................... [[info:emacs][Documentation]]
  Search for an answer ................................ [[https://emacs.stackexchange.com][Stack Exchange]]

*Quick commands*        /C is for Control, M is for Meta (Alt or Command)/

  Save ............... =[C-x]= =[C-s]=    Help ..................... =[C-h]=
  Save as ............ =[C-x]= =[C-w]=    Cancel ................... =[C-g]=
  Open a new file .... =[C-x]= =[C-f]=    Undo ................. =[C-x]= =[u]=
  Close buffer ....... =[C-x]= =[C-k]=    Quit ............... =[C-x]= =[C-c]=
  

                       [[elisp:(kill-buffer%20(current-buffer))][ *— Close this buffer —* ]]

@rougier
Copy link
Author

rougier commented May 10, 2020

@weird-ego
Copy link

(setq-default mode-line-format "") -> (setq-default mode-line-format '(""))
otherwise some modes, such as eshell will not run

@phikal
Copy link

phikal commented May 10, 2020

Why even use org, and modify display-startup-screen/the functions it calls?

Generally speaking, this looks like a very interesting redesign, and suggesting something along these lines on the mailing list would be worth a try, but I don't think it should change keybindings (C-z, C-x C-x), play around too much with the mode/header line, etc.

Also, I think C-/ is usually preferred over C-x u. Or at least I prefer it.

@cireu
Copy link

cireu commented May 11, 2020

Why even use org, and modify display-startup-screen/the functions it calls?

Generally speaking, this looks like a very interesting redesign, and suggesting something along these lines on the mailing list would be worth a try, but I don't think it should change keybindings (C-z, C-x C-x), play around too much with the mode/header line, etc.

Also, I think C-/ is usually preferred over C-x u. Or at least I prefer it.

C-/ is unavailable in terminal, C-_ maybe better

@phikal
Copy link

phikal commented May 11, 2020

C-/ is unavailable in terminal, C-_ maybe better.

Which in turn is another argument to generate such a screen programmatically.

@rougier
Copy link
Author

rougier commented May 11, 2020

Thanks for the feedback. I've created a repository at https://github.com/rougier/elegant-emacs. I'm no expert at lisp nor emacs so I imagine there's room for improvement as you've already suggested.

@bvk
Copy link

bvk commented Aug 6, 2020

Could you please improve the display when there is a vertical split? Thanks.

@rougier
Copy link
Author

rougier commented Aug 6, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment