emacs 27 has an update to emacs’ tetris mode which makes the glyphs display larger on higher DPI screens.

This script will download that update from git.savannah.gnu.org and display tetris in a distraction free environment for the ultimate productivity.

If you symlink this script to etetris-vt100 and run that instead, you will get the animated and striking black and white terminal version.

1
ln -s etetris etetris-vt100

If you symlink this script to etetris-xterm and run that instead, you will get the vivid color terminal version.

1
ln -s etetris etetris-xterm

Mappings

key binding function
h left move left
j down move down faster
k up rotate
l right move right
Space drop

The script etetris

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
sn="$(basename "$0")"

if test "$sn" = "etetris-xterm"; then
    nw=" -nw "
elif test "$sn" = "etetris-vt100"; then
    nw=" -nw "
    export TERM=vt100
else
    extra="(load \"/tmp/tetris-load.el\")"
fi

cat <<HEREDOC > /tmp/tetris-load.el
(defun str (thing)
  "Converts object or string to an unformatted string."
  (setq thing (format "%s" thing))
  (set-text-properties 0 (length thing) nil thing)
  thing)

(defun my-new-buffer-frame (&optional contents bufname)
  "Create a new frame with a new empty buffer."
  (interactive)
  (if (not bufname)
      (setq bufname "*untitled*"))
  (let ((buffer (generate-new-buffer bufname)))
    (set-buffer-major-mode buffer)
    ;; (display-buffer buffer '(display-buffer-pop-up-frame . nil))
    (display-buffer buffer '(display-buffer-same-window . nil))
    (with-current-buffer buffer
      (insert (str contents))
      (beginning-of-buffer))
    buffer))
(defalias 'new-buffer-from-string 'my-new-buffer-frame)

(defun buffer2string (buffer)
  (with-current-buffer buffer
    (save-restriction
      (widen)
      (buffer-substring-no-properties (point-min) (point-max))
      ;;(buffer-substring-no-properties buffer (point-min) (point-max))
      )))

(defun ecurl (url)
  (with-current-buffer (url-retrieve-synchronously url t t 5)
    (goto-char (point-min))
    (re-search-forward "^$")
    (delete-region (point) (point-min))
    (kill-line)
    (let ((result (buffer2string (current-buffer))))
      (kill-buffer)
      result)))

;; It's the time period. The closer to 0, the faster.
(defun my-tetris-update-speed-function (_shapes rows)
  ;; (/ 20.0 (+ 50.0 rows))
  (/ 20.0 (+ 40.0 rows)))

(custom-set-variables
 '(tetris-width 10)
 '(tetris-height 25)
 '(tetris-buffer-width 30)
 '(tetris-buffer-height 27)
 '(tetris-update-speed-function 'my-tetris-update-speed-function))

(require 'tetris)

(define-key tetris-mode-map (kbd "k") (kbd "<up>"))
(define-key tetris-mode-map (kbd "j") (kbd "<down>"))
(define-key tetris-mode-map (kbd "h") (kbd "<left>"))
(define-key tetris-mode-map (kbd "l") (kbd "<right>"))

(defun load-tetris-update ()
  (with-current-buffer
    (new-buffer-from-string
      (ecurl "http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/play/gamegrid.el"))
    (eval-buffer (current-buffer))
    (kill-buffer)))

(load-tetris-update)
HEREDOC

# (execute-kbd-macro (kbd \"C-l\"))

read -r -d '' elisp_command <<HEREDOC
(progn
  $extra
  (define-key global-map (kbd "q") #'save-buffers-kill-terminal)
  (tool-bar-mode -1)
  (menu-bar-mode -1)
  (call-interactively 'tetris)
  (setq mode-line-format '())
  (message ""))
HEREDOC

emacs $nw -q --eval "$elisp_command"