How to enable a non-global minor mode by default, on emacs startup?

rainbow-mode isn’t a global minor mode, so it needs to be enabled on a per-buffer basis. I only use it for CSS, so I have: (add-hook ‘css-mode-hook ‘my-css-mode-hook) (defun my-css-mode-hook () (rainbow-mode 1)) If you genuinely want it to be global, everywhere, you can easily define a global minor mode yourself: (define-globalized-minor-mode my-global-rainbow-mode rainbow-mode (lambda … Read more

Finding the max value in a map

You can use std::max_element to find the highest map value (the following code requires C++11): std::map<int, size_t> frequencyCount; using pair_type = decltype(frequencyCount)::value_type; for (auto i : v) frequencyCount[i]++; auto pr = std::max_element ( std::begin(frequencyCount), std::end(frequencyCount), [] (const pair_type & p1, const pair_type & p2) { return p1.second < p2.second; } ); std::cout << “A mode … Read more

How to write an emacs mode for a new language?

If you’re lazy, one easy way is to extend generic-mode to know about your new language: http://emacswiki.org/emacs/GenericMode I do this a lot for config files for applications that I work with a lot to get decent syntax highlighting. Here’s one I did for the asterisk PBX a long time ago as an example.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)