Sorting Org Mode lists using a sequence of regular expressions

I manually categorize Emacs News links into an Org unordered list, and then I reorganize the list by using M-S-up (org-shiftmetaup) and M-S-down (org-shiftmetadown). I decide to combine or split categories depending on the number of links. I have a pretty consistent order. John Wiegley suggested promoting Emacs Lisp and Emacs development links at the top of the list. I like to sort the rest of the list roughly by interest: general links first, then Org, then coding, then other links at the bottom.

Here’s some code that sorts Org lists in a custom sequence, with unknown items at the bottom for easy re-ordering. It will take a list like:

- Other:
  - Link A
  - Link B
- Emacs development:
  - Link A
  - Link B
- Emacs Lisp:
  - Link A
  - Link B

and turn it into:

- Emacs Lisp:
  - Link A
  - Link B
- Emacs development:
  - Link A
  - Link B
- Other:
  - Link A
  - Link B
(defun my/org-sort-list-in-custom-order (order)
  "Sort the current Org list so that items are in the specified order.
ORDER is a list of regexps."
  (org-sort-list
   nil ?f
   (lambda ()
     (let ((case-fold-search t)
           (item
            (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+")
              (org-sort-remove-invisible (buffer-substring (match-end 0) (point-at-eol))))))
       (or (cl-position item order :test (lambda (a b) (string-match b a))) (1+ (length order)))))
   '<))

(defun my/emacs-news-sort-list ()
  (interactive)
  (my/org-sort-list-in-custom-order
   '("Emacs Lisp"
     "Emacs development"
     "Appearance"
     "Navigation"
     "Dired"
     "Org Mode"
     "Coding"
     "Calc"
     "Email and news"
     "Other"
     "Discussion"
     "Outside Emacs"
     "New packages?")))

One more little thing automated… The next thing would probably be to write some code that autocategorizes links based on an alist of (item . regexp) pairs, which would also reduce the need to re-sort the items afterwards. Still, this is good for dealing with manual categorization. =)

2017-12-19 Emacs news

Links from reddit.com/r/emacs, /r/orgmode, /r/spacemacs, Hacker News, planet.emacsen.org, YouTube, the changes to the Emacs NEWS file, and emacs-devel.

Weekly review: Week ending 2017-12-15

We managed to make it out to the playground this week. I bundled her into a snowsuit and she enjoyed the swing, slide, and seesaw. Back at home, she was interested in standing astride the balance bike a few times. She also enjoyed lifting heavy things over her head and tossing them down. I encouraged her to throw bags of lentils from her tower down to her rocking chair, which helped absorb the impact.

A- can open doorknobs now! She also figured out how to repeatedly squeeze and open scissors, and can cut all the way through an index card if I hold the card for her. She’s interested in picking things up with her toes like I do.

A- sorted cans of cat food by colour into five groups. It was fun seeing her look around and light up when she saw a matching can. She also put one of her toys onto a Duplo car, said “Ride!”, and rolled the car down a slope, so she’s getting the hang of wheels too. She likes rolling things down a slope to hit a target, and calling out what she hit if she missed her called shot.

Now that pottying is well-established, we decided to stop offering videos as an option for potty time. It wasn’t worth the momentary upset whenever she wanted to watch more videos of herself and we wanted her to move on to another activity. She still asks for them from time to time, but she also accepts being told stories or being read to. She seems to pick up words and ideas when we review her videos together, so maybe I’ll find another place in her routines for video review. I can select videos and put them in an album for her, and that might guide her activities for the afternoon too.

A- occasionally requests Cattus Petasatus while she’s on the potty, which amuses us greatly. The Cozy Classics version of Pride and Prejudice is a regular at bedtime, too.

A- strung quite a few words together in these groups of frequently associated thoughts. For example, she liked the picture I took of her when she was upset and she didn’t want to wake up. She often said, “Upset picture, cat pajamas, no wake up, ni (nurse) bed,” practically all in one breath. When I was pretending to sleep in the hopes of getting her to sleep before 5 AM, she repeated sentences like “Mama, read you. Lights on.”

She showed some interest in music this week. She sang parts of Baa Baa Black Sheep and the little ditty we made up about Put Away. She asked me to bring down the ukulele, and she played with the strings while we sang. It made up for not having been able to go to music classes these past few weeks.

A- liked carrying her stuffed sheep around in a sling, carefully tucking a small blanket around it just like I tuck a blanket around her when she’s in the carrier. She’s also gotten better at both imitating us when we brush our teeth and letting me brush her teeth. She’s been working on coordinating the use of a fork and a spoon. She took her T-shirt and her pajamas off all by herself. She sometimes insisted on my waiting for her as she climbs up and down the stairs by herself. She liked doing things at the same time we did, whether it was taking pictures with the camera or cleaning the kitchen.

We got our flu shots, bought more gifts, and packed for the trip. I donated A-‘s outgrown clothes and walker to the JFRC. I found the Reddit JSON for upvoted posts and incorporated that into my Emacs News workflow. I started looking into photobooks, and I’m leaning towards figuring out ImageMagick incantations so that I have more control.

The major system update at work seems to be going well. I fixed a couple of small bugs related to tagged documents and header internationalization. No emergencies, yay! I’ll probably still bring the work laptop just in case.

Next week: travel and family time…

Contemplating A-‘s enamel hypoplasia

I get a little anxious about A-‘s teeth. She has enamel hypoplasia, and there are large spots where enamel didn’t fully form. I’ve taken her to the dentist a number of times, and I even got a second opinion. Both dentists recommended watching and waiting, trying to make brushing a pleasant habit instead of restraining her, holding off on fluoride toothpastes or varnishes until she can reliably rinse and spit, and playing the long game when it comes to minimizing anxiety about dental care – better to avoid potentially traumatizing kids. Most days I can get her to either use the electric toothbrush or let me brush her teeth. A- does like rinsing and spitting at home, but I’m not sure I can get her to do that at a dentist’s office after a possibly upsetting varnish, and she still sometimes drinks the water instead of spitting out out. It’s just a little nerve-wracking to watch the slow discoloration of the rear surfaces of her front teeth and wonder when she’ll be able to sit for treatment, while keeping things pleasant and worry-free for A- so that she doesn’t develop dental anxiety.

The research papers I’ve read recommend fluoride varnishes even for very young children, but I’m reluctant to push for something against the recommendations of two dentists who’ve seen A-. I think I can trust their experience and that they’ve considered the research findings, too.

It can be reassuring to plan for the worst-case scenario. Let’s say A-‘s teeth start hurting. We’d take her to the dentist to have a look. Let’s say the teeth most affected by enamel hypoplasia need to be filled or even extracted before A- can sit still for cleanings or less invasive treatments. We’d take her in for dental work under sedation. It would be expensive, but that’s something we can save for. She might have spacers to help with the growth of her permanent teeth. It would suck, but there shouldn’t be any long-term pain, and she would probably catch up in growth after that’s resolved. If she does end up with anxiety about dentists, well, maybe play therapy and psychotherapy can help. After all, she’s similarly unhappy with ocularists, ophthalmologists, cardiologists, pediatricians, and nurses, but we don’t let that stop us from doing what’s necessary.

I think I’m partly worried that A- might not be able to tell us if her teeth hurt. She’s pretty good at telling us when she bumps her elbow or drops something on her toe, though. She loves eating frozen blueberries and doesn’t have a fever. Her gums don’t look like they have abscesses, although her top front teeth do have dark brown spots on the back.

I’ll probably take her to the dentist when we get back from our trip, partly for familiarization and partly for peace of mind. Maybe we can plan it for a day when W- can take us in the car. Or maybe we’ll get proper snow pants for A- and gradually work up to regularly spending time outside, so then we can make it to the appointment by subway. We can deal.

Lots of people get cavities. I still need the occasional filling, even though I try to take good care of my teeth. Lots of kids get cavities, and the Internet says the cavities tend to bother the parents more than they bother the kids. It’s not the end of the world. It’s not fully under my control, either. All we can do is deal with things and try to build good habits. It’s going to be okay.

2017-12-11 Emacs news

Links from reddit.com/r/emacs, /r/orgmode, /r/spacemacs, Hacker News, planet.emacsen.org, YouTube, the changes to the Emacs NEWS file, and emacs-devel.

Weekly review: Week ending 2017-12-08

Cognition: This week was a good one for sorting. A- grasped the concept of “same” when I demonstrated it with the cans in the pantry. She was able to put cans of red kidney beans together and cans of soup together, and she could even distinguish between chicken soup and mushroom soup.

Emotion: A- showed a little anxiety whenever we peeled oranges, burying her face in me until we gave her the all clear. It’s a good way to avoid getting squirted in the eye, that’s for sure.

Field trips: We discovered that a nearby community centre has a warm toddler pool and long weekend hours. It might become our new favourite.

Motor: A-‘s been getting the hang of the tongs that I placed under the sink for her. She can pick up plastic bags and ping pong balls now. She also spent some time having fun with stickers, and can usually peel them off the sticker sheets herself.

Lots of climbing up and sliding down the slide that we improvised from pillows and the other mattress in her room. She used to climb up the incline, but now she mostly takes the long way around. She also wears pants more often now, instead of going around bare. That makes sliding more comfortable. Besides, no clothes = no pictures or videos, and she likes being on camera and reviewing the videos.

Also, A- rather amusingly flaps her arms and calls that jumping jacks.

Household: A-‘s good at putting away dishes now. I take them out of the dishwasher and hand them to her, and she puts them on the shelves as she stands on the counter. I hover behind her for safety. We probably can’t rejig our kitchen layout to put the dishes lower, but this seems like a reasonable risk for more sorting and counting practice. Maybe when she’s bigger, she can use the tower as an in-between step for boosting herself up and lowering herself.

She’s gotten the hang of the microwave routine, too. We open the door together, put in food, cover it, close the door, press buttons (hooray for child lock), make a whirring sound, open the door, remove the cover, use a towel to carefully remove the pretend-hot food, and let it cool down. She had lots of fun labeling each step.

Sensory: lots of stepping on bubble wrap, and a bit of using her hands too. She likes the crinkly sound the plastic bags make, and trying to catch them when I toss them up in the air. Some water play in the sink, too.

Us: I made it out to the Philippine consulate to pick up my passport, and I bought a few gifts for our upcoming trip. W-‘s been working late, but we stocked the fridge with plenty of food, so we were fine. He completed the stairs and the temporary porch, so we can use the front door again. The camera W- gave me is working out really nicely even with our indoor light, so we’ve been building a habit of sharing photos and videos with him after dinner. Yay!

W- hung out with A- for a couple of hours on Sunday so that I could investigate an upgrade-related issue and do a braindump to help one of my team mates understand our data extract script better. It was nice to have that focused time.

Next week: more trip preparations!