Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

This Week I Learned - 2016 Week 19

Write-up for last week or you might want to read the whole series.

Mithridatism, the practice of gradually building immunity towards poison through self-administering smaller and non-lethal dose. The first thing that came to my mind is the fictional sect  of Five Poisons Cult in the Wuxia, a genre of Chinese fiction focus on chivalry and martial arts in ancient China.

Surviving the Framework Hype Cycle. Crucial presentation for those working in web development. Either you go with the fad and endure the mid-life crisis. Which is coincident with what I learned last week regarding emerging technologies and how to interpret it through Gartner Hyper Cycle

Why are developers always chasing the latest shinny new things in the development world? Two reasons. First, the resume-driven development where we all wanted to use the latest, greatest, or sexiest technologies to build system regardless the suitability. Second, to join the league of 10x developer. Someone actually jokes that x represents the original estimation, which is true sometimes.

Bradon Hays' letter to an aspiring developer. In short, learn and work with smart people to level up your skill. But I do agree, regardless the experiences, it takes a developer around 6 to 12 months to be comfortable with any programming languages and frameworks. And most importantly, don't be those 10-plus years developer who have SAME year of experience, 10-plus times. Something interesting that he mentioned about masking "honesty" or "humility" as pessimism, contrary to what Dijkstra wrote in his Turing Award Lecture, The Humble Programmer.

New GNU Emacs website. (HN discussion) I think Free Software Foundation (FSF) finally realize the needs to have suitable way to promote free software and attract developers, especially Emacs. I suspect the release of Visual Studio Code might have something to do with it. For a start, why not  have a more sensible default configuration? FSF needs a good re-branding and marketing, not the philosophy but the brand itself. Maybe is time for me to help out with the development as well? But first, how much evil I need in Emacs?

Sticky keys. I was aware of it but didn't pay much attention but was reminded again. Interesting way to reduce the possibility of Repetitive Strain Injury (RSI).

Cure for Cron's cronic problem. I'm not sure why this feature was not added to the Cron itself? While the moreutils' chronic provides similar feature, Cronic have better error reporting as shown below.
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron  cronic backup

Cronic detected failure or error output for the command:


cp: data2: Permission denied


+ cp -rp data1 /backup
+ cp -rp data2 /backup
cp: data2: Permission denied

Someone sent me this good advice on finding happiness. I'm not sure who wrote this, but the advice seems thought provoking.
  1. Make a list of things that make you happy
  2. Make a list of things you do every day
  3. Compare the list
  4. Adjust accordingly

This Week I Learned - 2016 Week 12

Last week post or the whole series.

#1 LXD 2.0 blog post series. Write-up by St├ęphane Graber on the upcoming LXD 2.0 release. Since the REST API support are pretty much quite stable these days, you can't blame where numerous web front ends (lxd-webui and lxd-webgui) exists. Between two different container implementations, I still prefer LXC to Docker. The unfortunate case is Docker has the popularity and financial backing to move things faster.

#2 "End of file during parsing". Encountered this error message when I was customizing my Emacs. This is due to excess open or close parentheses. Surprised to know that the debugging procedures is quite tedious. I'm still not getting used to the enormous long Emacs default key bindings.

#3 Emacs' Sequence of Actions at Startup. For Emacs 24.x. That is one long list of items to run during program startup.

#4 .PNONY in a Makefile. It just dawned to me that the obvious reason is that we set certain targets as .PNONY because these are not file target!

#5 Certain metals antiseptic effect. Hence, why musical instruments and some door knobs are made from brass.

#6 Which activity brings out the worst in people? Sad but true, I've to agree with the discussion of the top post. Inheritance, mostly caused by the wife/husband of the siblings.

#7 Seeing the Current Value of a Variable. Either 'Ctrl+h v' or 'Mx describe-variable' to find the value of a configuration item in Emacs.

#8 Telsa's Euology. Surprised to found out about her passing. Used to follow her blog in the early days of GNOME project when Alan Cox was still the Linux kernel maintainer.

The Road to Evil

Few years back, I've tried it but the transition experience still a lot to be desired. But due to the recent circumstance which piqued my interest to revisit this long overdue to-do item in my someday list again. Yes, to become an engaged member of the Church of Emacs.

Joke aside. With the recent development of Emacs and the more stable releases of its related plugins, the transition from Vim to Emacs seems doable and manageable. You still can retain most of the Vim experience in Emacs through Evil (Extensible Vi Layer for Emacs), but not without some additional customization. More on that in coming posts.

Installation in Ubuntu.
$ sudo apt-get install emacs24

$ emacs --version
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Well, this is Ubuntu/Debian, checking the emacs binary. Maybe there other Emacs implementations available?
$ file $(which emacs)
/usr/bin/emacs: symbolic link to /etc/alternatives/emacs

$ file /etc/alternatives/emacs 
/etc/alternatives/emacs: symbolic link to /usr/bin/emacs24-x

$ sudo update-alternatives --config emacs
There is only one alternative in link group emacs (providing /usr/bin/emacs): /usr/bin/emacs24-x
Nothing to configure.

By default, Emacs starts with X window system. If you want to bypass this behaviour and start in console instead, use the '-nw' parameter or add an alias instead.
$ emacs -nw
$ alias emc='emacs -nw'

Next is to install the Evil package for Emacs. If you need something up fast, check out the blog post by Bling and his Evil-mode bootstrap config. There is also a tutorial video to demonstrate evil-mode in Emacs. Ironically, I learned more about Vim than Emacs from his video.

To automatically install missing packages, the '.emacs.d/init.el` as follows.
$ cat .emacs.d/init.el 
; required packages
(setq package-list '(evil))

; additional repository
(require 'package)
(add-to-list 'package-archives '("melpa" . ""))

; activate and refresh all the packages
(unless package-archive-contents

; install the missing packages
(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

; enable evil-mode
(require 'evil)
(evil-mode 1)

Start Emacs in console but enable debugging. If there are no issues, Emacs will start normally and you can immediately start using it with Vim's default key bindings.
$ emacs -nw --debug-init

To prevent Repetitive strain injury (RSI), one the of way when using Vim is reducing your pinky or little finger usage. For the left pinky, the Escape (Esc) key and for the right pinky, the colon (:) key.

The Escape key.
This can be done by mapping 'jj' key to Escape key. Updates to our '.emacs.d/init.el' file.
$ cat init.el | grep "required\|exit" -A 3
; required packages
(setq package-list '(evil key-chord))

; additional repository
; exit insert mode by pressing j and then j quickly
(setq key-chord-two-keys-delay 0.5)
(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
(key-chord-mode 1)

Binding the Colon (:) key.
This can be achieved by binding the colon (:) key to semicolon (;) key. Thus remove the needs to use the right Shift key. Changes to '.emacs.d/init.el' as shown again.
$ cat init.el | grep "evil-ex" -B 1
; bind ';' to ':'
(define-key evil-normal-state-map (kbd ";") 'evil-ex)

Restart Emacs and both settings should be customized to our liking.

As someone who suffered from RSI (rare these days but still prevention is still better than cure), these two customization are the essential minimum requirements for me to have a painless typing sessions. Not sure why, but both these settings should be the sensible default to Evil-mode, not enable by default, but should be part of the settings.

Stay tuned, expect more Emacs customization posts in coming months.