🏠 About Now Archive Tags RSS

Newest posts:

The good side-window side

I want the content I am working on to be the centre of attention on my screen. I want as little scrolling as possible and most of the content I work with is taller than it is wide (code and org documents). On wide screens, buffers with shells, for version control, REPLs, help, info etc should therefore be on the side of the screen where it does not steal space from the main content. Since I read left to right, I like such windows to pop up on the right side where they do not disturb the flow of my reading of the main content. Emacs has the concept of side-windows that is useful for taming buffers that would otherwise pop up other places.

I set the width of my side-windows to 80 since man pages expect that and it works well for help and shells as well. To be able to have a (wo)man page and a shell, an info node and a REPL, or a shell, REPL and help buffer at the same time, I use slots to divide up the side-window if more than one special buffer is open. I have not included ansi-term in the buffer-list for side-windows since I use it only occasionally when I want more than one terminal, in which case I need to be able to manage its windows in the normal way. Usually, there is no need for a full terminal emulator, but I use Eshell a lot.

At home, my laptops and my external screen are 16:9 or 16:10 wide screens. At my desk at work, I have a 16:9 screen, a 16:10 screen and another 16:9 screen flipped 90 degrees to the portrait orientation. I usually use the tall screen for Emacs to minimise scrolling. Since the tall screen is slim (9:16), I would rather have side-windows in the bottom instead of overlapping the main window on the right side when I use that screen. Even with the side-windows at the bottom, the screen is a lot taller than the wide screens which is nice.

However, I spend most of my time at work not at my desk, but in two classrooms where I either use my laptop only with its built-in screen, duplicated to a large screen in front of the class or only with an external screen when sitting in the back (for ergonomics). And there are also meetings where I use the laptop's internal screen only. All of these screens are wider than they are tall, so I want my side-windows on the right again.

So I made a function that checks whether the height of the frame is larger than the width and if so, side-windows are put on the bottom of the screen where they belong on tall screens, but if the opposite is true, then they are put on the right where they make more sense on wide screens. I call this function when Emacs starts in my configuration to adapt the side-windows to the screen in use, but I also have a keybinding (C-z w) for it so after moving from a classroom or meeting to my desk or vise versa, I can get the side-windows where I want them without having to end my Emacs session. I often prepare a file at my desk that I am going to present in class with inter-present-mode or jot something in a file during class that I work on at my desk later, so it is useful to keep the session going.

Here is my function for deciding which side side-windows should be on:

(defun emo-side-window-side ()
  "Evaluates which side side-windows should be on based on whether the frame is in portrait or landscape orientation."
  (interactive)
  (let* ((side-window-side (if (> (frame-outer-height) (frame-outer-width))
                          'bottom 'right))
       (disp-buf-alist `(("\\*\\(Python\\|ielm\\|compilation\\).*\\*"
          (display-buffer-reuse-window display-buffer-in-side-window)
          (side . ,side-window-side)
          (slot . -1)
          (post-command-select-window . t)
          (window-width . 80))
("\\*\\(shell\\|.*eshell\\).*\\*"
          (display-buffer-reuse-window display-buffer-in-side-window)
          (side . ,side-window-side)
          (slot . 0)
          (post-command-select-window . t)
          (window-width . 80))
("\\*\\(help\\|info\\|man\\|woman\\|Agenda Commands\\|Org Agenda\\|Occur\\|Buffer.\\|xref\\).*\\*"
          (display-buffer-reuse-window display-buffer-in-side-window)
          (side . ,side-window-side)
          (slot . 1)
          (post-command-select-window . t)
          (window-width . 80)))))
  (setq display-buffer-alist disp-buf-alist)))

Tags

This site is built with org-static-blog which has a tags feature. To see all posts with a specific tag, use these links:

There are also RSS feeds for each tag:

Boot RaspberryPi OS on an NVME larger than 2TB

RaspberryPi OS boots from an EFI partition. On other hardware, an EFI partition is used with UEFI which demands that your disk is GPT-partitioned or a hybrid GPT with MBR. However, the RaspberryPi imager and the installer you get when pressing Shift at boot uses MBR. MBR is a way to partition a disk that we used in the 1980s and that made sense back then, but it has the unfortunate limitation that it cannot use disks larger than 2 TB. So when I bought my 4 TB NVME to use with my Raspberry Pi 5, I was unpleasantly surprised that after installing RaspberryPi OS light, I could only see a 2 TB disk.

There are various solutions floating around the internet to get around this problem, but most of them are unnecessarily complex. The RaspberryPi 5 can boot from a disk partitioned with a GPT partition table just fine. The problem is just to get the right partitions with the right data onto the disk since the installer insists on using 1980s technology which means that you cannot use it on large disks. In the early 80s, a large hard drive had 40 MB capacity, so 2TB seemed like science fiction. Who would need all that space when Macintosh System Software, a few programs like MacWrite and MacDraw and a dozen files could fit on a 800kB diskette? (The Double Density 3.5 inch floppy disks that gave 720kB space on MS-DOS delivered 800kB on a Mac.)

In addition to your NVME, you will also need a USB stick and an SD card. If you use a case like my Argon Neo, installing the NVME and SD-card demands a bit of disassembly. The reason we need two other devices is that we need to clone one of them to the NVME and to do that we need to boot from the other. Here is what you need to do to your NVME working:

  1. Insert the SD-card and the NVME in your case or hat or whatever you use and insert an ethernet cable connected to your router.
  2. Boot your RaspberryPi while repeatedly pressing down the shift key until you get to the Raspberry Pi screen that downloads the installer.
  3. Install RaspberryPi OS (light) on the SD card.
  4. Boot from the SD card. If the boot order is set to boot from NVME first, you may have to press Space when booting to get to the boot order screen first. Since RaspberryPi OS reboots once as part of the isntallation, you may have to go through the boot order screen twice, so be ready to press space again after the first boot. After the second boot, the SD card has got RaspberryPi OS and the root partition (/) has been expanded.
  5. Insert your USB stick into one of the blue USB3 ports.
  6. Boot your Raspberry Pi again and repeatedly press down shift until you get to the screen that downloads the installer.
  7. Install RaspberryPi OS on your USB-stick.
  8. When the Pi reboots, press space repeatedly to get to the boot order screen and select USB and boot.
  9. Be ready to press space repeatedly again since the Pi reboots once as part of the installation process and choose USB again to boot the USB stick and let it expand the root partition.
  10. When you have booted into the USB stick for the second time after the root partition has been expanded, open a terminal (or use the TTY if you used RPi light).
  11. Write sudo fdisk /dev/nvme0n1 to partition the NVME with fdisk.
  12. Press g to make a new GPT partition table. You may have to confirm that you want to remove an MS-DOS (MBR) partition table already there.
  13. Press n to make a new partition.
  14. Choose the default as the first sector by pressing return.
  15. Write +512M to make the size of the partition half a Gigabyte.
  16. Press t to change a partition.
  17. Choose the default 1 as the partition you want to change.
  18. Set its type to 1 (EFI System).
  19. Make a new partition with n.
  20. Accept the defaults since it will use the rest of the disk.
  21. Press w to write your changes to the disk.
  22. Write dd if=/dev/mmcblk0p1 of=/dev/nvme0n1p1 && sync and press return. This will clone the first partition, the EFI partiont, of the SD card onto the first partition of the NVME.
  23. Write dd if=/dev/mmcblk0p2 of=/dev/nvme0n1p2 && sync and press return. This will clone the second partition, the root partition, of the SD card onto the second partition of the NVME.
  24. Write sudo mount /dev/nvme0n1p1 /mnt to mount the EFI partition of the NVME to /mnt on your running system (from the USB stick).
  25. Write lsblk -f to get the UUID of the root partition of the NVME (/dev/nvme0n1p2).
  26. Open the file /mnt/cmdline.txt with sudo in a text editor. (I prefer to combine step 25 up to and including 33 since Emacs has a built in terminal multiplexer and tiling window manager, and it is easier to copy the UUID from one window in Emacs to another window than to try to remember a UUID from lsblk -f from before I opened Emacs. I also use tramp inside Emacs to open the files with sudo instead of opening emacs with sudo. If you use another text editor in a TTY, then you probably have to write the UUID down after running lsblk -f since your text editor will hide the output from that command when you launch it to edit the file, unless you use GNU screen or tmux.)
  27. Change where it says root=PARTUUID=somenumber to root=UUID= and write or paste the UUID from lsblk -f for /dev/nvme0n1p2.
  28. Save the file and exit the text editor if you use a TTY editor without a built in terminal multiplexer.
  29. Write sudo umount /mnt and press return to unmount the first partition.
  30. Write sudo mount /dev/nvme0n1p2 /mnt to mount the root partition from the NVME to /mnt on your running system (the USB stick). If it tells you the disk is busy, wait for it. It means that the disk is still writing even if it has tld the OS it has finished. If you fail to wait, then you cannot boot.
  31. Write lsblk -f again and note down the UUID of both /dev/nvme0n1p1 (the EFI partition) and /dev/nvme0n1p2 if you did not already note it down. (Or use a terminal multiplexer or Emacs to copy it over when you need it.)
  32. Open the file /mnt/etc/fstab in a text editor with sudo.
  33. Replace the part of the line that says PARTUUID=somenumber on the line where it says /boot/firmware with UUID= and write or paste the UUID number for /dev/nvme0n1p1 (the EFI partition).
  34. Do the same with line where it says /, but use the UUID for /dev/nvme0n1p2 (the root partition).
  35. Save the file and exit your text editor.
  36. Wait for a while to allow time for the nvme to write out the change. Turn off the RaspberryPi.
  37. Remove the SD card and the USB stick.
  38. Reboot the Raspberry Pi. It should now boot from the NVME. If the boot order is set to boot USB or SD Card first, you may have to press space when booting to boot from the NVME. In such a case, you should write sudo raspi-config in a terminal and go to Advanced Options, choose A4 Boot order, and choose B2 NVME/USB Boot … and then press OK and finish and reboot. It should now boot from the NVME. If something went wrong and you end up in an emergency shell, then reboot, insert the USB and SD card again, press space and try again.

I now have a 4TB NVME that boots my RaspberryPi 5. I also tried booting from SD card and using the NVME only as storage for a while, but it was slow and annoying, so it is really worth spending some time to get the Pi booting from the NVME. Hopefully, the RaspberryPi devs will change the imager and installer so they use the GPT partition scheme in the future. There is no reason to use MBR in the 21st century.

Inter-present-mode

A while ago, I wrote that I made a few functions to present from org mode to replace org-present which removes too many glyphs to be practical for my use. I thought it would be nice to use use-package to defer loading these functions until I need them, and I was curious about how to make a minor mode. So yesterday, I created a minor mode around those simple functions.

I made functions for starting the presentation, going forward, going backward and stopping the presentation, so turning it into a minor mode that is turned on and then have some functionality bound to a keymap, and which you then can turn off again was a very natural fit. I added the ability to customize a few things and have some ideas for more functionality to include and more things to customize.

Have a look at the Readme.org at Codeberg.org if you want to have a look or try it out. I might try to include it in a package archive in the future, but for now, you can install it with use-package's vc: keyword.

Presentation functions

I use Emacs at work to present in class. I teach basic IT technology, programming and development, so it is very useful to be able to run code blocks interactively and get them syntax highlighted. If I get questions from the students, I can change the code to explain other ways of doings things or show them how small changes can yield very different results. I also quite often add additional useful information from the students into the slides while presenting if they mention something worth noting. I have written about this before.

I have used org-present to present from Emacs Org files thus far. It has been good in many ways, but there have been a few annoyances as well. One thing that has bitten me many times is that it hides too many characters. This means that when I show things like == on screen (except in code blocks), it looks like =. This is very annoying when teaching programming. It also ruins org tables since it removes + which means that tables with vertical lines that are fully aligned normally show up misaligned. I have stopped using lines to separate headings and content in tables, but it is not ideal. I have used org-present for two years now, and there is no way to configure it to remove these annoyances, so I am ready to switch to something else.

Today, I found some time to look into this and made a few, simple functions that does exactly what I need and nothing more. It is just ten lines more than my previous configuration for org-present. And since it is part of my Emacs config, there is no need to install additional packages. I almost always start presentations from the the start with the title, so my emo-present-start function does that. There is a bit of a rough edge in that it shows metadata keywords like #+Title: and #+Options: toc: nil when I present the title. I might sandpaper that rough edge off in the future. Otherwise, it works better for me than org-present and with a lot fewer lines of code.

© Einar Mostad 2010 - 2025. Content is licensed under the terms of CC BY SA except code which is GNU GPL v3 or later.
Made with GNU Emacs, Org-Static-Blog, and Codeberg Pages on GNU/Linux.