Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A very minimal emacs configuration
;; nano.el -- A very minimal emacs
;; Usage: emacs -q -l nano.el
;; Copyright (C) 2020 Nicolas .P Rougier
;; Author: Nicolas P. Rougier <>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <>.
(setq default-frame-alist
(append (list
'(font . "Roboto Mono Light 14")
;; '(unsplittable . t)
;; '(buffer-predicate . (lambda (x) nil))
'(min-height . 1)
'(height . 42)
'(min-width . 40)
'(width . 74)
'(foreground-color . "#333333")
'(background-color . "#ffffff")
'(cursor-color . "black")
'(internal-border-width . 1)
'(vertical-scroll-bars . nil)
'(left-fringe . 32)
'(right-fringe . 32)
'(tool-bar-lines . 0)
'(menu-bar-lines . 0))))
(setq inhibit-startup-screen t
inhibit-startup-message t
inhibit-startup-echo-area-message t
initial-scratch-message nil)
(tool-bar-mode 0)
(menu-bar-mode t)
(tooltip-mode 0)
(setq org-hide-emphasis-markers t)
(set-face-attribute 'mode-line nil
:height 0.5
:foreground "#999977"
:background "#ffffff"
:overline nil
:underline nil
:box nil)
(set-face-attribute 'mode-line-inactive nil
:height 0.5
:foreground "#999977"
:background "#ffffff"
:overline nil
:underline nil
:inherit nil
:box nil)
(set-face-attribute 'header-line nil
:weight 'light
:foreground "#000000"
:background "#f0f0f0"
:overline nil
:underline nil
:box nil
:box `(:line-width 1 :color "#ffffff" :style nil)
:inherit nil)
(set-face-attribute 'internal-border nil
:background "#777777")
(set-face-attribute 'fringe nil
:foreground "#cccccc"
:background "#ffffff")
(set-face-attribute 'bold nil
:weight 'medium)
(defun header-line-render (left right)
(let* ((available-width (- (window-total-width) (length left) )))
(format (format "%%s%%%ds" available-width) left right)))
(setq-default header-line-format
(cond ((and buffer-file-name (buffer-modified-p)) " [M] ")
(buffer-read-only " [RO] ")
(t " "))
(propertize "%b" 'face '(:weight regular))
" (%m)"
(propertize " " 'display '(raise +0.25))
(propertize " " 'display '(raise -0.30))))
(list "%l:%c "))))))
(setq-default mode-line-format "%-")
(defun update-buffers-mode-line ()
(dolist (window (window-list))
(with-selected-window window
(if (or (one-window-p t)
(eq (window-in-direction 'below) (minibuffer-window))
(not (window-in-direction 'below)))
(with-current-buffer (window-buffer window)
(setq mode-line-format "%-"))
(with-current-buffer (window-buffer window)
(setq mode-line-format nil)))
(if (window-in-direction 'above)
(face-remap-add-relative 'header-line '(:overline "#777777"))
(face-remap-add-relative 'header-line '(:overline nil))))))
(add-hook 'window-configuration-change-hook 'update-buffers-mode-line)
(dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
" *Minibuf-1*" " *Echo Area 1*"))
(when (get-buffer buffer)
(with-current-buffer buffer
(face-remap-add-relative 'default '(:foreground "#999999")))))
;; (define-key global-map (kbd "M-q") 'kill-emacs)
(define-key global-map (kbd "M-n") 'make-frame)
;; (define-key global-map (kbd "M-w") 'delete-frame)
;; See
;; ... 2020-09-29_comprehensive_guide_on_handling_long_lines_in_emacs.html
(setq bidi-paragraph-direction 'left-to-right)
(if (version<= "27.1" emacs-version)
(setq bidi-inhibit-bpa t))
(if (version<= "27.1" emacs-version)
(global-so-long-mode 1))
(defun help-message ()
(let ((message-log-max nil))
"[C-x C-f] Open [M-w] Copy [C-w] Cut [C-s] Search —— "
(propertize "[C-g] Cancel" 'face '(:foreground "black"))
"[C-x C-s] Save [C-y] Paste [C-/] Undo [M-x] Command —— "
(propertize "[C-x C-c] Quit" 'face '(:foreground "black"))))
;; (message
;; (concat
;; "[⌘-O] Open [⌘-C] Copy [⌘-X] Cut [⌘-F] Search [⌘-H] Help "
;; (propertize "[Esc] Cancel" 'face '(:foreground "black"))
;; "\n"
;; "[⌘-S] Save [⌘-V] Paste [⌘-Z] Undo [⌘-R] Replace [⌘-P] Command "
;; (propertize "[⌘-Q] Quit" 'face '(:foreground "black"))))
(sit-for 30)))
(define-key global-map (kbd "C-h") 'help-message)
(setq minibuffer-prompt-properties
(quote (read-only nil
cursor-intangible t
face minibuffer-prompt)))
(defun nano-minibuffer-hook ()
(if (active-minibuffer-window)
(window-buffer (active-minibuffer-window))
(add-text-properties (point-min) (point-max)
`(display '(raise +0.25))))))
(defun nano-minibuffer-setup-hook ()
(add-hook 'post-command-hook 'nano-minibuffer-hook))
(defun nano-minibuffer-exit-hook ()
(remove-hook 'post-command-hook 'nano-minibuffer-hook))
(defun my-command-error-function (data context caller)
"Ignore some minor warnings."
(when (not (memq (car data) '(quit
beginning-of-line end-of-line
beginning-of-buffer end-of-buffer
end-of-file buffer-read-only)))
(command-error-default-function data context caller)))
(setq command-error-function #'nano-command-error-function)
(defun nano-message (orig-fun &rest args)
(let* ((msg (if (car args) (apply 'format-message args) ""))
(split (string-match "\n.*\\'" msg)))
(if split
(let ((part-1 (substring msg 0 split))
(part-2 (propertize (substring msg split)
'display '(raise +0.25))))
(apply orig-fun (list (concat part-1 part-2))))
(apply orig-fun (list (propertize msg 'display '(raise +0.25)))))))
(add-hook 'minibuffer-setup-hook 'nano-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook 'nano-minibuffer-exit-hook)
(advice-add 'message :around #'nano-message)

This comment has been minimized.

Copy link
Owner Author

@rougier rougier commented Oct 2, 2020


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