Customizing Hide-Show for CMake Mode in Emacs

customizing HideShow mode on Emacs is done by hs-special-modes-alist. There are 4 parts (actually 5, but we care mostly about the 3) of the equation. You can customize it for your mode with a list like this

  (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC)

For example, the default definition of the hs-special-modes-alist looks like this:

  (defvar hs-special-modes-alist
    (mapcar #'purecopy
            '((c-mode "{" "}" "/[*/]" nil nil)
              (c-ts-mode "{" "}" "/[*/]" nil nil)
              (c++-mode "{" "}" "/[*/]" nil nil)
              (c++-ts-mode "{" "}" "/[*/]" nil nil)
              (bibtex-mode ("@\\S(*\\(\\s(\\)" 1))
              (java-mode "{" "}" "/[*/]" nil nil)
              (java-ts-mode "{" "}" "/[*/]" nil nil)
              (js-mode "{" "}" "/[*/]" nil)
              (js-ts-mode "{" "}" "/[*/]" nil)
              (mhtml-mode "{\\|<[^/>]*?" "}\\|</[^/>]*[^/]>" "<!--" mhtml-forward nil)
              ;; Add more support here.
              ))

The ingredients

START and END regular expression

This regular expression matches the beginning/end of the folding code. For C/C++ alike languages, this is as brackets "{", "}", etc. For some language lacks of any brackets/parenthesis like python, it is more difficult. Emacs' built-in python mode provided patch to support it:

Event bus implementation

Recently I open sourced a small C++ library called eBus(Event Bus), it came along separated from another project I was working on. The idea, or should I say the interface was not very original, I took the inspiration from a much more complicated Event Buses In O3DE. The goal is simple, providing an easy to use Observer pattern so your can decouple the code from the callers to its callees.

Instead of doing this:

Moving to Hugo, Aftermath

My blog is now back online, with brand new render engine Hugo. The URLs are totally different though. Not sure how web crawlers handling it right now.

After the migration, I did a few extra work for patching the hiccups. Fix the build warnings and adding new features.

The about page

In every blog you always have some pages that you do not want it be inside the blog list. By default Hugo will simply place everything on the “navigation list”. Even if I place it outside the blog folder. This is the list your template is calling .NextPage and .PrevPage. So initially I just give it a very old date, or simply removed the date, so it will appear as the last on the list. Obviously I will have to fix that.

Moving to Hugo

For a long time I’ve been wanting to Migrate my blog system from Pelican to Hugo. One reason is that I had enough with python virtual environment breaks every 3 months. Another motivation is obviously I would like to replace Python with Go in my life.

A long time ago I followed Go tutorial for getting started, surprised by its syntax tidiness and similarity to Python, and it is way faster. But soon I found out it would be one of this thing I learned for a weekend and forget all together, since I don’t have any projects I would use it actively. Now after one month of procrastination, I finally pieces ALMOST everything to reproduce my old blog. Time for a summary.

Belief or Cult

It’s been a while that I haven’t update the blogs. It is so easy to slack off on good habits. “Oh I will continue once I finish A B C”. We are all busy as hell, in the software world, you WORK, you WORK and you GO TO SLEEP. Like this one, I am always hoping to switch to Hugo, then I can continue writing the blog. The thing is, I never got the good weekend to do the switching. Weekends are really no for staying at home confronting monitors.

July 2021 Status Update

I am now back in Canada, quarantined again. There is much of internal struggle whether I should move back or stay in Shanghai? Working for tech company in Shanghai or many cities in China would be like endless crunching. Maybe I was not used to this high-paced lifestyle, long working hours. Didn’t like javascript either. It is a pity that I didn’t find a nicer job maybe opens to better opportunities. I was focusing on the development of Taiwins back then, well it is working now and I don’t develop it anymore. The June was pretty unproductive, ever since the ICL implant surgery I couldn’t use computers for long, even now it is painful to do so. At least I get more time reading books?

Back with Org Mode

If there is one thing I’d like to commit it must be the my time mangement improvements. For that purpose, Emacs Org-mode is the ultimate tool for programmers. I can keep my notes nicely and I can track my tasks/errands all together. But all my notes are stored in my linux box, I lose access to them once I am away. From that reason, I was always on-and-off with using org-mode due to the portability. We are not in the age doing everything with desktop anymore, more often I need to track my TODOs from cellphone as well.

Jan 2021 Status Update

Folks, the Magical year of 2020 is behind us, and it wasn’t a happy new chapter waiting us. Man, I still couldn’t believe, once per 100 years, why it was us who have to face the coronavirus. Now I take a good look of my 2020, I went from trying to submit a xcbcommon handling patch to weston to writing a full wayland compositor from scratch. It was not my plan!!! Taiwins should have being a rather simple application on top of the libweston, the so called “reference compositor “, but libweston cannot change keyboard layout once launching, nor it can support cloning output, there are new bugs when you digging deep. The worst is that it breaks the library into different shared modules, and changes lib location every release. It was like it really does not want to link to it. The codebase was old and long, it was difficult to make a change and really difficult to get libweston taking a patch. Then there is the wlroots. If it was released half year earlier Taiwins would probably sit on top of that. But, screw it. I am doing it myself.

August 2020 Status Update

It is a sunny day, somehow I got up early this morning. The cool, chilling breath of air reminded me we are at the tail of the summer. It felt so strange, this summer was like it was never here. Hiking, go swimming, taking a trips and night outs. all those experiences for a normal summer I would do, they are all absent, hope I don’t regret too much for crunching code at home all these months. It was a tough year actually, I was determined to push Taiwins to a usable state, it has been stressful. Every time I look at the pile of the TODO list, a sentiment of endless development and desperate hit me hard like a heart attack. I had to work a lot to stay healthy.

July 2020 Status Update

July, the hottest month in Montreal every year. The heat wave rushes to you when you walk outside makes you wondering if you are in some tropical island, it sure doesn’t look like living at 45 latitde northen hemisphere. Last month was a rapid leap towards wayland objects implementations and now I just hitted the wall of xdg-shell protocol. Today I’d like to talk about what it is like to implement a wayland protocol.