Blog Archives

How I met the qutebrowser


It was through the ‘windows’ of Internet Explorer that I first got a glimpse of the Internet world. During those days, every PC you buy came with a version of Windows XP installed. I doubt if I knew about any other browsers back then ( I don’t think I even cared.). A couple of years later around 2007, is when I installed Ubuntu. Those where the days when Ubuntu used to ship free CDs. That opened up a new world for me. I remember, how I initially struggled to get the Internet working in Ubuntu, I used to boot back and forth from Windows to search for workarounds and then to Ubuntu to try it out, and finally when I had the internet working on ubuntu, firefox became my favourite browser for a very long time ( I have had my thing for Chrome but firefox still has that special spot.) That was until recently.

I am a person who hates the mouse. Every time my hand moves from the keyboard to the mouse, there is a part of me that dies. So with weekends with nothing to do due to the lockdown, I started my search for a browser that is mainly keyboard oriented.
Being an Emacs fan, my first criteria was to find something that used the Emacs keybindings, and I stumbled upon Next. I was ecstatic when I was reading through the github page. But within 30 minutes of usage , my excitement soon died out. There were several sites that Next could not handle. I realised that this is still a project in the nascent stage. Well I hope they do make progress in fixing all those issues, because I would love to use that as my main browser.

The next project that came up was the qutebrowser. As per the qutebrowser website, qutebrowser is a minimalist keyboard focused browser. The only problem was that it uses the VI keybindings. Nevertheless since I saw a couple of good reviews about the project, I decided to take this for a spin. I quickly glanced through the cheat sheet. I was already familiar with some VI shortcuts. I was soon surfing through the internet waves on qutebrowser. Despite the fact that I had some learning curve due to the VI keybindings, the experience was much more pleasant and I felt much more efficient compared to the traditional mouse based browsers.

On Ubuntu all you have to do is:

sudo apt install qutebrowser

and you are all set. It might be a good idea to keep the cheatsheet open for the first couple of hours until you get familiar.

Most of the keybindings are intutive, like ‘o’ means open a link, which will give you a prompt to type the hyper link. You can scroll a page using the ‘j’ and ‘k’ keys.

Qutebrowser also has a pass through mode which can be activated and deactivated using the Ctrl-v. With the pass through mode all keypresses from the keyboard are treated as normal and will not be interpreted as commands. This is from the VI mode concept.
By default you are in the command mode and that is how keys like ‘o’, ‘j’ and ‘k’ have different meanings. But on pressing ‘i’ you enter the insert mode or the edit mode where the keypresses are treated as characters entered. For readers who are not familiar with the VI, maybe it is a good idea to have some familiarity with VI before trying the qutebrowser.

After three weeks of usage I can say that the honeymoon period is over and here is what I like about the qutebrowser:

  1. qutebrowser is a minimalist browser. All it has is a title bar, and that too a very narrow one.
  2. It is 99% keyboard oriented. The 1% is because I still could not figure how to copy paste content from the webpages without using the mouse.
  3. It is as fast as chrome or firefox.
  4. It does not consume a whole lot of memory like chrome.
  5. Despite being minimalist, it can still play videos from Youtube, CuriosityStream etc.
  6. It does a decent amount of adblocking.

The things that I wish qutebrowser had:

  1. Qutebrowser still does not have a mechanism for autofill of forms and passwords.
  2. Ocassionaly I have seen the qutebrowser crashing if I leave it on for a long time. I am still not sure about this and once I am I will considering raising an issue in the github page.

Here is a very short video of qutebrowser in action.

qutebrowser

So why don’t you try it out and let me know your thoughts on the qutebrowser.

Rtags completes Emacs


This post is a description of how to setup Rtags on Emacs.  The internet is has quite a few resources about Rtags’ setup, but despite that I had to go over several of them to get things up and running for me.

Rtags is ideally meant to work for C++ projects that use CMake build systems, for others there are a few tweaks that may be needed. So here is the setup that works for developers using the traditional GNU Make for building their projects.

So here goes my setup:

To start with I had Emacs already installed, and I use Ubuntu 18.04

Installing Clang

Fire up a terminal and execute the following commands

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main"
sudo apt-get update
sudo apt-get install clang-3.9 lldb-3.9
sudo apt-get install libclang-3.9-dev

Installing Rtags Server

Once you have clang installed now its time to install Rtags. This can be done with the following commands

git clone --recursive https://github.com/Andersbakken/rtags.git
cd rtags
mkdir build
cd build
cmake ..
make

If the make executes with out any errors then it’s time to move forward. Once this install is complete you can start the rtags server with the rdm command

rdm -j3 &

If this does not work ensure that $PATH has the path to your rtags/build/bin folder which was created in the above steps, added to it. The rdm process is located in that folder.

This will have the rdm process running and listening to build commands and create the cache for the code navigation.

Install The Rtags plugin for Emacs

Emacs being an awesome editor all you have to do is

M-x package-install RET rtags RET
M-x package-install RET flycheck-rtags RET
M-x package-install RET company-rtags RET

Now in your .emacs file add the following(sourced from here)

(defun setup-flycheck-rtags ()
  (interactive)
  (flycheck-select-checker 'rtags)
  (setq-local flycheck-highlighting-mode nil)
  (setq-local flycheck-check-syntax-automatically nil))

;; only run this if rtags is installed
(when (require 'rtags nil :noerror)
  ;; make sure you have company-mode installed
  (require 'company)
  (define-key c-mode-base-map (kbd "M-.")
    (function rtags-find-symbol-at-point))
  (define-key c-mode-base-map (kbd "M-,")
    (function rtags-find-references-at-point))
  ;; install standard rtags keybindings. Do M-. on the symbol below to
  ;; jump to definition and see the keybindings.
  (rtags-enable-standard-keybindings)
  (setq rtags-autostart-diagnostics t)
  (rtags-diagnostics)
  (setq rtags-completions-enabled t)
  (push 'company-rtags company-backends)
  (global-company-mode)
  (define-key c-mode-base-map (kbd "<C-tab>") (function company-complete))
  ;; use rtags flycheck mode -- clang warnings shown inline
  (require 'flycheck-rtags)
  ;; c-mode-common-hook is also called by c++-mode
  (add-hook 'c-mode-common-hook #'setup-flycheck-rtags))

If you use the CMake build systems the story kind of ends here, but as I said if you use the GNU Make then hold on .

A Secret Recipe for GNU Make users

Go back to the rtags folder where we synced the code from github. Remember that in step 1 we created a build folder to build rtags and that the binary rdm was present in rtags_path/build/bin

What we are going to do is use the rtags wrappers for g++/gcc to ensure that when these commands are triggered rdm process will listen and create the cache needed for it to work.

So in a terminal we will do the following

ln -s /path-to-rtags/bin/gcc-rtags-wrapper.sh /path-to-rtags/build/bin/g++
ln -s /path-to-rtags/bin/gcc-rtags-wrapper.sh /path-to-rtags/build/bin/gcc

The paths to these newly created symbolic links should already be a part of $PATH from step 1.

After doing this step open a new terminal and type:

which g++

If this returns the path to the newly created links then you are set.

Once this is done go to your project folder and build the project. If you have the terminal with rdm running you can see it is logging some information. Once this stops. You are all set. Start Emacs and open a source file. The key bindings for each action can be found on the C++ menu as shown below.

emacs_rtags

Here is a short demo of how to navigate the code using rtags

rtags_demo

Hope you found this useful.

%d bloggers like this: