Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

Emacs:

Emacs offers you extreme configurability without depending solely on pre-defined functions and variables. Perhaps, the most significant characteristic of vim is its blazing speed and almost no burden from adding bells and whistles. And one of my favorite features in Vim is the relative numbering of the lines. This allows you to almost instantly use Vim’s commands with lines/numbers as arguments. In the code snippet below (Linux Kernel), say, you wanted to remove the comment with “TODO” since the comment is no longer valid in the context. You do not have to start calculating

void update_rq_clock(struct rq *rq)
{
        s64 delta;

        lockdep_assert_held(&rq->lock);

        if (rq->clock_update_flags & RQCF_ACT_SKIP)
                return;

        /* TODO: add config sched debug warning */
#ifdef CONFIG_SCHED_DEBUG
        if (sched_feat(WARN_DOUBLE_CLOCK))
                SCHED_WARN_ON(rq->clock_update_flags & RQCF_UPDATED);
        rq->clock_update_flags |= RQCF_UPDATED;
#endif

        delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;
        if (delta < 0)
                return;
        rq->clock += delta;
        update_rq_clock_task(rq, delta);
}

Voidstar Podcast:

This came out my interview for the VoidStar Podcast Series with Joe Armstrong.

Idea:

The idea is to track your activity via Emacs. Given that Emacs is more of “an OS that lacks a good editor” this is actually possible.

Outline:

Here I give you the outline of how to setup your Emacs system so that you can try and track your activity too.

Tracking:

The primary idea is to track which file you have been spending the most time on per week.

Plugin:

For this you will need an Emacs plugin that can keep track of when you opened a file and when you closed it.

Emacs Config:

Here’s my code to do this, but before that, I have to disclose that a part of this code was lifted from some response to StackOverflow question etc.

Reference:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Visiting-Functions.html#Visiting-Functions

Emacs Lisp:

This does not handle closing Emacs altogether, and killing Emacs all of a sudden. Frankly neither of these are an occurence in my system. So here goes.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;; My edits to track the files I use
(add-hook 'before-save-hook 'time-stamp)

(defvar my-m-x-log-file "~/mx.log")
;; (defadvice execute-extended-command (after log-execute-extended-command activate)
;;   (let ((logfile (find-file-noselect my-m-x-log-file)))
;;     (with-current-buffer logfile
;;       (goto-char (point-max))
;;       (insert (format "%s %s\n" this-command 'insert-time-stamp))
;;       (save-buffer))))
(defvar current-date-time-format "%a %b %d %H:%M:%S %Z %Y")
(add-hook 'find-file-hook 'my-fileopen-hook)
(defun my-fileopen-hook()
  (setq my-buf-name (buffer-file-name))
  (let ((logfile (find-file-noselect my-m-x-log-file)))
  (with-current-buffer logfile
  (goto-char (point-max))
  (insert (format "[+] %s " my-buf-name))
  (insert (format-time-string current-date-time-format (current-time)))
  (insert "\n")
  (save-buffer)
  ))
  )

(add-hook 'kill-buffer-hook 'my-fileclose-hook)
(defun my-fileclose-hook()
  (setq my-buf-name (buffer-file-name))
  (let ((logfile (find-file-noselect my-m-x-log-file)))
  (with-current-buffer logfile
  (goto-char (point-max))
  (insert (format "[-] %s " my-buf-name))
  (insert (format-time-string current-date-time-format (current-time)))
  (insert "\n")
  (save-buffer)
  ))
)

My Podcast!

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes