@alvaro
sign in · lmno.lol

Emacs smartparens auto-indent

While I do most editing in Emacs, I use Xcode every now and then. I like Xcode's pair matching (of brackets) combined with its auto-indent.

While the wonderful smartparens gives Emacs pair-matching powers, it doesn't automatically indent between pairs (out of the box anyway).

Luckily, smartparens does provide sp-local-pair, which enables us to achieve a similar goal.

With a short snippet, we can autoindent between {}, [], and () when pressing return in-between.

(defun indent-between-pair (&rest _ignored)
  (newline)
  (indent-according-to-mode)
  (forward-line -1)
  (indent-according-to-mode))

(sp-local-pair 'prog-mode "{" nil :post-handlers '((indent-between-pair "RET")))
(sp-local-pair 'prog-mode "[" nil :post-handlers '((indent-between-pair "RET")))
(sp-local-pair 'prog-mode "(" nil :post-handlers '((indent-between-pair "RET")))

comments on twitter

[2020-03-20 Fri] Solarpunk bookmarks


id: solarpunk-bookmarks

[2020-03-10 Tue] sqlite bookmarks


id: sqlite-bookmarks

[2020-02-26 Wed] covid-19 bookmarks


id: covid-19-bookmarks

[2020-02-15 Sat] Security bookmarks


id: security-bookmarks

[2020-02-15 Sat] Nix bookmarks


id: nix-bookmarks

[2020-01-10 Fri] Plants bookmarks


id: plants-bookmarks

[2019-12-29 Sun] Fixing Honeywell CM927's dead screen


id: fixing-honeywell-cm927-dead-screens

My Honeywell CM927 thermostat's screen had been getting progressively worse over the last year. As of late, the screen was of little use.

A random search yielded the Honeywell CM927 LCD screen fail - common? thread, with a promising comment by Phil:

"Strip the unit and remove the circuit board (just a few plastic clips, no screws). Remove the LCD assembly from the circuit board (more plastic clips and an eight pin push connection). Removed the LCD unit from the clear plastic housing (more plastic clips). Finally heat up the plastic ribbon where it is stuck to the circuit board (hair dryer will do trick) and then firmly press it onto the circuit board… probably worth doing this several times; in effect you are remating the ribbon to the circuit board by softening the adhesive. Put it all back together and it should be working again."

Phil's instructions were great. There's also a super handy video by El Tucan, also linked by Stevie.

Success ø/

Heating up the plastic ribbon and pressing it onto the circuit board did the trick for me. Took a few tries for all segments to appear, but the screen is looking great again.

Thank you Internet strangers! :)

[2019-12-29 Sun] SwiftUI bookmarks


id: swiftui-bookmarks

[2019-12-17 Tue] Studying for Life in the UK test


id: studying-for-life-in-the-uk-test

Today, I passed the Life in the UK test. Wasn't quite sure how to study for it. During my commutes, I listened to the Life in the UK 2019 Test audio book.

A friend recommended lifeintheuktestweb.co.uk. Overall, I found their practice tests very useful. Taking a bunch tests helped me internalize the material.

Took some notes along the way (mostly data with years attached) and dumped it into an org table. This helped me form a mental timeline.

NOTE: These tables alone are not comprehensive enough to prepare for the exam. You'll need to know additional information without dates attached.

Events

Year Event


2012 Diamond Jubilee 1999 Scottish Parliament formed 1973 UK joins the EU ø/ 1972 Mary Peters wins Gold medal (pentathlon) 1957 Treaty of Rome signed (March 25) 1950 UK signs European Convention of Human Rights 1949 Ireland become a republic 1947 Granted independence India, Pakistan and Ceylon (Sri Lanka) 1945 Clement Attlee elected 1945 Alexander Fleming discovers penicillin 1945 WWII ends 1944 Butler Act (free secondary education England/Wales) 1940 Battle of Britain 1939 Germany invades Poland 1930s Turing Machine 1936 BBC first regular television service 1932 First television broadcast 1930 British Film Studios Fluorish 1928 Women/men with same voting age 1918 WWI ends (November 11, 11am) 1903 Emmeline Pankhurst Women’s Social and Political Union (suffragettes) 1902 Motor-car racing in UK 1896 First film shown publicly 1899-1902 The Boer War (South Africa) 1870-1914 120000 Russian and Polish Jews fled to Britain to escape prosecution 1853-1856 Crimean War 1851 Great Exhibition (showcased Crystal Palance) 1837 Queen Victoria becomes queen (at 18) 1833 Emancipation Act (abolished slavery throughout British Emprire) 1832 The Reform Act (increase number of people with voting rights) 1776 North American colonies want out (don't tax us without representation) 1745 Bonnie Prince Charlie gets support by clansmen from Scottish highlands 1714 Queen Ann dies, George I becomes King 1689 Bill of rights (limit rights of kings) 1688 William of Orange invades England (proclaims king) 1680-1720 Huguenots refugees came to England (from France) 1695 Free press (newspapers) established 1679 Habeas Corpus Act (right to trial) 1649-1660 Cromwell rules republic for 11 years (Charles I executed) 1642 English Civil war (Cavaliers vs Roundheads) 1606 Union flag created 1588 English beat Spanish Armada 1348 Black death (third population die) 1314 Battle of Bannockburn: Robert the Bruce (Scottish King) beats English invasion 1284 Statute of Rhuddlan (Wales joins Crown, by King Edward I) 1215 Magna Carta created 1066 Norman Conquest (Saxon King Harold killed by William I) 300-400 AD Christians appear in Britain 789 AD Vikings first visit Britain and raid coastal towns 6000 years ago Farmers come to Britain

Population

Year Population


2010 > 62 million 2005 < 60 million 1998 57 million 1951 50 million 1901 40 million 1851 20 million 1700 5 million 1600 > 4 million

[2019-12-01 Sun] Georgia travel bookmarks


id: georgia-travel-bookmarks

[2019-11-24 Sun] Wizard zines comics in Emacs eshell


id: wizard-zines-comics-eshell-util

Over at wizardzines.com, Julia Evans authors wonderful zines on topics like git, networking, linux, command-line utilities, and others. Some zines are paid. Some are free. No affiliation here, just a fan.

A little while ago, Julia tweeted about a utility she's building to view her original comics on similar topics. I instantly thought it'd be a fun tool to implement for Emacs eshell.

Since then, I subscribed to wizardzines.com/saturday-comics and received a few comics (awk, tar, and bash tricks). I saved them locally (using topic name and dropping file extensions).

ls -1 ~/Downloads/wizardzines-comics/

awk bash tar

By no means battle-tested, but here's an elisp snippet defining the ecomic command. It displays inlined comics in the handy eshell.

(require 'eshell)
(require 'iimage)

(defvar wizardzines-comics-path "~/Downloads/wizardzines-comics")

(defun eshell/ecomic (&rest args)
  "Display command comic in ARGS.
Note: ensure comic images live in `wizardzines-comics-path', named with
command name and no extension."
  (eshell-eval-using-options
   "ecomic" args
   '((?h "help" nil nil "show this usage screen")
     :external "ecomic"
     :show-usage
     :usage "COMMAND

Show COMMAND comic from Julia Evans' https://wizardzines.com/saturday-comics")
   (let* ((command (nth 0 (eshell-stringify-list (eshell-flatten-list args))))
          (image-fpath (concat (file-name-as-directory
                                (expand-file-name wizardzines-comics-path))
                               command)))
     (unless (file-exists-p image-fpath)
       (error "comic: \"%s\" not found :-(" command))
     (eshell-buffered-print "\n")
     (add-text-properties 0 (length image-fpath)
                          `(display ,(create-image image-fpath)
                                    modification-hooks
                                    (iimage-modification-hook))
                          image-fpath)
     (eshell-buffered-print image-fpath)
     (eshell-flush))))

comments on twitter

Updates